mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
Merge branch 'bugfix/fix_link_estab_param_v5.0' into 'release/v5.0'
fix(nimble): Corrected link_estab event handling parameters (v5.0) See merge request espressif/esp-idf!35811
This commit is contained in:
commit
e5b60eb20b
@ -1 +1 @@
|
|||||||
Subproject commit 2c71e39d238e63f470a1a4c59994010fe564b9bc
|
Subproject commit e72f1360c7084f0a15d6cf7125e77f09aab6017d
|
@ -139,16 +139,16 @@ dynamic_service_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_CONNECT:
|
case BLE_GAP_EVENT_CONNECT:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
dynamic_service_print_conn_desc(&desc);
|
dynamic_service_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
dynamic_service_advertise();
|
dynamic_service_advertise();
|
||||||
}
|
}
|
||||||
|
@ -426,11 +426,11 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
MODLOG_DFLT(INFO, "Connection 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);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
MODLOG_DFLT(INFO, "");
|
MODLOG_DFLT(INFO, "");
|
||||||
@ -440,29 +440,29 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gattc_exchange_mtu(event->connect.conn_handle, NULL, NULL);
|
rc = ble_gattc_exchange_mtu(event->link_estab.conn_handle, NULL, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Failed to negotiate MTU; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to negotiate MTU; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = peer_set_addr(event->connect.conn_handle, desc.peer_id_addr.val);
|
rc = peer_set_addr(event->link_estab.conn_handle, desc.peer_id_addr.val);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to set peer addr; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to set peer addr; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Authorization is required for this characterisitc */
|
/** Authorization is required for this characterisitc */
|
||||||
rc = ble_gap_security_initiate(event->connect.conn_handle);
|
rc = ble_gap_security_initiate(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(INFO, "Security could not be initiated, rc = %d\n", rc);
|
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);
|
BLE_ERR_REM_USER_CONN_TERM);
|
||||||
} else {
|
} else {
|
||||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||||
@ -471,7 +471,7 @@ enc_adv_data_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
enc_adv_data_cent_scan();
|
enc_adv_data_cent_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,16 +188,16 @@ enc_adv_data_prph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
enc_adv_data_prph_print_conn_desc(&desc);
|
enc_adv_data_prph_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
enc_adv_data_prph_advertise();
|
enc_adv_data_prph_advertise();
|
||||||
}
|
}
|
||||||
|
@ -490,17 +490,17 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
MODLOG_DFLT(INFO, "Connection 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);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
@ -513,17 +513,17 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
* Encryption (Enable encryption)
|
* Encryption (Enable encryption)
|
||||||
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
|
* 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) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(INFO, "Security could not be initiated, rc = %d\n", rc);
|
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);
|
BLE_ERR_REM_USER_CONN_TERM);
|
||||||
} else {
|
} else {
|
||||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Perform service discovery */
|
/* Perform service discovery */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||||
ble_htp_cent_on_disc_complete, NULL);
|
ble_htp_cent_on_disc_complete, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
@ -533,7 +533,7 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
ble_htp_cent_scan();
|
ble_htp_cent_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +566,7 @@ ble_htp_cent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||||
/*** Go for service discovery after encryption has been successfully enabled ***/
|
/*** Go for service discovery after encryption has been successfully enabled ***/
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||||
ble_htp_cent_on_disc_complete, NULL);
|
ble_htp_cent_on_disc_complete, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -233,10 +233,10 @@ ble_htp_prph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed */
|
/* A new connection was established or a connection attempt failed */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d\n",
|
MODLOG_DFLT(INFO, "connection %s; status=%d\n",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising */
|
/* Connection failed; resume advertising */
|
||||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||||
ext_ble_htp_prph_advertise();
|
ext_ble_htp_prph_advertise();
|
||||||
@ -245,7 +245,7 @@ ble_htp_prph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
conn_handle = event->connect.conn_handle;
|
conn_handle = event->link_estab.conn_handle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_DISCONNECT:
|
case BLE_GAP_EVENT_DISCONNECT:
|
||||||
|
@ -414,30 +414,30 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
MODLOG_DFLT(INFO, "Connection 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);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) >= 1
|
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) >= 1
|
||||||
conn_handle_coc = event->connect.conn_handle;
|
conn_handle_coc = event->link_estab.conn_handle;
|
||||||
disc_cb = blecent_l2cap_coc_on_disc_complete;
|
disc_cb = blecent_l2cap_coc_on_disc_complete;
|
||||||
#else
|
#else
|
||||||
disc_cb = blecent_on_disc_complete;
|
disc_cb = blecent_on_disc_complete;
|
||||||
#endif
|
#endif
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform service discovery. */
|
/* Perform service discovery. */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||||
disc_cb, NULL);
|
disc_cb, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
@ -446,7 +446,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
blecent_scan();
|
blecent_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -320,16 +320,16 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
bleprph_print_conn_desc(&desc);
|
bleprph_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||||
ext_bleprph_advertise();
|
ext_bleprph_advertise();
|
||||||
@ -337,7 +337,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
bleprph_advertise();
|
bleprph_advertise();
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
bleprph_print_conn_desc(&desc);
|
bleprph_print_conn_desc(&desc);
|
||||||
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) >= 1
|
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) >= 1
|
||||||
|
@ -340,10 +340,10 @@ ble_multi_adv_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
ble_multi_adv_print_conn_desc(&desc);
|
ble_multi_adv_print_conn_desc(&desc);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -349,7 +349,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
|
|
||||||
switch (s_current_phy) {
|
switch (s_current_phy) {
|
||||||
@ -367,20 +367,20 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform service discovery. */
|
/* 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);
|
blecent_on_disc_complete, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
@ -389,7 +389,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
blecent_scan();
|
blecent_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -186,16 +186,16 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
bleprph_print_conn_desc(&desc);
|
bleprph_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
ext_bleprph_advertise();
|
ext_bleprph_advertise();
|
||||||
}
|
}
|
||||||
|
@ -273,25 +273,25 @@ ble_spp_client_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
MODLOG_DFLT(INFO, "Connection 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);
|
assert(rc == 0);
|
||||||
memcpy(&connected_addr[event->connect.conn_handle].val, desc.peer_id_addr.val,
|
memcpy(&connected_addr[event->link_estab.conn_handle].val, desc.peer_id_addr.val,
|
||||||
PEER_ADDR_VAL_SIZE);
|
PEER_ADDR_VAL_SIZE);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform service discovery. */
|
/* Perform service discovery. */
|
||||||
rc = peer_disc_all(event->connect.conn_handle,
|
rc = peer_disc_all(event->link_estab.conn_handle,
|
||||||
ble_spp_client_on_disc_complete, NULL);
|
ble_spp_client_on_disc_complete, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
@ -300,7 +300,7 @@ ble_spp_client_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
ble_spp_client_scan();
|
ble_spp_client_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -144,15 +144,15 @@ ble_spp_server_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
ble_spp_server_print_conn_desc(&desc);
|
ble_spp_server_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
if (event->connect.status != 0 || CONFIG_BT_NIMBLE_MAX_CONNECTIONS > 1) {
|
if (event->link_estab.status != 0 || CONFIG_BT_NIMBLE_MAX_CONNECTIONS > 1) {
|
||||||
/* Connection failed or if multiple connection allowed; resume advertising. */
|
/* Connection failed or if multiple connection allowed; resume advertising. */
|
||||||
ble_spp_server_advertise();
|
ble_spp_server_advertise();
|
||||||
}
|
}
|
||||||
|
@ -698,24 +698,24 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
MODLOG_DFLT(INFO, "Connection 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);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to add peer; rc=%d\n", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||||
blecent_power_control(event->connect.conn_handle);
|
blecent_power_control(event->link_estab.conn_handle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_ENCRYPTION
|
#if CONFIG_EXAMPLE_ENCRYPTION
|
||||||
@ -725,17 +725,17 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
* Encryption (Enable encryption)
|
* Encryption (Enable encryption)
|
||||||
* Will invoke event BLE_GAP_EVENT_ENC_CHANGE
|
* 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) {
|
if (rc != 0) {
|
||||||
MODLOG_DFLT(INFO, "Security could not be initiated, rc = %d\n", rc);
|
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);
|
BLE_ERR_REM_USER_CONN_TERM);
|
||||||
} else {
|
} else {
|
||||||
MODLOG_DFLT(INFO, "Connection secured\n");
|
MODLOG_DFLT(INFO, "Connection secured\n");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Perform service discovery */
|
/* 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);
|
blecent_on_disc_complete, NULL);
|
||||||
if(rc != 0) {
|
if(rc != 0) {
|
||||||
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
|
||||||
@ -745,7 +745,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
blecent_scan();
|
blecent_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,14 +187,14 @@ blehr_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed */
|
/* A new connection was established or a connection attempt failed */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d\n",
|
MODLOG_DFLT(INFO, "connection %s; status=%d\n",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising */
|
/* Connection failed; resume advertising */
|
||||||
blehr_advertise();
|
blehr_advertise();
|
||||||
}
|
}
|
||||||
conn_handle = event->connect.conn_handle;
|
conn_handle = event->link_estab.conn_handle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_DISCONNECT:
|
case BLE_GAP_EVENT_DISCONNECT:
|
||||||
|
@ -245,16 +245,16 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
bleprph_print_conn_desc(&desc);
|
bleprph_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||||
ext_bleprph_advertise();
|
ext_bleprph_advertise();
|
||||||
@ -264,7 +264,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||||
bleprph_power_control(event->connect.conn_handle);
|
bleprph_power_control(event->link_estab.conn_handle);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -392,15 +392,15 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
ESP_LOGI(TAG, "connection %s; status=%d ",
|
ESP_LOGI(TAG, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
bleprph_print_conn_desc(&desc);
|
bleprph_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
bleprph_advertise();
|
bleprph_advertise();
|
||||||
}
|
}
|
||||||
|
@ -285,16 +285,16 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
MODLOG_DFLT(INFO, "connection %s; status=%d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
bleprph_print_conn_desc(&desc);
|
bleprph_print_conn_desc(&desc);
|
||||||
}
|
}
|
||||||
MODLOG_DFLT(INFO, "\n");
|
MODLOG_DFLT(INFO, "\n");
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising. */
|
/* Connection failed; resume advertising. */
|
||||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||||
ext_bleprph_advertise();
|
ext_bleprph_advertise();
|
||||||
@ -304,7 +304,7 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||||
bleprph_power_control(event->connect.conn_handle);
|
bleprph_power_control(event->link_estab.conn_handle);
|
||||||
|
|
||||||
ble_gap_event_listener_register(&power_control_event_listener,
|
ble_gap_event_listener_register(&power_control_event_listener,
|
||||||
bleprph_gap_power_event, NULL);
|
bleprph_gap_power_event, NULL);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -540,11 +540,11 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed. */
|
/* A new connection was established or a connection attempt failed. */
|
||||||
if (event->connect.status == 0) {
|
if (event->link_estab.status == 0) {
|
||||||
/* Connection successfully established. */
|
/* Connection successfully established. */
|
||||||
/* XXX Set packet length in controller for better throughput */
|
/* XXX Set packet length in controller for better throughput */
|
||||||
ESP_LOGI(tag, "Connection established ");
|
ESP_LOGI(tag, "Connection established ");
|
||||||
rc = ble_hs_hci_util_set_data_len(event->connect.conn_handle,
|
rc = ble_hs_hci_util_set_data_len(event->link_estab.conn_handle,
|
||||||
LL_PACKET_LENGTH, LL_PACKET_TIME);
|
LL_PACKET_LENGTH, LL_PACKET_TIME);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Set packet length failed; rc = %d", rc);
|
ESP_LOGE(tag, "Set packet length failed; rc = %d", rc);
|
||||||
@ -555,29 +555,29 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gattc_exchange_mtu(event->connect.conn_handle, NULL, NULL);
|
rc = ble_gattc_exchange_mtu(event->link_estab.conn_handle, NULL, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Failed to negotiate MTU; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to negotiate MTU; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
rc = ble_gap_conn_find(event->link_estab.conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
|
|
||||||
rc = ble_gap_update_params(event->connect.conn_handle, &conn_params);
|
rc = ble_gap_update_params(event->link_estab.conn_handle, &conn_params);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Failed to update params; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to update params; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remember peer. */
|
/* Remember peer. */
|
||||||
rc = peer_add(event->connect.conn_handle);
|
rc = peer_add(event->link_estab.conn_handle);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Failed to add peer; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to add peer; rc = %d", rc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform service discovery. */
|
/* 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);
|
blecent_on_disc_complete, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Failed to discover services; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to discover services; rc = %d", rc);
|
||||||
@ -586,7 +586,7 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
} else {
|
} else {
|
||||||
/* Connection attempt failed; resume scanning. */
|
/* Connection attempt failed; resume scanning. */
|
||||||
ESP_LOGE(tag, "Error: Connection failed; status = %d",
|
ESP_LOGE(tag, "Error: Connection failed; status = %d",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
blecent_scan();
|
blecent_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -241,26 +241,26 @@ gatts_gap_event(struct ble_gap_event *event, void *arg)
|
|||||||
case BLE_GAP_EVENT_LINK_ESTAB:
|
case BLE_GAP_EVENT_LINK_ESTAB:
|
||||||
/* A new connection was established or a connection attempt failed */
|
/* A new connection was established or a connection attempt failed */
|
||||||
ESP_LOGI(tag, "connection %s; status = %d ",
|
ESP_LOGI(tag, "connection %s; status = %d ",
|
||||||
event->connect.status == 0 ? "established" : "failed",
|
event->link_estab.status == 0 ? "established" : "failed",
|
||||||
event->connect.status);
|
event->link_estab.status);
|
||||||
rc = ble_att_set_preferred_mtu(PREFERRED_MTU_VALUE);
|
rc = ble_att_set_preferred_mtu(PREFERRED_MTU_VALUE);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
ESP_LOGE(tag, "Failed to set preferred MTU; rc = %d", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->connect.status != 0) {
|
if (event->link_estab.status != 0) {
|
||||||
/* Connection failed; resume advertising */
|
/* Connection failed; resume advertising */
|
||||||
gatts_advertise();
|
gatts_advertise();
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_hs_hci_util_set_data_len(event->connect.conn_handle,
|
rc = ble_hs_hci_util_set_data_len(event->link_estab.conn_handle,
|
||||||
LL_PACKET_LENGTH,
|
LL_PACKET_LENGTH,
|
||||||
LL_PACKET_TIME);
|
LL_PACKET_TIME);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ESP_LOGE(tag, "Set packet length failed");
|
ESP_LOGE(tag, "Set packet length failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_handle = event->connect.conn_handle;
|
conn_handle = event->link_estab.conn_handle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_GAP_EVENT_DISCONNECT:
|
case BLE_GAP_EVENT_DISCONNECT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user