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

GATT_CONN_TERMINATE_LOCAL_HOST after 28-30s

Good morning,

I have designed a prototype based on nRF52840 and an application based on S140 v.6.1.0.

We have already assembled several prototypes and all of them have been working fine for weeks: we have created our own Android app and we have tested it with several Smartphones.

One of this equipments is the one I'm using for development, together with a defined Smartphone.

Up to yesterday, everythink was working fine but now, when I'm connecting the Smartphone with my development prototype, it perfectly connects but it always disconnects after 28-30seconds.

I have also tested with nRF Connect app: the same happens and in log register the message GATT_CONN_TERMINATE_LOCAL_HOST appears after 28-30s.

From this point, I have done some testing:

- With my Smartphone:

- I have tried to connect to a different prototype and it is connecting fine without any disconnection

- I have forgotten my prototype in order to enter passkey again --> This has not solved the problem with my prototype

- I have switched off and on back again bluetooth --> Same problem

- I have erased bluetooth cache in my smartphone --> Same problem

- With my prototype (nRF52840 based):

-I have tested same prototype with another Smartphone, and it is perfectly working.

- I have fully erased it with JFlash and I have flashed it again (bootloader, sd, boot_setting,app). Even, I have done this with different versions that were previously working without problems.

My smartphone is a Xiaomi Mi6, and I have been using it during my development stage.

Do you know which can be the reason of such behaviour?

Best regards,

Dani

