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

Connection alive by empty data pdu instead of notifications

Hi,

Central nrf52840

peripheral nrf52840

adv. interval: 25ms

adv. timeout 180 seconds

connection interval (both min and max) 10ms

scan interval 50 ms

scan windows 25ms

scan timeout 0

connection supervision timeout 4s

My question is, when the central or the peripheral device is disconnected(powered off and on again), I want the notifications to continue by advertising and scanning etc. This should ideally happen even when the peripheral device or central goes in and out of range. I noticed that when the central device is powered off, the peripheral starts advertising and when it is on, it connects with the central device and "Notifications" are received. However, in some cases, they just connect and send and receive only EMPTY DATA PDU although there is data at the transmitter it's just not being transmitted in the form of notification. Why does this happen and how to prevent this situation? One more evidence to this case is that, when they just communicate using empty data PDU, error_code 3401 is logged at this line err_code = sd_ble_gatts_hvx(p_semg->conn_handle, &hvx_params); (peripheral)

Thanks, Nivetha

Parents
  • Hi Nivetha,

    It's not very clear what you meant by " I want the notifications to continue by advertising and scanning etc."

    I assume your question is , why in some cases the connection was re-established and the notification started automatically when in some other cases there were no notification, just empty packets.

    We need to look into how the notification be sent. You can only send notification when the CCCD (Client Characteristic Configuration Descriptor) is enabled by writing 1 to the CCCD characteristic. If there was nothing written or initialized in CCCD when you call hvx command, you will receive BLE_ERROR_GATTS_SYS_ATTR_MISSING (0x3401). This is described in the documentation of the sd_ble_gatts_hvx command.

    If your 2 devices are bonded, the CCCD should be enabled automatically when they re-connect. But it's up to the application code (or the peer manager if you use peer manager)

    Or, the central should set the CCCD right away after the connection re-established. This should be implemented in the central code.

  • Then bonding is required. If not peer manager won't be able to re-establish CCCD. I would suggest you to capture a sniffer trace.

Reply Children
No Data
Related