mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(nimble): Fix issues found in review for nimble examples
This commit is contained in:
@@ -141,9 +141,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;
|
||||
@@ -160,7 +162,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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@@ -90,9 +90,11 @@ dynamic_service_advertise(void)
|
||||
fields.name_len = strlen(name);
|
||||
fields.name_is_complete = 1;
|
||||
|
||||
fields.uuids16 = (ble_uuid16_t[]) {
|
||||
BLE_UUID16_INIT(GATT_SVR_SVC_ALERT_UUID)
|
||||
};
|
||||
/* Must be static: ble_gap_adv_set_fields stores the pointer, not the data.
|
||||
* A stack compound literal becomes dangling after this function returns,
|
||||
* causing corruption when BLE_NIMBLE_ENABLE_CONN_REATTEMPT re-uses it. */
|
||||
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;
|
||||
|
||||
@@ -143,8 +145,11 @@ dynamic_service_gap_event(struct ble_gap_event *event, void *arg)
|
||||
event->connect.status);
|
||||
if (event->connect.status == 0) {
|
||||
rc = ble_gap_conn_find(event->connect.conn_handle, &desc);
|
||||
assert(rc == 0);
|
||||
dynamic_service_print_conn_desc(&desc);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to find connection; rc=%d\n", rc);
|
||||
} else {
|
||||
dynamic_service_print_conn_desc(&desc);
|
||||
}
|
||||
}
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
|
||||
@@ -282,11 +287,19 @@ app_main(void)
|
||||
|
||||
#if MYNEWT_VAL(BLE_GATTS)
|
||||
rc = gatt_svr_init();
|
||||
assert(rc == 0);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to init GATT server; rc=%d\n", rc);
|
||||
nimble_port_deinit();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the default device name. */
|
||||
rc = ble_svc_gap_device_name_set("ble-dynamic-service");
|
||||
assert(rc == 0);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Failed to set device name; rc=%d\n", rc);
|
||||
nimble_port_deinit();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
nimble_port_freertos_init(dynamic_service_host_task);
|
||||
|
||||
Reference in New Issue
Block a user