Parents
  • Hi Dani, 

    Could you provide the debug log with the disconnect reason?

    In ble_evt_handler, you could do something like this:

            case BLE_GAP_EVT_DISCONNECTED:
            
                NRF_LOG_INFO("Disconnected reason: %d.",p_ble_evt->evt.gap_evt.params.disconnected.reason);

    sniffer trace could be helpful(see this page).

    -Amanda H.

  • Hi Amanda,

    I've sniffer already working, but what information do you need to be catched?

    As I'm using a 8-digit passkey, I have entered this passkey into Wireshark passkey field. This is right?

    I'm deeping a bit more into this application, but meanwhile, if you can detail the information that is useful for you, it will be great!!!

    All the best,

    Dani.

  • Hi Amanda,

    I have been playing with connection intervals definition, and in some scenarios it works.

    Could you recommend us best scenario, or the rules to follow?

    Now, I have set:

    MIN_CONN_INTERVAL to 10

    MAX_CONN_INTERVAL to 100

    In my application, if I sent application data once every 62.5ms, then the GATT_CONN_TERMINATE_LOCAL_HOST appears. What I do not understand (looking at nRF Connect app in my smartphone) is why notifications are received every 1 second (I send them every 62.5ms). Please, look at log1.txt file saved with nRF Connect.

    nRF Connect, 2020-11-25
    A-SMART 2 (F9:4F:3C:FA:8E:43)
    I	11:40:31.927	[Server] Server started
    V	11:40:31.936	Heart Rate (0x180D)
    - Heart Rate Measurement [N] (0x2A37)
       Client Characteristic Configuration (0x2902)
    - Body Sensor Location [R] (0x2A38)
    - Heart Rate Control Point [W] (0x2A39)
    Unknown Service (0000aaa0-0000-1000-8000-aabbccddeeff)
    - Unknown Characteristic [N R] (0000aaa1-0000-1000-8000-aabbccddeeff)
       Client Characteristic Configuration (0x2902)
       Unknown Descriptor (0000aab0-0000-1000-8000-aabbccddeeff)
       Characteristic User Description (0x2901)
       Characteristic Presentation Format (0x2904)
    - Unknown Characteristic [I W WNR] (0000aaa2-0000-1000-8000-aabbccddeeff)
       Client Characteristic Configuration (0x2902)
    User Data (0x181C)
    - First Name [R W] (0x2A8A)
    - Last Name [R W] (0x2A90)
    - Gender [R W] (0x2A8C)
    V	11:40:32.167	Connecting to F9:4F:3C:FA:8E:43...
    D	11:40:32.168	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	11:40:32.368	[Server callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	11:40:32.368	[Server] Device with address F9:4F:3C:FA:8E:43 connected
    D	11:40:32.374	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	11:40:32.374	Connected to F9:4F:3C:FA:8E:43
    D	11:40:32.401	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	11:40:32.407	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	11:40:32.408	[Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    I	11:40:32.447	[Server] MTU changed to 247
    I	11:40:33.212	PHY updated (TX: LE 2M, RX: LE 2M)
    I	11:40:33.213	[Server] PHY updated (TX: LE 2M, RX: LE 2M)
    I	11:40:33.662	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	11:40:34.153	[Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_PIN (0)
    I	11:40:34.202	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    I	11:40:34.652	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	11:40:38.366	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12)
    I	11:40:38.366	Device bonded
    D	11:40:38.369	wait(1600ms)
    I	11:40:39.144	Connection parameters updated (interval: 97.5ms, latency: 0, timeout: 4000ms)
    V	11:40:39.972	Discovering services...
    D	11:40:39.972	gatt.discoverServices()
    D	11:40:39.988	[Callback] Services discovered with status: 0
    I	11:40:39.988	Services discovered
    V	11:40:40.018	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    Unknown Service (00001000-0000-1000-8000-00805f9b34fb)
    - Unknown Characteristic [R W] (00001001-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [N R] (00001002-1212-efde-1523-785feabcd123)
       Client Characteristic Configuration (0x2902)
    Unknown Service (00002000-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [R W] (00002001-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [N R] (00002002-1212-efde-1523-785feabcd123)
       Client Characteristic Configuration (0x2902)
    Unknown Service (00003000-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [R W] (00003001-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [N R] (00003002-1212-efde-1523-785feabcd123)
       Client Characteristic Configuration (0x2902)
    Unknown Service (00004000-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [R W] (00004001-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [N R] (00004002-1212-efde-1523-785feabcd123)
       Client Characteristic Configuration (0x2902)
    Unknown Service (00005000-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [R W] (00005001-1212-efde-1523-785feabcd123)
    Unknown Service (00006000-1212-efde-1523-785feabcd123)
    - Unknown Characteristic [N R] (00006002-1212-efde-1523-785feabcd123)
       Client Characteristic Configuration (0x2902)
    Secure DFU Service (0xFE59)
    - Secure Buttonless DFU [I W] (8ec90004-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    D	11:40:40.018	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	11:40:40.021	gatt.setCharacteristicNotification(00001002-1212-efde-1523-785feabcd123, true)
    D	11:40:40.022	gatt.setCharacteristicNotification(00002002-1212-efde-1523-785feabcd123, true)
    D	11:40:40.023	gatt.setCharacteristicNotification(00003002-1212-efde-1523-785feabcd123, true)
    D	11:40:40.023	gatt.setCharacteristicNotification(00004002-1212-efde-1523-785feabcd123, true)
    D	11:40:40.026	gatt.setCharacteristicNotification(00006002-1212-efde-1523-785feabcd123, true)
    I	11:40:40.320	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-16-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:40.320	"(0x) 0F-01-00-00-00-14-0D-D3-16-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:41.420	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-17-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:41.420	"(0x) 0F-01-00-00-00-14-0D-D3-17-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:42.362	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-18-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:42.362	"(0x) 0F-01-00-00-00-14-0D-D3-18-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:43.333	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-19-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:43.333	"(0x) 0F-01-00-00-00-14-0D-D3-19-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:44.322	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-1A-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:44.322	"(0x) 0F-01-00-00-00-14-0D-D3-1A-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:45.389	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-1B-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:45.389	"(0x) 0F-01-00-00-00-14-0D-D3-1B-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:46.356	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-1C-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:46.356	"(0x) 0F-01-00-00-00-14-0D-D3-1C-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:47.429	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-1D-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:47.429	"(0x) 0F-01-00-00-00-14-0D-D3-1D-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:48.318	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-1E-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:48.318	"(0x) 0F-01-00-00-00-14-0D-D3-1E-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:49.383	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-1F-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:49.383	"(0x) 0F-01-00-00-00-14-0D-D3-1F-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:50.356	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-20-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:50.356	"(0x) 0F-01-00-00-00-0E-0D-D3-20-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:51.533	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-21-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:51.533	"(0x) 0F-01-00-00-00-0E-0D-D3-21-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:52.307	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-22-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:52.307	"(0x) 0F-01-00-00-00-0E-0D-D3-22-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:53.390	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-23-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:53.390	"(0x) 0F-01-00-00-00-0E-0D-D3-23-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:54.351	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-24-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:54.351	"(0x) 0F-01-00-00-00-0E-0D-D3-24-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:55.338	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-25-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:55.339	"(0x) 0F-01-00-00-00-0E-0D-D3-25-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:56.400	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-26-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:56.400	"(0x) 0F-01-00-00-00-0E-0D-D3-26-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:57.374	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-27-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:57.374	"(0x) 0F-01-00-00-00-0E-0D-D3-27-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:58.352	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-28-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:58.352	"(0x) 0F-01-00-00-00-0E-0D-D3-28-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:40:59.520	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-0E-0D-D3-29-00-00-01-01-00-05-00-00-00-00-00
    A	11:40:59.520	"(0x) 0F-01-00-00-00-0E-0D-D3-29-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:41:00.405	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-2A-00-00-01-01-00-05-00-00-00-00-00
    A	11:41:00.405	"(0x) 0F-01-00-00-00-14-0D-D3-2A-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:41:01.383	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-2B-00-00-01-01-00-05-00-00-00-00-00
    A	11:41:01.383	"(0x) 0F-01-00-00-00-14-0D-D3-2B-00-00-01-01-00-05-00-00-00-00-00" received
    I	11:41:02.346	Notification received from 00006002-1212-efde-1523-785feabcd123, value: (0x) 0F-01-00-00-00-14-0D-D3-2C-00-00-01-01-00-05-00-00-00-00-00
    A	11:41:02.346	"(0x) 0F-01-00-00-00-14-0D-D3-2C-00-00-01-01-00-05-00-00-00-00-00" received
    D	11:41:02.361	[Callback] Connection state changed with status: 22 and new state: DISCONNECTED (0)
    E	11:41:02.361	Error 22 (0x16): GATT CONN TERMINATE LOCAL HOST
    I	11:41:02.361	Disconnected
    D	11:41:02.361	[Server callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
    I	11:41:02.361	[Server] Device disconnected
    D	11:41:02.447	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    
    Do you have any explanation for this?

    Dani

  • Hi Amanda,

    I'm very interested in knowing what I have asked in my previous answers.

    But apart of this, and going deeper into this behaviour, I have solved this disconnections, but I do not know the reason. In fact, I have noticed that I receive the BLE_GATTC_EVT_HVX event. Then, according to (https://devzone.nordicsemi.com/f/nordic-q-a/30804/nrf-connect-for-android-disconnects-with-error-22-gatt-conn-terminate-local-host/149921#149921) I call 'sd_ble_gattc_hv_confirm' when this event is given and know device works without disconnections.

    Dani

  • Hi Dani, 

    Good to hear you fix the issue. 

    Dani said:
    Could you recommend us best scenario, or the rules to follow?

    Check if this helps you devzone.nordicsemi.com/.../ and this note

    Dani said:
    What I do not understand (looking at nRF Connect app in my smartphone) is why notifications are received every 1 second (I send them every 62.5ms).

    The central decides the connection interval and it may not accept the intervals proposed by the peripheral.

    -Amanda H.

  • Thank you very much...

    Now, when writting a wrong passkey, my device is reseted.

    Which can be the reason? I have already implemented event PM_EVT_CONN_SEC_FAILED:

    static void pm_evt_handler(pm_evt_t const * p_evt)
    {
    ret_code_t err_code;

    pm_conn_sec_config_t config;
    pm_conn_sec_status_t conn_sec_status;

    pm_handler_on_pm_evt(p_evt);
    pm_handler_disconnect_on_sec_failure(p_evt);
    pm_handler_flash_clean(p_evt);

    switch (p_evt->evt_id)
    {

    case PM_EVT_CONN_SEC_SUCCEEDED:

    // Check if the link is authenticated (meaning at least MITM).
    err_code = pm_conn_sec_status_get(p_evt->conn_handle, &conn_sec_status);
    APP_ERROR_CHECK(err_code);

    break;

    case PM_EVT_CONN_SEC_FAILED:
    m_ble_general.ble_conn_handle = BLE_CONN_HANDLE_INVALID;
    break;

    case PM_EVT_PEERS_DELETE_SUCCEEDED:
    advertising_start();
    break;

    case PM_EVT_CONN_SEC_CONFIG_REQ:
    config.allow_repairing = true;
    pm_conn_sec_config_reply(p_evt->conn_handle, &config);
    break;

    case PM_EVT_BONDED_PEER_CONNECTED:
    pm_local_database_has_changed();

    break;

    default:
    break;
    }
    }

    Please, find attached sniffer trace for this moment.

    What do I have to correct to avoid these resets?

    Dani.

    Android_pairing_with_wrong_key.pcapng

  • Hi Dani, 

    This is a different issue from the origianl. Please create a new support case with the debug log.

    -Amanda H. 

Reply Children
No Data
Related