Introduce new BLE_GAP_EVENT_LINK_ESTAB event to ensure link is established

This commit is contained in:
Rahul Tank
2024-08-21 12:00:44 +05:30
parent 50c2641a04
commit 6e423e457b
2 changed files with 37 additions and 0 deletions
+20
View File
@@ -164,6 +164,7 @@ struct hci_conn_update;
#define BLE_GAP_EVENT_CONNLESS_IQ_REPORT 35
#define BLE_GAP_EVENT_CONN_IQ_REPORT 36
#define BLE_GAP_EVENT_CTE_REQ_FAILED 37
#define BLE_GAP_EVENT_LINK_ESTAB 38
/* DTM events */
#define BLE_GAP_DTM_TX_START_EVT 0
@@ -542,6 +543,25 @@ struct ble_gap_event {
uint16_t conn_handle;
} connect;
/**
* Represents a successful Link establishment attempt. Valid for the following event
* types:
* o BLE_GAP_EVENT_LINK_ESTAB
*/
struct {
/**
* The final status of the link establishment;
* o 0: the connection was successfully established.
* o BLE host error code: the connection attempt failed for
* the specified reason.
*/
int status;
/** The handle of the relevant connection. */
uint16_t conn_handle;
} link_estab;
/**
* Represents a terminated connection. Valid for the following event
* types:
+17
View File
@@ -1056,6 +1056,9 @@ ble_gap_master_connect_failure(int status)
event.connect.status = status;
rc = state.cb(&event, state.cb_arg);
event.type = BLE_GAP_EVENT_LINK_ESTAB;
rc = state.cb(&event, state.cb_arg);
} else {
rc = 0;
}
@@ -1082,6 +1085,9 @@ ble_gap_master_connect_cancelled(void)
event.connect.status = BLE_HS_ETIMEOUT;
}
state.cb(&event, state.cb_arg);
event.type = BLE_GAP_EVENT_LINK_ESTAB;
state.cb(&event, state.cb_arg);
}
}
@@ -2466,6 +2472,17 @@ ble_gap_rx_rd_rem_sup_feat_complete(const struct ble_hci_ev_le_subev_rd_rem_used
conn = ble_hs_conn_find(le16toh(ev->conn_handle));
if ((conn != NULL) && (ev->status == 0)) {
conn->supported_feat = get_le32(ev->features);
struct ble_gap_event event;
uint16_t conn_handle = le16toh(ev->conn_handle);
memset(&event, 0, sizeof event);
event.type = BLE_GAP_EVENT_LINK_ESTAB;
event.link_estab.status = ev->status;
event.link_estab.conn_handle = conn_handle;
ble_gap_event_listener_call(&event);
ble_gap_call_conn_event_cb(&event, conn_handle);
}
ble_hs_unlock();