forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Movinf events creation to newPebbleDriver method Adding basic button support Ignoring sass-cache and robeaux Adding accelerometer example Adding tap support Use custom server instead of classic martini This is to disable logs and avoid noise Adding correct format to code Adding notification support to pebble driver Adding tests and correcting PendingMessage Updating documentation Format to example accel Removing logging changes in api Removing temp fix in api, will be attended later Removing extra space
- Loading branch information
Javier Cervantes
authored and
Javier Cervantes
committed
Jun 10, 2014
1 parent
3de9d86
commit 3d454a7
Showing
14 changed files
with
240 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.sass-cache | ||
*.test | ||
robeaux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/pebble" | ||
"fmt" | ||
"fmt" | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/api" | ||
"github.com/hybridgroup/gobot/platforms/pebble" | ||
) | ||
|
||
func main() { | ||
pebbleAdaptor := new(gobotPebble.PebbleAdaptor) | ||
pebbleAdaptor.Name = "Pebble" | ||
master := gobot.NewGobot() | ||
api.NewApi(master).Start() | ||
|
||
pebble := gobotPebble.NewPebble(pebbleAdaptor) | ||
pebble.Name = "pebble" | ||
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") | ||
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble") | ||
|
||
master := gobot.GobotMaster() | ||
api := gobot.Api(master) | ||
api.Port = "8080" | ||
work := func() { | ||
pebbleDriver.SendNotification("Hello Pebble!") | ||
gobot.On(pebbleDriver.Events["button"], func(data interface{}) { | ||
fmt.Println("Button pushed: " + data.(string)) | ||
}) | ||
|
||
work := func() { | ||
gobot.On(pebble.Events["button"], func(data interface{}) { | ||
fmt.Println("Button pushed: " + data.(string)) | ||
}) | ||
} | ||
gobot.On(pebbleDriver.Events["tap"], func(data interface{}) { | ||
fmt.Println("Tap event detected") | ||
}) | ||
} | ||
|
||
robot := gobot.Robot{ | ||
Connections: []gobot.Connection{pebbleAdaptor}, | ||
Devices: []gobot.Device{pebble}, | ||
Work: work, | ||
} | ||
robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work) | ||
|
||
robot.Name = "pebble" | ||
|
||
master.Robots = append(master.Robots, &robot) | ||
master.Start() | ||
master.Robots = append(master.Robots, robot) | ||
master.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/api" | ||
"github.com/hybridgroup/gobot/platforms/pebble" | ||
) | ||
|
||
func main() { | ||
master := gobot.NewGobot() | ||
api.NewApi(master).Start() | ||
|
||
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") | ||
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble") | ||
|
||
work := func() { | ||
gobot.On(pebbleDriver.Events["accel"], func(data interface{}) { | ||
fmt.Println(data.(string)) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work) | ||
|
||
master.Robots = append(master.Robots, robot) | ||
master.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
package pebble | ||
|
||
func (sd *PebbleDriver) PublishEventC(params map[string]interface{}) { | ||
sd.PublishEvent(params["name"].(string), params["data"].(string)) | ||
sd.PublishEvent(params["name"].(string), params["data"].(string)) | ||
} | ||
|
||
func (sd *PebbleDriver) SendNotificationC(params map[string]interface{}) { | ||
sd.SendNotification(params["message"].(string)) | ||
} | ||
|
||
func (sd *PebbleDriver) PendingMessageC(params map[string]interface{}) interface{} { | ||
m := make(map[string]string) | ||
m["result"] = sd.PendingMessage() | ||
return m | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package pebble | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
"testing" | ||
) | ||
|
||
func TestGobotPebble(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Gobot-Pebble Suite") | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Gobot-Pebble Suite") | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package pebble | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("PebbleAdaptor", func() { | ||
var ( | ||
adaptor *PebbleAdaptor | ||
) | ||
var ( | ||
adaptor *PebbleAdaptor | ||
) | ||
|
||
BeforeEach(func() { | ||
adaptor = new(PebbleAdaptor) | ||
}) | ||
BeforeEach(func() { | ||
adaptor = NewPebbleAdaptor("pebble") | ||
}) | ||
|
||
It("Must be able to Finalize", func() { | ||
Expect(adaptor.Finalize()).To(Equal(true)) | ||
}) | ||
It("Must be able to Connect", func() { | ||
Expect(adaptor.Connect()).To(Equal(true)) | ||
}) | ||
It("Must be able to Disconnect", func() { | ||
Expect(adaptor.Disconnect()).To(Equal(true)) | ||
}) | ||
It("Must be able to Reconnect", func() { | ||
Expect(adaptor.Reconnect()).To(Equal(true)) | ||
}) | ||
It("Must be able to Finalize", func() { | ||
Expect(adaptor.Finalize()).To(Equal(true)) | ||
}) | ||
It("Must be able to Connect", func() { | ||
Expect(adaptor.Connect()).To(Equal(true)) | ||
}) | ||
It("Must be able to Disconnect", func() { | ||
Expect(adaptor.Disconnect()).To(Equal(true)) | ||
}) | ||
It("Must be able to Reconnect", func() { | ||
Expect(adaptor.Reconnect()).To(Equal(true)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.