devicehive / IoT-framework

* DEPRECATED * DeviceHive GO Framework for IoT and M2M
http://devicehive.com
MIT License
40 stars 17 forks source link

Refactor examples/cloud-ble and cloud-ble-build #5

Open astaff opened 9 years ago

astaff commented 9 years ago

examples/cloud-ble implements a general purpose ble-cloud bridge, which is great, however, we don't really want to expose all BLE commands as is. For this purposes we've created cloud-ble-build, which accepts special command, Init, with parameters mac and type (which is actually a BLE device name). This command will store mac and name and will keep trying to connect to device and once connected try to init, and the init on re-connect, etc. Please refactor this logic and add it to default cloud-ble logic, so the user can create custom init mappings like (please forgive my syntax):

ble.AddMapping("", "sensortag", func(mac, name string) { { time.Sleep(500 * time.Millisecond) ble.BleGattWrite(mac, "F000AA1204514000b000000000000000", "01") time.Sleep(500 * time.Millisecond) ble.BleGattWrite(mac, "F000AA1304514000b000000000000000", "0A") time.Sleep(500 * time.Millisecond) ble.BleGattNotifications(mac, "F000AA1104514000b000000000000000", true) } }

After that, move mapping init process into cloud-ble-build. Maybe we should call it cloud-ble-demo.