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

Disconnect very quickly after connected,reason:0x3E

Hi Supporter:

Hardware:nRF52840 dongle

Software: basic example "ble_app_interactive", s140_nrf52_6.1.1_softdevice

There is a strange problem,I connect my machine with iphone nrf connect, connect is ok, discovery all normal, But when i use Dongle with the software "ble_app_interactive", It's quickly disconnect.Log:

<info> app: CENTRAL: Connecting...
<debug> app: Connection Request Failed, reason 8
Connected to address: 00 1D 48 2F 18 29
<info> app: CENTRAL: Connected, handle: 0.
<debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
<debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
<info> app: Connecting to target 29182F481D00
<info> app: CENTRAL: Disconnected, handle: 0, reason: 0x3E

I test my central dongle with other dongle which use example "usbd_ble_uart",It's connect ok;Log

<info> app: CENTRAL: Connecting...
<debug> app: Connection Request Failed, reason 8
Connected to address: F6 17 FA C0 12 F1
<info> app: CENTRAL: Connected, handle: 0.
<debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
<debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
<info> app: Connecting to target F112C0FA17F6
<debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 64 bytes.
<debug> nrf_ble_gatt: Updating ATT MTU to 64 bytes (desired: 247) on connection 0x0.
Current MTU: 64
<debug> nrf_ble_gatt: ATT MTU updated to 64 bytes on connection 0x0 (response).
MTU changed successfully
<debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
<debug> nrf_ble_gatt: max_rx_octets: 251
<debug> nrf_ble_gatt: max_tx_octets: 251
<debug> nrf_ble_gatt: max_rx_time: 2120
<debug> nrf_ble_gatt: max_tx_time: 2120
<info> app: Data length updated to 251 bytes.

But when i connect peripheral  dongle with this central dongle first, and then i connect my machin, It's connect ok. 

It's very strange.00-connect_fail.pcapng00-connect_success.pcapng

I use sniffer crab some bags. 

Attachment is my sniffer bags. 

Hope my description is clearly .

Thanks any help.

  • Some notice:The connect exchange data is locate the end of captue package.Lot's of advertisement in the front of package. 

  • Hi Jay, 

     

    <info> app: CENTRAL: Disconnected, handle: 0, reason: 0x3E

     Disconnected reason 0x3E means: BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED. 
    This matched with what I can observe in the sniffer trace. The central sent the connect request but there was no response from the peripheral. 

    There could be a few posibilities: 

    1. The slave didn't catch the connect request from the central. How often do you see the issue ? Have you even managed to connect the central to the peripheral ? Have you tried to connect using a phone to your peripheral ?  Please try to test with a normal BLE application in the SDK.
    2. The slave caught the connect request but couldn't send the response packet due to timing issue. Could you check the log on the peripheral ? If it's the case the log on the peripheral should also show that it's connected but then quickly disconnected. 

  • Hi Hung Bui,

    Good weekend, Thanks for your reply.

    For you question:

    1.How often do you see the issue-  every time.when i connect it first.

    2.Have you even managed to connect the central to the peripheral - My "nRF52840 dongle" connect to iphone is ok.But it's cannot connect to my MACHINE(It's linux host and maybe TI chip,not very sure).

    3.Have you tried to connect using a phone to your peripheral- Yes ,My iphone connect to my MACHINE is ok, Not any problem.I use the app NRF CONNECT.

    4.Please try to test with a normal BLE application in the SDK-- My application is used the example "ble_app_interactive" which is in the SDK.

    5.Could you check the log on the peripheral-- I can see the log in my MACHINE (Use the HCIDUMP tool in linux host).It's can dicovery my central device, and putout the correct mac address, But it's display disconnect very soon .I can send the log to you in monday.

    And i want to expain the attachment 

    00-connect_fail.pcapng : This packet is the process which connected fail. 

    00-connect_success.pcapng : When my nRF52840 Dongle have connected  a peripheral before, I can connect my MACHINE as second link success, This packet is the proccess which connect success as second link. 

    It's can connect success when it's as second link, This is why i feel so strange.  

    If the slave cannot catch the connect request, why is connect success as sencond link? I compare the "fail "and "success" packet, The connect request content different is "window offset", I  suspect this filed cause this problem,But the window offset and window size cannot set through soft device.

  • Hi Hung:

    My slave details:

    > HCI Event: LE Meta Event (0x3e) plen 19
    LE Connection Complete
    status 0x00 handle 1025, role slave
    bdaddr F5:CC:F0:5F:A0:DE (Random)
    < ACL data: handle 1025 flags 0x00 dlen 16
    L2CAP(d): cid 0x0005 len 12 [psm 0]
    Connect: de:a0:5f:f0:cc:f5
    > HCI Event: Number of Completed Packets (0x13) plen 5
    handle 1025 packets 1
    > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 1025 reason 0x3e
    Reason: Connection Failed to be Established
    < HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1
    2020/10/31 22:48:16 l2conn: 0x0401 already disconnected
    Disconnect: de:a0:5f:f0:cc:f5
    > HCI Event: Command Complete (0x0e) plen 4
    LE Set Advertise Enable (0x08|0x000a) ncmd 1
    status 0x00

  • Hi Jay, 
    Thanks for the info. There are some devices that don't support window offset = 0 . We have created a compatibility mode to avoid using window offset = 0. 
    Please have a look at the ble_gap_opt_compat_mode_1_t struct quoted here:

    /**@brief Compatibility mode 1 option.
     *
     * @details This can be used with @ref sd_ble_opt_set to enable and disable
     *          compatibility mode 1. Compatibility mode 1 is disabled by default.
     *
     * @note Compatibility mode 1 enables interoperability with devices that do not support a value of
     *       0 for the WinOffset parameter in the Link Layer CONNECT_IND packet. This applies to a
     *       limited set of legacy peripheral devices from another vendor. Enabling this compatibility
     *       mode will only have an effect if the local device will act as a central device and
     *       initiate a connection to a peripheral device. In that case it may lead to the connection
     *       creation taking up to one connection interval longer to complete for all connections.
     *
     *  @retval ::NRF_SUCCESS Set successfully.
     *  @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set.
     */
    typedef struct
    {
       uint8_t enable : 1;                           /**< Enable compatibility mode 1.*/
    } ble_gap_opt_compat_mode_1_t;

    This mode can be enabled by calling sd_ble_opt_set().

    I don't think there is an option to do this in the CLI interface, but you can add the call directly in the code of ble_app_interactive. 

Related