fix(nimble): Fix issues found in review for nimble examples

This commit is contained in:
Rahul Tank
2026-07-24 17:50:29 +08:00
committed by BOT
parent 99b87ca81f
commit fa1bf5e2fc
73 changed files with 1299 additions and 635 deletions
@@ -151,9 +151,11 @@ gatt_svc_access(uint16_t conn_handle, uint16_t attr_handle,
sizeof(gatt_svr_chr_val),
sizeof(gatt_svr_chr_val),
&gatt_svr_chr_val, NULL);
ble_gatts_chr_updated(attr_handle);
MODLOG_DFLT(INFO, "Notification/Indication scheduled for "
"all subscribed peers.\n");
if (rc == 0) {
ble_gatts_chr_updated(attr_handle);
MODLOG_DFLT(INFO, "Notification/Indication scheduled for "
"all subscribed peers.\n");
}
return rc;
}
goto unknown;
@@ -170,7 +172,7 @@ gatt_svc_access(uint16_t conn_handle, uint16_t attr_handle,
if (ble_uuid_cmp(uuid, &gatt_svr_dsc_uuid.u) == 0) {
rc = os_mbuf_append(ctxt->om,
&gatt_svr_dsc_val,
sizeof(gatt_svr_chr_val));
sizeof(gatt_svr_dsc_val));
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
}
goto unknown;
@@ -184,9 +184,10 @@ bleprph_advertise(void)
fields.name_is_complete = 1;
#endif
fields.uuids16 = (ble_uuid16_t[]) {
static const ble_uuid16_t adv_uuids16[] = {
BLE_UUID16_INIT(GATT_SVR_SVC_ALERT_UUID)
};
fields.uuids16 = adv_uuids16;
fields.num_uuids16 = 1;
fields.uuids16_is_complete = 1;
@@ -480,17 +481,21 @@ bleprph_on_reset(int reason)
static void
ble_app_set_addr(void)
{
ble_addr_t addr;
ble_addr_t addr = {0};
int rc;
/* generate new non-resolvable private address */
rc = ble_hs_id_gen_rnd(0, &addr);
assert(rc == 0);
if (rc != 0) {
MODLOG_DFLT(ERROR, "ble_hs_id_gen_rnd failed; rc=%d\n", rc);
return;
}
/* set generated address */
rc = ble_hs_id_set_rnd(addr.val);
assert(rc == 0);
if (rc != 0) {
MODLOG_DFLT(ERROR, "ble_hs_id_set_rnd failed; rc=%d\n", rc);
}
}
#endif
@@ -507,8 +512,8 @@ bleprph_on_sync(void)
#if CONFIG_EXAMPLE_USE_CI_ADDRESS
if (strlen(CONFIG_EXAMPLE_CI_ADDRESS_OFFSET)) {
uint8_t addr[6] = {0};
uint32_t *offset = (uint32_t *)&addr[1];
*offset = atoi(CONFIG_EXAMPLE_CI_ADDRESS_OFFSET);
uint32_t offset_val = (uint32_t)atoi(CONFIG_EXAMPLE_CI_ADDRESS_OFFSET);
memcpy(&addr[1], &offset_val, sizeof(offset_val));
addr[5] = 0xC3;
addr[0] = CONFIG_IDF_FIRMWARE_CHIP_ID;
rc = ble_hs_id_set_rnd(addr);