pebble

package
v2.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

Pebble

This repository contains the Gobot adaptor for Pebble smart watch.

It uses the Pebble 2.0 SDK, and requires the 2.0 iOS or Android app, and that the "watchbot" app has been installed on the Pebble watch.

How to Install

Please refer to the main README.md

  • Install Pebble 2.0 iOS or Android app. (If you haven't already)
  • Follow README to install and configure "watchbot" on your watch: https://gobot.io/x/watchbot

How to Use

Before running the example, make sure configuration settings match with your program. In the example, api host is your computer IP, robot name is 'pebble' and robot api port is 8080

package main

import (
  "fmt"

  "gobot.io/x/gobot/v2"
  "gobot.io/x/gobot/v2/api"
  "gobot.io/x/gobot/v2/platforms/pebble"
)

func main() {
  manager := gobot.NewManager()
  api.NewAPI(manager).Start()

  pebbleAdaptor := pebble.NewAdaptor()
  watch := pebble.NewDriver(pebbleAdaptor)

  work := func() {
    watch.SendNotification("Hello Pebble!")
    watch.On(watch.Event("button"), func(data interface{}) {
      fmt.Println("Button pushed: " + data.(string))
    })

    watch.On(watch.Event("tap"), func(data interface{}) {
      fmt.Println("Tap event detected")
    })
  }

  robot := gobot.NewRobot("pebble",
    []gobot.Connection{pebbleAdaptor},
    []gobot.Device{watch},
    work,
  )

  manager.AddRobot(robot)

  if err := manager.Start(); err != nil {
    panic(err)
  }
}

Supported Features

  • We support event detection of 3 main pebble buttons.
  • Accelerometer events
  • Pushing data to pebble watch

Documentation

We're busy adding documentation to our web site at http://gobot.io/ please check there as we continue to work on Gobot

Thank you!

Contributing

  • All patches must be provided under the Apache 2.0 License
  • Please use the -s option in git to "sign off" that the commit is your work and you are providing it under the Apache 2.0 License
  • Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
  • We will look at the patch, test it out, and give you feedback.
  • Avoid doing minor whitespace changes, renamings, etc. along with merged content. These will be done by the maintainers from time to time but they can complicate merges and should be done seperately.
  • Take care to maintain the existing coding style.
  • Add unit tests for any new or changed functionality
  • All pull requests should be "fast forward"
  • If there are commits after yours use “git rebase -i <new_head_branch>”
  • If you have local changes you may need to use “git stash”
  • For git help see progit which is an awesome (and free) book on git

License

Copyright (c) 2013-2018 The Hybrid Group. Licensed under the Apache 2.0 license.

Documentation

Overview

Package pebble contains the Gobot adaptor and driver for Pebble smart watch.

Installing:

It requires the 2.x iOS or Android app, and "watchbot" app (https://gobot.io/x/watchbot) installed on Pebble watch. Then install running:

Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)

Example:

Before running the example, make sure configuration settings match with your program. In the example, api host is your computer IP, robot name is 'pebble' and robot api port is 8080

package main

import (
	"fmt"

	"gobot.io/x/gobot/v2"
	"gobot.io/x/gobot/v2/api"
	"gobot.io/x/gobot/v2/platforms/pebble"
)

func main() {
	manager := gobot.NewManager()
	api.NewAPI(manager).Start()

	pebbleAdaptor := pebble.NewAdaptor()
	watch := pebble.NewDriver(pebbleAdaptor)

	work := func() {
		watch.SendNotification("Hello Pebble!")
		watch.On(watch.Event("button"), func(data interface{}) {
			fmt.Println("Button pushed: " + data.(string))
		})

		watch.On(watch.Event("tap"), func(data interface{}) {
			fmt.Println("Tap event detected")
		})
	}

	robot := gobot.NewRobot("pebble",
		[]gobot.Connection{pebbleAdaptor},
		[]gobot.Device{watch},
		work,
	)

	manager.AddRobot(robot)

	if err := manager.Start(); err != nil {
	panic(err)
}
}

For more information refer to the pebble README: https://github.com/hybridgroup/gobot/blob/release/platforms/pebble/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor

type Adaptor struct {
	// contains filtered or unexported fields
}

func NewAdaptor

func NewAdaptor() *Adaptor

NewAdaptor creates a new pebble adaptor

func (*Adaptor) Connect

func (a *Adaptor) Connect() error

Connect returns true if connection to pebble is established successfully

func (*Adaptor) Finalize

func (a *Adaptor) Finalize() error

Finalize returns true if connection to pebble is finalized successfully

func (*Adaptor) Name

func (a *Adaptor) Name() string

func (*Adaptor) SetName

func (a *Adaptor) SetName(n string)

type Driver

type Driver struct {
	gobot.Commander
	gobot.Eventer
	Messages []string
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(adaptor *Adaptor) *Driver

NewDriver creates a new pebble driver Adds following events:

button - Sent when a pebble button is pressed
accel - Pebble watch acceleromenter data
tab - When a pebble watch tap event is detected

And the following API commands:

"publish_event"
"send_notification"
"pending_message"

func (*Driver) Connection

func (d *Driver) Connection() gobot.Connection

func (*Driver) Halt

func (d *Driver) Halt() error

Halt returns true if driver is halted successfully

func (*Driver) Name

func (d *Driver) Name() string

func (*Driver) PendingMessage

func (d *Driver) PendingMessage() string

PendingMessages returns messages to be sent as notifications to pebble (Not intended to be used directly)

func (*Driver) PublishEvent

func (d *Driver) PublishEvent(name string, data string)

PublishEvent publishes event with specified name and data in gobot

func (*Driver) SendNotification

func (d *Driver) SendNotification(message string) string

SendNotification appends message to list of notifications to be sent to watch

func (*Driver) SetName

func (d *Driver) SetName(n string)

func (*Driver) Start

func (d *Driver) Start() error

Start returns true if driver is initialized correctly

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL