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

nRF Connect for android disconnects with Error 22: 'gatt conn terminate local host'

Hi,

I'm testing stability of my firmware. As a part of tests I'm trying to maintain long term (multiple days) connection between nRF52 and nRF Connect for Android app running on Xiaomi Mi 2 (BLE5.0 capable hardware with Android 8.0). Every 24h or so I'm getting Error 22 code and nRF Connect disconnects. From nRF52 side everything looks ok, no asserts or error codes. Softdevice events look as Android phone has gracefully shut down the connection. What might be an issue? How could I approach debugging this further?

Parents
  • For anyone who ends up in this thread because of the nRF Connect "ERROR 22" issue, I just spent 2 h trying to figure out the reson in my case.

    So, just to recap the details of the issue:

    • my device (NRF52832QFAAE0) is a BLE peripheral serving as GATT Server, using SoftDevice s132 v7.0.1, SDK16.0.0.
    • NRF_SDH_BLE_CENTRAL_LINK_COUNT       = 0
    • NRF_SDH_BLE_PERIPHERAL_LINK_COUNT = 1
    • my device was not showing any known or unknown or assertion fail
    • my device was correctly advertising and accepting connection (without bonding)
    • after 30 seconds from each connection, my smartphone (OnePlus 5T, android 9) is dropping the connection with error 22 (0x16)
    • I was using nRF Connect version 4.24.1

    The 30 second timeout of my phone lead me to think that my device was probably not replying to a GATT query from my phone.
    After dumping all the BLE events, I noticed that I was receiving a HVX event of type INDICATION.

    At first I solved it with a simple call to:

    sd_ble_gattc_hv_confirm(p_ble_evt->evt.gap_evt.conn_handle, p_ble_evt->evt.gattc_evt.params.hvx.handle);

    A second inspection brought me to find out that my NRF app was configured with an example of GATT service and apparently was sending indication to my device. Disabling it solved my issue.

    Please, nRF Team, look into this, and maybe put a warning in the app if the server example is enabled by default.
    Still, I'm nos sure how is it possible to receive Indications if i'm not enabling any client feature in my device.


Reply
  • For anyone who ends up in this thread because of the nRF Connect "ERROR 22" issue, I just spent 2 h trying to figure out the reson in my case.

    So, just to recap the details of the issue:

    • my device (NRF52832QFAAE0) is a BLE peripheral serving as GATT Server, using SoftDevice s132 v7.0.1, SDK16.0.0.
    • NRF_SDH_BLE_CENTRAL_LINK_COUNT       = 0
    • NRF_SDH_BLE_PERIPHERAL_LINK_COUNT = 1
    • my device was not showing any known or unknown or assertion fail
    • my device was correctly advertising and accepting connection (without bonding)
    • after 30 seconds from each connection, my smartphone (OnePlus 5T, android 9) is dropping the connection with error 22 (0x16)
    • I was using nRF Connect version 4.24.1

    The 30 second timeout of my phone lead me to think that my device was probably not replying to a GATT query from my phone.
    After dumping all the BLE events, I noticed that I was receiving a HVX event of type INDICATION.

    At first I solved it with a simple call to:

    sd_ble_gattc_hv_confirm(p_ble_evt->evt.gap_evt.conn_handle, p_ble_evt->evt.gattc_evt.params.hvx.handle);

    A second inspection brought me to find out that my NRF app was configured with an example of GATT service and apparently was sending indication to my device. Disabling it solved my issue.

    Please, nRF Team, look into this, and maybe put a warning in the app if the server example is enabled by default.
    Still, I'm nos sure how is it possible to receive Indications if i'm not enabling any client feature in my device.


Children
Related