BT connection timeouts with PAWR enabled

sdk-nrf: v2.7.0

When PAWR is enabled I no longer get connection timeouts as a callback to bt_conn_cb.connected with the conn_err parameter set when attempting to open a connection as a central.

Instead I get an error log from inside bt_hci_core.


Code to start connection
```
struct bt_conn_le_create_param con_params = BT_CONN_LE_CREATE_PARAM_INIT(BT_CONN_LE_OPT_NONE, BT_GAP_SCAN_FAST_INTERVAL, BT_GAP_SCAN_FAST_INTERVAL);
con_params.timeout = 500;

err = bt_conn_le_create(&target_address, &con_params, BT_LE_CONN_PARAM_DEFAULT, &conn);
```

Logs I get

```

00> rtt:~$ [0:0:5.943,420] <dbg> EDGE_HEARTBEAT_PERIPHERAL: connect_to_peripheral: attempted connection start

00> rtt:~$ rtt:~$ [0:0:10.943,298] <err> bt_hci_core: Invalid connection complete event

```

I have validated this is from PAWR by disabling it and confirming I do get the expected callback.

Flags enabled when we use PAWR

select BT_OBSERVER

select BT_EXT_ADV
select BT_CTLR_ADV_EXT

select BT_PER_ADV_SYNC
select BT_PER_ADV_SYNC_RSP
select BT_PER_ADV_SYNC_TRANSFER_SENDER
select BT_PER_ADV_SYNC_TRANSFER_RECEIVER

select BT_CTLR_SYNC_PERIODIC
select BT_CTLR_SYNC_PERIODIC_RSP

Parents
  • Sorry if I am using the wrong terminology.

    The central device (the one running the code I posted) is the one subscribing to the PAWR advertiser and sending responses back to it

  • Could you please try this workaround?

    Adding this line in hci_core.c after LOG_ERR("Invalid connection complete event");

    enh_conn_complete((struct bt_hci_evt_le_enh_conn_complete *)evt);

    The function le_enh_conn_complete_v2 should then look like this:

    static void le_enh_conn_complete_v2(struct net_buf *buf)
    {
     struct bt_hci_evt_le_enh_conn_complete_v2 *evt =
      (struct bt_hci_evt_le_enh_conn_complete_v2 *)buf->data;
    
     if (evt->adv_handle == BT_HCI_ADV_HANDLE_INVALID &&
         evt->sync_handle == BT_HCI_SYNC_HANDLE_INVALID) {
      /* The connection was not created via PAwR, handle the event like v1 */
      enh_conn_complete((struct bt_hci_evt_le_enh_conn_complete *)evt);
     }
    #if defined(CONFIG_BT_PER_ADV_RSP)
     else if (evt->adv_handle != BT_HCI_ADV_HANDLE_INVALID &&
       evt->sync_handle == BT_HCI_SYNC_HANDLE_INVALID) {
      /* The connection was created via PAwR advertiser, it can be handled like v1 */
      enh_conn_complete((struct bt_hci_evt_le_enh_conn_complete *)evt);
     }
    #endif /* CONFIG_BT_PER_ADV_RSP */
    #if defined(CONFIG_BT_PER_ADV_SYNC_RSP)
     else if (evt->adv_handle == BT_HCI_ADV_HANDLE_INVALID &&
       evt->sync_handle != BT_HCI_SYNC_HANDLE_INVALID) {
      /* Created via PAwR sync, no adv set terminated event, needs separate handling */
      struct bt_le_per_adv_sync *sync;
    
      sync = bt_hci_get_per_adv_sync(evt->sync_handle);
      if (!sync) {
       LOG_ERR("Unknown sync handle %d", evt->sync_handle);
    
       return;
      }
    
      bt_hci_le_enh_conn_complete_sync(evt, sync);
     }
    #endif /* CONFIG_BT_PER_ADV_SYNC_RSP */
     else {
      LOG_ERR("Invalid connection complete event");
      enh_conn_complete((struct bt_hci_evt_le_enh_conn_complete *)evt);
     }
    }

  • That seems to work i now get a callback to my connection handler on timeout. Once the device it was trying to connect to became available it succeeded the next time bt_conn_le_create was called

Reply Children
No Data
Related