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.