I am in the process of writing an app which communicates with EspruinoHub via bluetooth.
I am using the advertising method.
The app is intended to control a smart tv, by sending mqtt commands in node-red. I have a basic button press example working, now I'm reviewing its effectiveness.
I noticed that the bangle doesn't advertise unless "Make Connectable" is pressed in settings. I looked at settings app in BangleApps and see it called NRF.wake(). My question is : should my 'app' be calling NRF.wake() at start? Because if disable bluetooth : off, then bluetooth: on is not enough for it to restore functionality(it doesnt' start advertising on bluetooth: on settings). Is that intended?
I'm not sure, but I would think that 'Make Connectable' should be re-fired if bluetooth is turned on and off?
Another question: the nature of advertising is non stop broadcast at certain intervals yes? Since i'm only trying to send 1 signal(a button press), how should I design it? Is it bad for power to keep advertising whilst app is open, is it better if I like get some confirmation back that it received signal then cancel the advertising by setting data to {} or better yet calling NRF.sleep() after verified it target smartDevice got the message?
Edit: Decided to use setTimeout for setAdvertising, but still have some uncertainties regarding restoring advertising defaults.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I am in the process of writing an app which communicates with EspruinoHub via bluetooth.
I am using the advertising method.
The app is intended to control a smart tv, by sending mqtt commands in node-red. I have a basic button press example working, now I'm reviewing its effectiveness.
I noticed that the bangle doesn't advertise unless "Make Connectable" is pressed in settings. I looked at settings app in BangleApps and see it called NRF.wake(). My question is : should my 'app' be calling NRF.wake() at start? Because if disable bluetooth : off, then bluetooth: on is not enough for it to restore functionality(it doesnt' start advertising on bluetooth: on settings). Is that intended?
I'm not sure, but I would think that 'Make Connectable' should be re-fired if bluetooth is turned on and off?
Another question: the nature of advertising is non stop broadcast at certain intervals yes? Since i'm only trying to send 1 signal(a button press), how should I design it? Is it bad for power to keep advertising whilst app is open, is it better if I like get some confirmation back that it received signal then cancel the advertising by setting data to {} or better yet calling NRF.sleep() after verified it target smartDevice got the message?
Edit: Decided to use setTimeout for setAdvertising, but still have some uncertainties regarding restoring advertising defaults.
Thanks in advance.!