Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Continuous disconnects with error coodes 0x22 and 0x08 with FreeRTOS

Hi,

I have a custom board running NUS peripheral which uses the nRF52832 and a NUS central which is running on a nRF52 DK. I modified the ble_app_hrs_freertos example to use NUS. I'm using SDK 14.2.0.

When I get the DK to scan and connect to my peripheral, I continuously get disconnect event, after which the DK scans again and reconnects. This loop keeps going on. I have observed two error codes with the disconnect events:

-> Error code = 0x22 when the peripheral and central are next to each other.

-> Error code = 0x08 when the peripheral and central are within one meter distance.

I tried using nRF sniffer and didn't see any weird packets, only advertising, scan request and connection request packets. No LMP error packets or anything pointing to a disconnect being triggered from the central.

Few of my application's FreeRTOS tasks have a priority greater than the BLE task i.e. priority > 2. 

Can someone point me to what my cause this issue? Is this an issue related to task priorities?

Thanks,

Gowtham

  • You get a 0x08 for connection timeout, seems like some procedure timed out. If you have some read/write authorize set, then you need to handle the authorize BLE event else, the read/write procedure will timeout causing this error code. Or there is some other procedure that timed out, should be visible in the sniffer log. 

    Ox22 = BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT

    There are lot of discussion in the forum already discussing the reason for this error, for example in the below link

    https://devzone.nordicsemi.com/f/nordic-q-a/6249/ble_hci_status_code_lmp_response_timeout

  • Hi,

    I have handled BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST in ble_evt_handler. It is being handled the same way as the ble_app_uart example. I did look at other posts similar to this one, but I couldn't find much help regarding this issue. Main thing which sets my issue apart is that 

    -> I do not receive any errors when I use nRF Connect Android app. I only receive these errors when I use the nRF52 DK as a central.

    -> The error code changes with the distance.(Check my question for exact error codes)

    -> The code I'm using on the peripheral is based on FreeRTOS. The non-FreeRTOS version of this code does not have this issue.

    -> The sniffer log didn't point to any timeout packets. I don't have the logs now, will post it ASAP.

    Edit: Fixed some typos

  • Probably nRF sniffer does not track timeout and just displays the air packets as it reads. Since a procedure timeout happens exactly 30 seconds after the procedure is initiated, when no response, it should be possible to find out what procedure started 30 seconds before the disconnect happened. Check the disconnect timestamp on your sniffer log and check what procedure started about 30 seconds before this disconnect and check the responses from that procedure.

Related