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

BLE Disconnect Detect

Hi all, I am not very proficient in NORDIC and BLE. I was wondering if you could answer me. I am developing a module using NRF52. I have a redundant wireless communication channel: (1) a BLE connection (2) an RF link. This redundancy is just for sake of reliability where the primary channel is BLE. My device acts as a HID device for disabled patients for their cellphone. I need to switch to RF channel when BLE has a problem for any reason. I developed using NORDIC SDK and arm gcc.

Here is my question:

Is there any way that I can figure out there any way that a disconnection in BLE link detected? Idk if this affects your answer or not: the main assumption is that, we don't want to develop a driver on the cellphone side and we just want to use the HID driver.

Thanks in advance,

  • Hi,

    The answer is yes, you will get a disconnection event on both sides after some time.

    When two peers fail to communicate over Bluetooth, either due to poor signal quality, noise or other issues, they will retry until the Supervision Timeout is reached. The Supervision Timeout value is set by the central device upon connection, and is specified in a multiple of 10 milliseconds. Whenever the time since the last successful communication exceeds the timeout value, the link is considered lost and a disconnection event is triggered.

    So what you want is to make sure that the supervision timeout is quite low, in order to quickly detect issues. There are some rules from the Bluetooth spec on how low it can be, which depends on the other connection parameters, and the maximum on Nordic SoftDevices, it is 32000 milliseconds.

    I also recommend reading this answer for more information about connection parameters and what guidelines that phones are adhering to:

    devzone.nordicsemi.com/.../

  • Is there any interrupt of event to handle this disconnection. Would you provide some guides for the code?

    Thanks!

  • I suggest that you read up on the getting started guides for BLE in the Infocenter. You probably want to start with the SoftDevice Specification and nRF5x Getting Started guide. The disconnection event will manifest as a SoftDevice event of type BLE_GAP_EVT_DISCONNECTED, and depending on your setup it might trigger a Software Interrupt (SWI). There are some examples in the SDK that can get you started. Normally, the main code will pull events and optionally call a xxx_on_ble_evt() function for each module. The heart rate and NUS examples are easy to start with.

Related