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

Bluetooth: Master initiates the data transmission in Slave Notify mode. Multiple transmissions in single connection event

I am trying to understand better the Bluetooth communication based on some data logs.

Master connection params:

int_min: 1000ms
int_max: 1005ms
lat: 0
timeout: 4000ms

Slave is calling function bt_gatt_notify every 20ms with new values provided. Master is subscribed to the notifications.

Here is the view from Wireshark in particular moment:

Wireshark.log

What I find strange:

  1. Whenever the slave should transmit the new data, its actually Master who is sending the request first, then the slave responds.
  2. No ACKs from the master after that
  3. In single connection event there are 3 new values that are being sent to Master(you can understand by looking the log times). After 3 are sent, the Master is waiting for the beginning of the next connection interval.

I was expecting that there will be asynchronous data transmission initiated by the Slave as soon as the data is updated. Also what I found strange is that for some reason in one connection event there are 3 new values. How can we clarify this?

Best,

  • I was expecting that there will be asynchronous data transmission initiated by the Slave as soon as the data is updated.

    Wrong expectation. All communication is done via connection events that take place every connection interval. Notifications and indications are queued, ether in the application (nrf_ble_gq) or in the softdevice itself.

    The amount of data exchanged during a connection intervall changes with softdevice config - default config can queue up to 6 or 7 notifications IIRC. The central may not be able to take that much data, though.

    If you call bt_gatt_notify every 20ms you should have gotten some of those NRF_ERROR_RESOURCES return codes (if your conn params are correct).

  • I would like to add that your conn parameters are strange - you're trying to send a notification every 20ms knowing that an exchange will occur not frequently than once a second - so 47 messages of 50 are lost. If you would like to save power, configure 20-ms conn interval and set slave latency to 50 (to skip events while no data is ready).

  • Hey, thanks for clarifications! I checked, I do not get any errors, the 3 values are queued even when I put the smaller delay between notifications. I also checked, no notifications has been lost, they are all in right sequence. Parameters are alright, since its easy to check based on the log that every connection event takes 1s. Also, after some time the peripheral is requesting the update of the connection parameters to default one, I found that interesting since I am not specifying it in my code.

  • It was just for the sake of experimenting and trying to understand better how low level stack handles such events. I checked-no data is being lost, its just that the slave is not able to send the notifications, but once it is, the data is arriving in right order. Slave also doesnt throw any errors.

  • Hi

    Which example are you using as a starting point?

    Technically it is up to the application to request a change of connection parameters. In the nRF5 SDK we had a support module to handle this for you, so you just needed to define the desired connection parameters in the main file, but I need to check how this is handled in Zephyr. 

    Best regards
    Torbjørn

Related