Using non-blocking APIs for advertisement packet updates

I am trying to understand how to use the non blocking APIs to ensure that the advertisement packet contains the latest data from my sensors. In blocking mode, it is a bit easier to understand since the procedure is :

wake-up -> measure adc -> update i2c sensor data -> update advertisement packet -> advertise -> sleep

When written in a blocking fashion, this is straightforward procedural but not optimal.

Since there are non-blocking APIs for ADC, I2C, using them will mean the application will need to be architect-ed slightly differently. Can you advice on how to write such apps? How can I ensure that when this is done, every advertisement packet contains new data and not a combination of old+new, given that the interval between advertisements is large enough for all measurements to complete.

Parents
No Data
Reply
  • Hi,

    Can you advice on how to write such apps? How can I ensure that when this is done, every advertisement packet contains new data and not a combination of old+new

    Use e.g. ble_advertising_advdata_update() and with two buffers.

    When already using buffer1 for advertising:
    Put new I2C sensor data in buffer2, then update advertisement packet to use buffer2 instead.

    When already using buffer2 for advertising:
    Put new I2C sensor data in buffer1, then update advertisement packet to use buffer1 instead.

Children
No Data
Related