fix(nimble): Deprecate BLE_GAP_LINK_ESTAB event

This commit is contained in:
Rahul Tank
2025-02-23 15:16:01 +05:30
parent 24d566d2f8
commit 8f7f3a4b57
3 changed files with 25 additions and 76 deletions
+8 -45
View File
@@ -158,12 +158,14 @@ struct hci_conn_update;
#define BLE_GAP_EVENT_REATTEMPT_COUNT 29
#define BLE_GAP_EVENT_TEST_UPDATE 30
#define BLE_GAP_EVENT_DATA_LEN_CHG 31
#define BLE_GAP_EVENT_LINK_ESTAB 32
#define BLE_GAP_EVENT_AUTHORIZE 33
#define BLE_GAP_EVENT_EATT 34
#define BLE_GAP_EVENT_PER_SUBEV_DATA_REQ 35
#define BLE_GAP_EVENT_PER_SUBEV_RESP 36
#define BLE_GAP_EVENT_PERIODIC_TRANSFER_V2 37
/* Deprecate EVENT_LINK_ESTAB */
#define BLE_GAP_EVENT_LINK_ESTAB BLE_GAP_EVENT_CONNECT
#define BLE_GAP_EVENT_AUTHORIZE 32
#define BLE_GAP_EVENT_EATT 33
#define BLE_GAP_EVENT_PER_SUBEV_DATA_REQ 34
#define BLE_GAP_EVENT_PER_SUBEV_RESP 35
#define BLE_GAP_EVENT_PERIODIC_TRANSFER_V2 36
/* DTM events */
#define BLE_GAP_DTM_TX_START_EVT 0
@@ -632,45 +634,6 @@ struct ble_gap_event {
#endif
} connect;
/**
* Represents a successful Link establishment attempt. Sometimes, in noisy environment,
* even if BLE_GAP_EVENT_CONNECT is posted, the link syncronization procedure may fail
* and link gets disconnected with reason 0x3E. Application can wait for below event to ensure
* the link syncronization is completed. 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;
#if MYNEWT_VAL(BLE_PERIODIC_ADV_WITH_RESPONSES)
/*
* Adv_Handle is used to identify an advertising set.
* If the connection is established from periodic advertising with responses
* and Role is 0x00 then the Advertising_Handle parameter shall be set
* according to the periodic advertising train the connection was established from
*/
uint8_t adv_handle;
/*
* Sync_Handle identifying the periodic advertising train
* If the connection is established from periodic advertising with responses
* and Role is 0x01, then the Sync_Handle parameter shall be set according
* to the periodic advertising train the connection was established from
*/
uint16_t sync_handle;
#endif
} link_estab;
/**
* Represents a terminated connection. Valid for the following event
* types:
+16 -30
View File
@@ -1029,11 +1029,10 @@ ble_gap_master_connect_failure(int status)
event.type = BLE_GAP_EVENT_CONNECT;
event.connect.status = status;
rc = state.cb(&event, state.cb_arg);
event.type = BLE_GAP_EVENT_LINK_ESTAB;
event.link_estab.status = status;
#if MYNEWT_VAL(BLE_PERIODIC_ADV_WITH_RESPONSES)
event.connect.sync_handle = pawr_sync_handle;
event.connect.adv_handle = pawr_adv_handle;
#endif
rc = state.cb(&event, state.cb_arg);
} else {
rc = 0;
@@ -1060,12 +1059,11 @@ ble_gap_master_connect_cancelled(void)
/* Connect procedure timed out. */
event.connect.status = BLE_HS_ETIMEOUT;
}
state.cb(&event, state.cb_arg);
event.type = BLE_GAP_EVENT_LINK_ESTAB;
event.link_estab.conn_handle = event.connect.conn_handle;
event.link_estab.status = event.connect.status;
#if MYNEWT_VAL(BLE_PERIODIC_ADV_WITH_RESPONSES)
event.connect.sync_handle = pawr_sync_handle;
event.connect.adv_handle = pawr_adv_handle;
#endif
state.cb(&event, state.cb_arg);
}
}
@@ -2335,7 +2333,6 @@ int
ble_gap_rx_conn_complete(struct ble_gap_conn_complete *evt, uint8_t instance)
{
#if NIMBLE_BLE_CONNECT
struct ble_gap_event event;
struct ble_hs_conn *conn;
int rc;
#if MYNEWT_VAL(BLE_GATT_CACHING)
@@ -2479,15 +2476,10 @@ ble_gap_rx_conn_complete(struct ble_gap_conn_complete *evt, uint8_t instance)
ble_hs_lock();
memset(&event, 0, sizeof event);
ble_hs_conn_insert(conn);
ble_hs_unlock();
event.type = BLE_GAP_EVENT_CONNECT;
event.connect.conn_handle = evt->connection_handle;
event.connect.status = 0;
/* add gatt connection */
#if MYNEWT_VAL(BLE_GATT_CACHING)
if (evt->role == BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER) {
@@ -2508,16 +2500,10 @@ ble_gap_rx_conn_complete(struct ble_gap_conn_complete *evt, uint8_t instance)
}
#endif
#if MYNEWT_VAL(BLE_PERIODIC_ADV_WITH_RESPONSES)
event.connect.sync_handle = evt->sync_handle;
event.connect.adv_handle = evt->adv_handle;
pawr_sync_handle = evt->sync_handle;
pawr_adv_handle = evt->adv_handle;
#endif
ble_gap_event_listener_call(&event);
ble_gap_call_conn_event_cb(&event, evt->connection_handle);
if (evt->role == BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE) {
ble_gap_rd_rem_ver_tx(evt->connection_handle);
} else {
@@ -2531,19 +2517,19 @@ ble_gap_rx_conn_complete(struct ble_gap_conn_complete *evt, uint8_t instance)
}
void
ble_gap_link_estab_call(uint16_t conn_handle, int status)
ble_gap_event_connect_call(uint16_t conn_handle, int status)
{
struct ble_gap_event event;
uint16_t handle = le16toh(conn_handle);
memset(&event, 0, sizeof event);
event.type = BLE_GAP_EVENT_LINK_ESTAB;
event.link_estab.status = status;
event.link_estab.conn_handle = handle;
event.type = BLE_GAP_EVENT_CONNECT;
event.connect.status = status;
event.connect.conn_handle = handle;
#if MYNEWT_VAL(BLE_PERIODIC_ADV_WITH_RESPONSES)
event.link_estab.sync_handle = pawr_sync_handle;
event.link_estab.adv_handle = pawr_adv_handle;
event.connect.sync_handle = pawr_sync_handle;
event.connect.adv_handle = pawr_adv_handle;
#endif
ble_gap_event_listener_call(&event);
@@ -2573,7 +2559,7 @@ ble_gap_rx_rd_rem_sup_feat_complete(const struct ble_hci_ev_le_subev_rd_rem_used
} else {
if ((conn != NULL) && (ev->status == 0)) {
conn->supported_feat = get_le32(ev->features);
ble_gap_link_estab_call(ev->conn_handle, ev->status);
ble_gap_event_connect_call(ev->conn_handle, ev->status);
slave_conn[ev->conn_handle] = 1;
}
}
@@ -2600,7 +2586,7 @@ ble_gap_rx_rd_rem_ver_info_complete(const struct ble_hci_ev_rd_rem_ver_info_cmp
ble_gap_rd_rem_sup_feat_tx(ev->conn_handle);
} else {
if ((conn != NULL) && (ev->status == 0)) {
ble_gap_link_estab_call(ev->conn_handle, ev->status);
ble_gap_event_connect_call(ev->conn_handle, ev->status);
}
}
#endif
+1 -1
View File
@@ -93,7 +93,7 @@ void ble_gap_rx_scan_req_rcvd(const struct ble_hci_ev_le_subev_scan_req_rcvd *ev
void ble_gap_rx_adv_report(struct ble_gap_disc_desc *desc);
void ble_gap_rx_rd_rem_sup_feat_complete(const struct ble_hci_ev_le_subev_rd_rem_used_feat *ev);
void ble_gap_rx_rd_rem_ver_info_complete(const struct ble_hci_ev_rd_rem_ver_info_cmp *ev);
void ble_gap_link_estab_call(uint16_t conn_handle, int status);
void ble_gap_event_connect_call(uint16_t conn_handle, int status);
#if MYNEWT_VAL(BLE_CONN_SUBRATING)
void ble_gap_rx_subrate_change(const struct ble_hci_ev_le_subev_subrate_change *ev);
#endif