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

Is ble_hrs_heart_rate_measurement_send safe to call in interrupt?

developer.nordicsemi.com/.../a00969.html

I'm trying to understand whether this can be called in a timer interrupt (app_timer) and how frequently. I seem to have a bug where after the first 60 or so samples, not every sample is being sent up to the nRF Toolbox iOS app.

Test setup

Foreground

Push an incrementing counter to a queue every 100ms via a repeating timer interrupt.

Background (main loop)

If there is a sample in the queue, remove that sample and send it with ble_hrs_heart_rate_measurement_send

I just clocked on an oscilloscope that it takes ~77us from the moment the counter is incremented to the moment the code enters ble_hrs_heart_rate_measurement_send so I'm definitely consuming the data from the queue much faster than it is being generated.

Observed result

On nordic's HRM iOS app, after about 50 or so samples, everything that follows is a sequence of ~5 of the same number e.g. 4 5 6 7 8 9 ... 55 55 55 55 55 65 65 65 65 65 ...

Am I calling the send function too frequently?

Parents
  • Hi

    What I am suspecting is that the connection interval is changed. When you connect with the iphone and start to receive data from the device, connection interval is decided by IOS, which is typically ~30ms. When 5 seconds have passed, ble_app_hrs will send connecion_parameter_update_request to the central (the phone) which will change the connection interval to 500-1000 ms. Try to change the connection interval requested by the device and see what happens then.

    More info on connection parameters here and here.

    Alternatively, you could use e.g. Lightblue app to see monitor the data received on IOS

    Update 9.1.2014 When a sd_* softdevice function is called (e.g. sd_ble_gatts_hvx), then the data is stored in a softdevice buffer and there it is stored until it is sent over the air on a following BLE connection event, so the call is non-blocking. More on data transmission is here.

  • That was exactly the issue. This doesn't answer the question originally posted, which is whether it's safe to send a message from an interrupt. Does the send function just copy data to a buffer and set a flag or does blocking transmission happen there?

Reply Children
No Data
Related