This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it possible to run code when the device wakes to advertise ?

Hi,

I'd like to check the battery level in my BLE device, and I can set a timer to handle the checking, however this means that Timer 1 would need to powered up, and hence it would take more power

I thought perhaps I could attach a callback to run when the nRF51822 wakes to advertise, but there doesn't seem to be a way to attach a callback.

And the only examples I have seen, e.g. BLE thermometers, seem to use the timer and then update the advertising data in the timer callback

Is a timer the only way to do this, and does it incur much more power usage ?

Parents
  • There are a few things to note here. Firstly, you can get a event whenever the radio is active, using Radio notification. Secondly, you do not need to use a TIMER in order to perform a task at a regular interval. The low power RTC is perfect for this purpose, and the additional current consumption is neglectable, as it uses the low frequency clock, which is anyway running when you have the SoftDevice enabled (needed for BLE). The Application timer library, which uses the RTC, is probably worth looking at.

  • I am glad to hear. If you are happy with the answer, could you please accept it? You can do that by clicking the circle checkmark to the left of it.

Reply Children
No Data