Device(nRF52840 with 17.0.2 SDK) is disconnected with reason 0x16(BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION) after paired in HID mode which is using Numeric comparison

Hi,

Our device is built with nRF52840 and SDK 17.0.2 and support Numeric Comparison pairing in HID mode.

Our device is trying to connect to Android device which has bluetooth version 4.2.

Pairing with the Android device is completed, but our device is disconnected from Android device about 30 seconds.

The disconnected reason is 0x16(BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION).

Android device connection parameter is as below.

- min_connection_interval : 0x27

- max_connection_interval: 0x39

- slave_latency: 0

- connection supervision timeout: 500

Would you please advise how to resolve this issue?

I changed MTU size to 23 from 257, but the problem is not resolved.

Parents
  • Hi,

    Do you see the disconnect reason 0x16 (BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION) on the nRF side or the Android side? If it is seen on the nRF side, this indicate that sd_ble_gap_disconnect() has been called for some reason. Can you check if that is the case, most likely while handling a GATT timeout as this happens after about 30 seconds? If this is the case, then the next step is to understand which operation timed out and why.

    If not, it would be interesting to see a sniffer trace to understand more about what is happening.

Reply
  • Hi,

    Do you see the disconnect reason 0x16 (BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION) on the nRF side or the Android side? If it is seen on the nRF side, this indicate that sd_ble_gap_disconnect() has been called for some reason. Can you check if that is the case, most likely while handling a GATT timeout as this happens after about 30 seconds? If this is the case, then the next step is to understand which operation timed out and why.

    If not, it would be interesting to see a sniffer trace to understand more about what is happening.

Children
  • Hi,

    I see the 0x16 disconnect reason on the nRF side.

    I have following codes and do you mean these timeout?

    case BLE_GATTC_EVT_TIMEOUT:
    // Disconnect on GATT Client timeout event.
    KDC_LOG_INFO("BLE_GATTC_EVT_TIMEOUT");
    err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
    BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
    break;

    case BLE_GATTS_EVT_TIMEOUT:
    // Disconnect on GATT Server timeout event.
    KDC_LOG_INFO("BLE_GATTS_EVT_TIMEOUT");
    err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
    BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
    break;

    Best regards,

    Ben

  • Hi Ben,

    Yes, that is what I was thinking about. Do you get any of these two events and disconnect based on that. If so, which? And from there, go back and look at exactly which operation timed out (here a sniffer trace could be an alternative way to see it)

  • Hi Einar,

    Unfortunately I don't have Android device in my hand so I can't test it.

    I just got informed from my customer and I am doing blind debugging right now.

    What kind of side effect can be happened if I commented out sd_ble_gap_disconnect() in these two cases?

    My current only choice is to send and ask a testing a new firmware with commented it.

     

  • Hi,

    Does your device have a GATT server or client or both? Most peripheral devices are client, so for now I assume that. If so, BLE_GATTS_EVT_TIMEOUT is probably the most relevant. The SDK examples generally disconnect on BLE_GATTS_EVT_TIMEOUT, as this is typically the safe approach as it then does not require handling of a GATT timeout specifically. If not, you may want to handle the timeout specifically depending on which operation timed out.

    You are free to not disconnect, but I cannot tell how that will affect your product. I recommend that you find a way to reproduce so that you can debug and understand what is happening when users see this issue in the field.

Related