fix(nimble): Corrected link_estab event handling parameters

This commit is contained in:
Rahul Tank
2024-12-19 16:00:46 +05:30
parent f098b8f1f0
commit 21cebc7df9
27 changed files with 157 additions and 157 deletions
@@ -703,30 +703,30 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
case BLE_GAP_EVENT_LINK_ESTAB:
/* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) {
if (event->link_estab.status == 0) {
/* Connection successfully established. */
MODLOG_DFLT(INFO, "Connection established ");
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
assert(rc == 0);
print_conn_desc(&desc);
MODLOG_DFLT(INFO, "\n");
/* Remember peer. */
rc = peer_add(event->connect.conn_handle);
rc = peer_add(event->link_estab.conn_handle);
if (rc != 0) {
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
return 0;
}
#if MYNEWT_VAL(BLE_POWER_CONTROL)
blecent_power_control(event->connect.conn_handle);
blecent_power_control(event->link_estab.conn_handle);
#endif
#if MYNEWT_VAL(BLE_HCI_VS)
#if MYNEWT_VAL(BLE_POWER_CONTROL)
memset(&params, 0x0, sizeof(struct ble_gap_set_auto_pcl_params));
params.conn_handle = event->connect.conn_handle;
params.conn_handle = event->link_estab.conn_handle;
rc = ble_gap_set_auto_pcl_param(&params);
if (rc != 0) {
MODLOG_DFLT(INFO, "Failed to send VSC %x \n", rc);
@@ -745,17 +745,17 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
* Encryption (Enable encryption)
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
**/
rc = ble_gap_security_initiate(event->connect.conn_handle);
rc = ble_gap_security_initiate(event->link_estab.conn_handle);
if (rc != 0) {
MODLOG_DFLT(INFO, "Security could not be initiated, rc = %d\n", rc);
return ble_gap_terminate(event->connect.conn_handle,
return ble_gap_terminate(event->link_estab.conn_handle,
BLE_ERR_REM_USER_CONN_TERM);
} else {
MODLOG_DFLT(INFO, "Connection secured\n");
}
#else
/* Perform service discovery */
rc = peer_disc_all(event->connect.conn_handle,
rc = peer_disc_all(event->link_estab.conn_handle,
blecent_on_disc_complete, NULL);
if(rc != 0) {
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
@@ -765,7 +765,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
} else {
/* Connection attempt failed; resume scanning. */
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
event->connect.status);
event->link_estab.status);
blecent_scan();
}