mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(nimble): Improve safety, fix bugs, and update docs across NimBLE examples
- Remove unused headers from examples - Improve periodic adv/sync example functionality and readability - Use ble_hs_id_infer_auto() instead of hardcoded BLE_OWN_ADDR_PUBLIC/RANDOM - Add ble_hs_util_ensure_addr() calls in on_sync for proper address setup - Use correct ext adv instance (0 instead of 1) in phy_prph, l2cap_coc, multi_conn - Fix struct name: ble_gap_periodic_adv_enable_params -> ble_gap_periodic_adv_start_params - Add CONFIG_BT_NIMBLE_GAP_SERVICE guards around ble_svc_gap_device_name_set - Fix unsafe AD data parsing with bounds checks in central examples - Fix UUID matching bugs (off-by-one loop condition and byte order) in phy_cent, htp_cent, and proximity_sensor_cent - Fix ble_multi_conn_cent address type to use dynamic inference - Remove contradictory sm_sc=0 after sm_sc=1 in ble_multi_adv - Add CONFIG_BT_NIMBLE_EXT_ADV=y to ble_multi_adv sdkconfig defaults - Check return values for ble_gap_set_host_feat, nimble_port_init - Update tutorials and READMEs to match code changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@@ -491,9 +491,11 @@ ble_coex_advertise(void)
|
||||
fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
|
||||
|
||||
name = ble_svc_gap_device_name();
|
||||
fields.name = (uint8_t *)name;
|
||||
fields.name_len = strlen(name);
|
||||
fields.name_is_complete = 1;
|
||||
if (name) {
|
||||
fields.name = (uint8_t *)name;
|
||||
fields.name_len = strlen(name);
|
||||
fields.name_is_complete = 1;
|
||||
}
|
||||
|
||||
fields.uuids16 = (ble_uuid16_t[]) {
|
||||
BLE_UUID16_INIT(BLECOEX_SVC_ALERT_UUID)
|
||||
@@ -523,16 +525,19 @@ static void on_sync(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ble_hs_util_ensure_addr(0);
|
||||
|
||||
ble_hs_id_infer_auto(0, &own_addr_type);
|
||||
ble_svc_gap_device_name_set("NimBLE Coex");
|
||||
ble_coex_advertise();
|
||||
|
||||
// Start scanning as a client
|
||||
rc = ble_hs_util_ensure_addr(0);
|
||||
assert(rc == 0);
|
||||
|
||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
||||
assert(rc == 0);
|
||||
|
||||
#if CONFIG_BT_NIMBLE_GAP_SERVICE
|
||||
rc = ble_svc_gap_device_name_set("NimBLE Coex");
|
||||
assert(rc == 0);
|
||||
#endif
|
||||
ble_coex_advertise();
|
||||
|
||||
/* Start scanning as a client */
|
||||
ble_coex_scan();
|
||||
}
|
||||
|
||||
@@ -557,7 +562,11 @@ void app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nimble_port_init();
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init nimble %d \n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ble_hs_cfg.sync_cb = on_sync;
|
||||
#if MYNEWT_VAL(BLE_INCL_SVC_DISCOVERY) || MYNEWT_VAL(BLE_GATT_CACHING_INCLUDE_SERVICES)
|
||||
|
||||
Reference in New Issue
Block a user