I reckon you can use NRF.sleep() and NRF.wake() to stop advertisements. However that will make the device unconnectable when it's not advertising.
Also you really want to let it send quite a few advertisements (so leave make 2 seconds between wake and sleep). It's radio so there's absolutely no guarantee that a single message will get through to the Pi.
I wouldn't be too worried about the battery usage of advertising though - it's not that huge. You can always reduce the advertising interval to once a second or so, which will really reduce the battery usage without you having to do anything painful with wake and sleep.
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.
Hi, Thanks!
I reckon you can use
NRF.sleep()
andNRF.wake()
to stop advertisements. However that will make the device unconnectable when it's not advertising.Also you really want to let it send quite a few advertisements (so leave make 2 seconds between
wake
andsleep
). It's radio so there's absolutely no guarantee that a single message will get through to the Pi.I wouldn't be too worried about the battery usage of advertising though - it's not that huge. You can always reduce the advertising interval to once a second or so, which will really reduce the battery usage without you having to do anything painful with
wake
andsleep
.