From 8e10ea30d707f2e23e9c03ef2ccb7758a810baa3 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 4 Jan 2017 15:15:38 +0100 Subject: [PATCH] particle: update examples to take key params via command line Signed-off-by: deadprogram --- examples/particle_api.go | 10 +++++++++- examples/particle_blink.go | 10 +++++++++- examples/particle_button.go | 11 ++++++++++- examples/particle_events.go | 10 +++++++++- examples/particle_function.go | 10 +++++++++- examples/particle_led_brightness.go | 10 +++++++++- examples/particle_variable.go | 10 +++++++++- 7 files changed, 64 insertions(+), 7 deletions(-) diff --git a/examples/particle_api.go b/examples/particle_api.go index cf725627..bcfbbd53 100644 --- a/examples/particle_api.go +++ b/examples/particle_api.go @@ -1,6 +1,14 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_api.go mydevice myaccesstoken +*/ + package main import ( + "os" "time" "gobot.io/x/gobot" @@ -13,7 +21,7 @@ func main() { master := gobot.NewMaster() api.NewAPI(master).Start() - core := particle.NewAdaptor("device_id", "access_token") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) led := gpio.NewLedDriver(core, "D7") work := func() { diff --git a/examples/particle_blink.go b/examples/particle_blink.go index 4e521ea3..b24085f9 100644 --- a/examples/particle_blink.go +++ b/examples/particle_blink.go @@ -1,6 +1,14 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_blink.go mydevice myaccesstoken +*/ + package main import ( + "os" "time" "gobot.io/x/gobot" @@ -9,7 +17,7 @@ import ( ) func main() { - core := particle.NewAdaptor("device_id", "access_token") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) led := gpio.NewLedDriver(core, "D7") work := func() { diff --git a/examples/particle_button.go b/examples/particle_button.go index ec123647..9ea1c41f 100644 --- a/examples/particle_button.go +++ b/examples/particle_button.go @@ -1,13 +1,22 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_button.go mydevice myaccesstoken +*/ + package main import ( + "os" + "gobot.io/x/gobot" "gobot.io/x/gobot/drivers/gpio" "gobot.io/x/gobot/platforms/particle" ) func main() { - core := particle.NewAdaptor("device_id", "access_token") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) led := gpio.NewLedDriver(core, "D7") button := gpio.NewButtonDriver(core, "D5") diff --git a/examples/particle_events.go b/examples/particle_events.go index 27f9b3d8..e04e5599 100644 --- a/examples/particle_events.go +++ b/examples/particle_events.go @@ -1,14 +1,22 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_events.go mydevice myaccesstoken +*/ + package main import ( "fmt" + "os" "gobot.io/x/gobot" "gobot.io/x/gobot/platforms/particle" ) func main() { - core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) work := func() { if stream, err := core.EventStream("all", ""); err != nil { diff --git a/examples/particle_function.go b/examples/particle_function.go index 90fba9f4..35306c54 100644 --- a/examples/particle_function.go +++ b/examples/particle_function.go @@ -1,14 +1,22 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_function.go mydevice myaccesstoken +*/ + package main import ( "fmt" + "os" "gobot.io/x/gobot" "gobot.io/x/gobot/platforms/particle" ) func main() { - core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) work := func() { if result, err := core.Function("brew", "202,230"); err != nil { diff --git a/examples/particle_led_brightness.go b/examples/particle_led_brightness.go index 252601e7..c82b35cc 100644 --- a/examples/particle_led_brightness.go +++ b/examples/particle_led_brightness.go @@ -1,6 +1,14 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_led_brightness.go mydevice myaccesstoken +*/ + package main import ( + "os" "time" "gobot.io/x/gobot" @@ -9,7 +17,7 @@ import ( ) func main() { - core := particle.NewAdaptor("device_id", "access_token") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) led := gpio.NewLedDriver(core, "A1") work := func() { diff --git a/examples/particle_variable.go b/examples/particle_variable.go index 88620c52..5af8c07f 100644 --- a/examples/particle_variable.go +++ b/examples/particle_variable.go @@ -1,7 +1,15 @@ +/* + To run this example, pass the device ID as first param, + and the access token as the second param: + + go run examples/particle_variable.go mydevice myaccesstoken +*/ + package main import ( "fmt" + "os" "time" "gobot.io/x/gobot" @@ -9,7 +17,7 @@ import ( ) func main() { - core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN") + core := particle.NewAdaptor(os.Args[1], os.Args[2]) work := func() { gobot.Every(1*time.Second, func() {