Puck.js will then go to sleep (apart from advertising), but every 30 seconds it'll wake up and change the advertising. You can lengthen the interval, but at some point there are diminishing returns for the power usage.
For NRF.setServices, a similar thing applies - except you don't want to redefine the services each time so you need to use NRF.updateServices:
You should get battery data this way, but only when you connect and view the characteristic. In the advertising data that is sent out without a connection you will see just the 180F service.
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! Your issue is that the advertising data is set at the time you make the call. It isn't continually updated.
To update it, all you need to do is make the call repeatedly, so use some code like this:
Puck.js will then go to sleep (apart from advertising), but every 30 seconds it'll wake up and change the advertising. You can lengthen the interval, but at some point there are diminishing returns for the power usage.
For
NRF.setServices
, a similar thing applies - except you don't want to redefine the services each time so you need to useNRF.updateServices
:You should get battery data this way, but only when you connect and view the characteristic. In the advertising data that is sent out without a connection you will see just the 180F service.