pebble

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2016 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

go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/pebble

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"

	"github.com/hybridgroup/gobot"
	"github.com/hybridgroup/gobot/api"
	"github.com/hybridgroup/gobot/platforms/pebble"
)

func main() {
	gbot := gobot.NewGobot()
	api.NewAPI(gbot).Start()

	pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
	pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")

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

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

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

	gbot.AddRobot(robot)

	gbot.Start()
}

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-2014 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://github.com/hybridgroup/watchbot) installed on Pebble watch. Then install running:

go get github.com/hybridgroup/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"

	"github.com/hybridgroup/gobot"
	"github.com/hybridgroup/gobot/api"
	"github.com/hybridgroup/gobot/platforms/pebble"
)

func main() {
	gbot := gobot.NewGobot()
	api.NewAPI(gbot).Start()

	pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
	pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")

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

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

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

	gbot.AddRobot(robot)

	gbot.Start()
}

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PebbleAdaptor

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

func NewPebbleAdaptor

func NewPebbleAdaptor(name string) *PebbleAdaptor

NewPebbleAdaptor creates a new pebble adaptor with specified name

func (*PebbleAdaptor) Connect

func (a *PebbleAdaptor) Connect() (errs []error)

Connect returns true if connection to pebble is established succesfully

func (*PebbleAdaptor) Finalize

func (a *PebbleAdaptor) Finalize() (errs []error)

Finalize returns true if connection to pebble is finalized succesfully

func (*PebbleAdaptor) Name

func (a *PebbleAdaptor) Name() string

type PebbleDriver

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

func NewPebbleDriver

func NewPebbleDriver(adaptor *PebbleAdaptor, name string) *PebbleDriver

NewPebbleDriver creates a new pebble driver with specified name 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 (*PebbleDriver) Connection

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

func (*PebbleDriver) Halt

func (d *PebbleDriver) Halt() (errs []error)

Halt returns true if driver is halted succesfully

func (*PebbleDriver) Name

func (d *PebbleDriver) Name() string

func (*PebbleDriver) PendingMessage

func (d *PebbleDriver) PendingMessage() string

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

func (*PebbleDriver) PublishEvent

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

PublishEvent publishes event with specified name and data in gobot

func (*PebbleDriver) SendNotification

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

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

func (*PebbleDriver) Start

func (d *PebbleDriver) Start() (errs []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