Peripheral missing disconnect on timeout

When communication fails on NRF connectivity dongle (In Python via pc_ble_driver) and Error code: NRF_ERROR_BUSY is received on attempts to write and one restarts python script, a timeout appears to occur in peripheral. the connection changes state (after delay) from BT_CONN_CONNECTED to BT_CONN_DISCONNECT_COMPLETE.

This does not trigger a callback and application thus does not know to call bt_conn_unref() thus advertising is not resumed.

System runs Zephyr on nRF Connect SDK 1.8.0 as peripheral only.

Parents Reply
  • The ref:

    static void connected(struct bt_conn *conn, uint8_t err)
    {
        struct bt_conn_info info;
    
        if (err) 
        {
            LOG_ERR("BLE Connection failed (err 0x%02x)", err);
            return;
        }
    
        default_conn_ble = bt_conn_ref(conn);
    
        bt_conn_get_info(conn, &info);
        LOG_INF("BLE Connected: Interval=%d, Datalen=%d", info.le.interval, info.le.data_len->tx_max_len);
    

    The connected() callback goes on to check some parameters and request changes in data length if appropriate.


    The unref:

    static void disconnected(struct bt_conn *conn, uint8_t reason)
    {
        LOG_WRN("BLE Disconnected (reason 0x%02x)", reason);
        if (auth_conn) 
        {
            bt_conn_unref(auth_conn);
            auth_conn = NULL;
        }
        
        if (default_conn_ble) 
        {
            bt_conn_unref(default_conn_ble);
            default_conn_ble = NULL;
            disable_reporting_over_ble(); // Once disconnected, disable reporting over BLE
        }
    }

Children
No Data
Related