gobot: gobot.io/x/gobot/platforms/pebble Index | Files

package pebble

import "gobot.io/x/gobot/platforms/pebble"

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:

go get gobot.io/x/gobot/platforms/pebble

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"
	"gobot.io/x/gobot/api"
	"gobot.io/x/gobot/platforms/pebble"
)

func main() {
	master := gobot.NewMaster()
	api.NewAPI(master).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,
	)

	master.AddRobot(robot)

	master.Start()
}

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

Index

Package Files

doc.go pebble_adaptor.go pebble_driver.go

type Adaptor Uses

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

func NewAdaptor Uses

func NewAdaptor() *Adaptor

NewAdaptor creates a new pebble adaptor

func (*Adaptor) Connect Uses

func (a *Adaptor) Connect() (err error)

Connect returns true if connection to pebble is established successfully

func (*Adaptor) Finalize Uses

func (a *Adaptor) Finalize() (err error)

Finalize returns true if connection to pebble is finalized successfully

func (*Adaptor) Name Uses

func (a *Adaptor) Name() string

func (*Adaptor) SetName Uses

func (a *Adaptor) SetName(n string)

type Driver Uses

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

func NewDriver Uses

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 Uses

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

func (*Driver) Halt Uses

func (d *Driver) Halt() (err error)

Halt returns true if driver is halted successfully

func (*Driver) Name Uses

func (d *Driver) Name() string

func (*Driver) PendingMessage Uses

func (d *Driver) PendingMessage() string

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

func (*Driver) PublishEvent Uses

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

PublishEvent publishes event with specified name and data in gobot

func (*Driver) SendNotification Uses

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

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

func (*Driver) SetName Uses

func (d *Driver) SetName(n string)

func (*Driver) Start Uses

func (d *Driver) Start() (err error)

Start returns true if driver is initialized correctly

Package pebble imports 1 packages (graph). Updated 2018-02-24. Refresh now. Tools for package owners.