Merge pull request #13084 from haukepetersen/opt_nimble_netifl2capabort
pkg/nimble_netif: catch L2CAP connection failures
This commit is contained in:
commit
001a216e9e
@ -333,6 +333,12 @@ static int _on_l2cap_client_evt(struct ble_l2cap_event *event, void *arg)
|
|||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case BLE_L2CAP_EVENT_COC_CONNECTED:
|
case BLE_L2CAP_EVENT_COC_CONNECTED:
|
||||||
|
if (event->connect.status != 0) {
|
||||||
|
/* in the unlikely event the L2CAP connection establishment
|
||||||
|
* fails, we close the GAP connection */
|
||||||
|
ble_gap_terminate(conn->gaphandle, BLE_ERR_REM_USER_CONN_TERM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
conn->coc = event->connect.chan;
|
conn->coc = event->connect.chan;
|
||||||
conn->state |= NIMBLE_NETIF_L2CAP_CLIENT;
|
conn->state |= NIMBLE_NETIF_L2CAP_CLIENT;
|
||||||
conn->state &= ~NIMBLE_NETIF_CONNECTING;
|
conn->state &= ~NIMBLE_NETIF_CONNECTING;
|
||||||
@ -370,6 +376,13 @@ static int _on_l2cap_server_evt(struct ble_l2cap_event *event, void *arg)
|
|||||||
handle = nimble_netif_conn_get_by_gaphandle(event->connect.conn_handle);
|
handle = nimble_netif_conn_get_by_gaphandle(event->connect.conn_handle);
|
||||||
conn = nimble_netif_conn_get(handle);
|
conn = nimble_netif_conn_get(handle);
|
||||||
assert(conn);
|
assert(conn);
|
||||||
|
|
||||||
|
if (event->connect.status != 0) {
|
||||||
|
/* in the unlikely event the L2CAP connection establishment
|
||||||
|
* fails, we close the GAP connection */
|
||||||
|
ble_gap_terminate(conn->gaphandle, BLE_ERR_REM_USER_CONN_TERM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
conn->coc = event->connect.chan;
|
conn->coc = event->connect.chan;
|
||||||
conn->state |= NIMBLE_NETIF_L2CAP_SERVER;
|
conn->state |= NIMBLE_NETIF_L2CAP_SERVER;
|
||||||
conn->state &= ~(NIMBLE_NETIF_ADV | NIMBLE_NETIF_CONNECTING);
|
conn->state &= ~(NIMBLE_NETIF_ADV | NIMBLE_NETIF_CONNECTING);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user