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

BLE Disconnects with Samsung phones

Hi,

I am using nRF52840 and BLE coexistence (mesh and ble). I am able to connect to my board via BLE using nRFConnect for PC and a nRF52840-DK and change characteristics value, etc. I also implemented a static passkey and everything works fine with nRF Connect for PC and different phones (Googles, Blackview).

My problem is that it does not works with samsung phones such as Galaxy S7 or J5 : After 25s of connection it disconnects with the error "Error 8 (0x8): GATT CONN TIMEOUT" on the phone. If i try to read a characteristic, the passkey is requested and the phone disconnects right after sending the passkey with the same error.

Do you know from where this problem could come from ?

  • Hi,

    - Which SD and SDK have you built your application on?

    - Do you have an on-air sniffer log?

    - Can you also check the disconnect reason on the nRF52840? Should be passed with the BLE_GAP_EVT_DISCONNECT event in p_ble_evt->evt.gap_evt.params.disconnected.reason, I expect reason to be one of the Bluetooth status codes as listed in ble_hci.h.

    - You may try to comment out data_length_update(conn_handle, p_gatt); in on_connected_evt() in nrf_ble_gatt.c (or add a 100ms delay before calling it).

    Best regards,
    Kenneth

  • - My application is built on SDK 15.2.0, SDK For mesh V3.1.0, S140.

    - The disconnect reason i got is 0x22 : BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT

    - I tried to comment out data_length_update and it works fine with samsung phones but adding a 100ms delay before does not work. Should i keep it like that (with data_length_update commented) ?

    - I do not have an on-air sniffer log, is it possible to make one using a nrf52840-DK ?

  • Hi, i already have this case handling in ble_evt_handler in ble_softdevice_support.c :

    /**@brief Function for handling BLE events.
     *
     * @param[in]   p_ble_evt   Bluetooth stack event.
     * @param[in]   p_context   Unused.
     */
    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                __PrintLog(LOG_MESH_APP, LOG_LEVEL_INFO, "[BLE]-> Connected \n"); 
                _t_BLEConfigService.u16_ConnHandle = p_ble_evt->evt.gap_evt.conn_handle;
                vBLEDRV_QwrConnHandleAssign();
    
                if (ptFLASHDRV_GetAnchorInfo()->b_AnchorConfiguredByBLE)
                {
                    vCS_RestoreConfigIntoCharacteristics(&_t_BLEConfigService);
                }
                break;
    
            case BLE_GAP_EVT_DISCONNECTED:
                __PrintLog(LOG_MESH_APP, LOG_LEVEL_INFO, "[BLE]-> Disconnected \n"); 
                // LED indication will be changed when advertising starts.
                _t_BLEConfigService.u16_ConnHandle = BLE_CONN_HANDLE_INVALID;
                vSYSCONFIG_ConfigSetConfiguredByBLE(true);
                ERROR_CHECK(u32FLASHDRV_StoreAnchorConfig());
                ERROR_CHECK(u32FLASHDRV_StoreServerInfo());
                __PrintLog(LOG_MESH_APP, LOG_LEVEL_INFO, "[BLE]-> Config stored, reset... \n"); 
                mesh_stack_device_reset();
                break;
    
            case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
            {
                __PrintLog(LOG_MESH_APP, LOG_LEVEL_INFO, "[BLE]-> PHY UPDATE REQUEST \n"); 
                ble_gap_phys_t const phys =
                {
                    .rx_phys = BLE_GAP_PHY_AUTO,
                    .tx_phys = BLE_GAP_PHY_AUTO,
                };
                err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
            } break;
    
            case BLE_GATTC_EVT_TIMEOUT:
                // Disconnect on GATT Client timeout event.
                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.
                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;
    
            case BLE_GATTS_EVT_WRITE:
                vCS_WriteEventCallback(&_t_BLEConfigService, p_ble_evt);
                break;
    
            case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
            {
                __PrintLog(LOG_MESH_APP, LOG_LEVEL_INFO, "[BLE]-> BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST \n"); 
    
                // Accepting parameters requested by peer.
                err_code = sd_ble_gap_conn_param_update(p_ble_evt->evt.gap_evt.conn_handle,
                                                        &p_ble_evt->evt.gap_evt.params.conn_param_update_request.conn_params);
                APP_ERROR_CHECK(err_code);
            }   
                break;
            default:
                // No implementation needed.
                break;
        }
    }

    Am i supposed to copy it somewhere else ?

  • I think a sniffer log would have solved this pretty quickly, but while waiting for an updated release (eta a few days):

    - Can you print out all p_ble_evt->header.evt_id just to check if there is any new events happening upon connection which differ between working and non working?

    - Search google for 'BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT' and see if you can find any relevant tips to try.

Related