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

connect timeout

Hi,All,

I am using nrf52832 as a slave, the SDK version is 12.3. I set the connection timeout to 10s as follows

#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(1000, UNIT_10_MS) 


I think that CONN_SUP_TIMEOUT is no data sent after 10s connection,  then enter the connection timeout event BLE_GAP_EVT_TIMEOUT, then the slave actively disconnected, but the problem is that the slave  can not enter the BLE_GAP_EVT_TIMEOUT event processing after connection timeout, and power consumption is 30μA, but The power consumption is 2μA after the host actively disconnects.
problem:
1,if the understand of connection timeout is correct
2. Is the connection timeout event BLE_GAP_EVT_TIMEOUT?
3,how reduce power consumption after the connection timeout

Best Regards

Amy

  • Hi,

    If your BLE peripheral is in a connection with a central, and the central stops responding for so long that the supervision timeout triggers, you will get the event BLE_GAP_EVT_DISCONNECTED with reason BLE_HCI_CONNECTION_TIMEOUT (0x08). You will not get the event BLE_GAP_EVT_TIMEOUT.

    If you are using the advertising module in the SDK, ble_advertising.c, the default behavior is to start advertising again after a disconnect. This happens in the function on_disconnected(). If you start advertising again, this will typically consume 30µA+ (depending on advertising interval)

  • Thanks

    My BLE peripheral is in a connection with a central.  In order to keep the connection, Bluetooth will send empty data packets to keep connection when there is no valid data interaction. If there is always an empty data packet interaction, will Bluetooth have a connection timeout?

    BLE_HCI_CONNECTION_TIMEOUT is a error code,not  event ,how can i use it?

  • Hi,

    If there is always an empty data packet interaction, will Bluetooth have a connection timeout?

    No, in that case you will not timeout. 

    BLE_HCI_CONNECTION_TIMEOUT is a error code,not  event ,how can i use it?

    In the event structure for BLE_GAP_EVT_DISCONNECTED, you will find the reason for the disconnect. See this page. If the disconnect happend because of a connection timeout, the disconnct reason will be BLE_HCI_CONNECTION_TIMEOUT.

    Snippet:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t err_code;
        uint8_t disconnect_reason;
    
        switch (p_ble_evt->header.evt_id)
        {
    
            case BLE_GAP_EVT_DISCONNECTED:
                disconnect_reason = p_ble_evt->evt.gap_evt.params.disconnected.reason;
                if(disconnect_reason  == BLE_HCI_CONNECTION_TIMEOUT)
                {
                    //disconnect_reason is BLE_HCI_CONNECTION_TIMEOUT
                }
                err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break; // BLE_GAP_EVT_DISCONNECTED

  • Hi,Sigurd

    Thanks for your answer, I think I can solve my problem now

    Best Regards

Related