Send bluz button click to app


#1

I have a basic android app that I can use to connect to Bluz DK. it works and I can get data sent with BLE.sendData.
Now I want the bluz to stay connected to my app doing nothing and using the least energy possible. When the user press a button connected to D2, it should wake up bluz and use BLE.sendData to send something to the app and go back to use the least energy possible. Does keeping the connection to the app use more energy? If yes, it is possible to keep the bluz disconnected and only connected it when the button is pressed (I only need to connect to the app on a know device).


#2

The best way to save energy would be to use SLEEP_MODE_DEEP in between button presses. This would shut everything down and draw as little power as possible. When the user presses a button, bluz can wake-up and start advertising, send whatever data it needs to send, and then go back to sleep.

This would have more lag then if it was always connected. If bluz needs to wake up and reconnect each time, then it would take a little longer. However, it may not be significant for your application so it may not be a big deal.


#3

Do you mind sharing the Bluz code for connecting to your app? I am having problem with the pairing of my phone - it times out and I wonder if it has to do with my code, or lack of it. The Bluz is set to manual mode (SYSTEM_MODE(MANUAL) and I can see it from my phone.

Thanks for your help!

-Hans


#4

Are you referring to any app code? Both our apps are open source and available on GitHub: https://github.com/bluzDK

You can use those as an example. As for code on bluz, it shouldn’t block much if you are in manual mode. User code can block the cloud connection, but the BLE connections are managed through interrupts, so your code shouldn’t really get in the way.