From 0fb1f1ef11a0e166d78e8d71bd801f2f92fad047 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Wed, 14 Jan 2026 13:30:36 +0530 Subject: [PATCH] fix(nimble): Fix various documentation/ assignment / fixes --- nimble/host/include/host/ble_esp_gap.h | 2 +- nimble/host/include/host/ble_gap.h | 10 +++++----- nimble/host/include/host/ble_sm.h | 2 +- nimble/host/services/dis/src/ble_svc_dis.c | 2 +- nimble/host/services/gap/src/ble_svc_gap.c | 1 + nimble/host/src/ble_gap.c | 19 ++++++++++++++----- nimble/host/src/ble_gattc.c | 7 ++++--- nimble/host/src/ble_gattc_cache_conn.c | 2 +- nimble/host/src/ble_store.c | 3 --- nimble/transport/socket/src/ble_hci_socket.c | 1 + 10 files changed, 29 insertions(+), 20 deletions(-) diff --git a/nimble/host/include/host/ble_esp_gap.h b/nimble/host/include/host/ble_esp_gap.h index 2c22a8aec..c528acd45 100644 --- a/nimble/host/include/host/ble_esp_gap.h +++ b/nimble/host/include/host/ble_esp_gap.h @@ -360,7 +360,7 @@ void ble_gap_end_test_evt(const void *buf, uint8_t len); * * If resolved with local IRK -> set to all zeros * * If not resolved -> unchanged * - * Returns: ESP_OK if resolve, ESP_FAIL otherwise. + * Returns: true if resolve, false otherwise. */ bool ble_gap_rpa_resolve(uint8_t *rpa, uint8_t *ida, uint8_t *addr_type); diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index 1dec2d559..3feeb22c7 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -1993,7 +1993,7 @@ struct ble_gap_event { #endif /* MYNEWT_VAL(BLE_ISO) */ /** - * Represents a read all remote features complet event + * Represents a read all remote features complete event * Valid for the following event types: * o BLE_GAP_EVENT_RD_ALL_REM_FEAT */ @@ -2022,7 +2022,7 @@ struct ble_gap_event { #if MYNEWT_VAL(BLE_MONITOR_ADV) /** - * Represents a read all remote features complet event + * Represents a monitor advertising report event * Valid for the following event types: * o BLE_GAP_EVENT_MONITOR_ADV_REPORT */ @@ -2031,9 +2031,9 @@ struct ble_gap_event { uint8_t addr_type; /** Device Address */ - uint16_t address[6]; + uint8_t address[6]; - /** Represents weather RSSI threshold condition is met */ + /** Represents whether RSSI threshold condition is met */ uint8_t condition; } monitor_adv_report; @@ -4168,7 +4168,7 @@ int ble_gap_read_local_irk(uint8_t * out_irk); * * @param bit_num Bit position in the FeatureSet * - * @param The Host feature is disabled or enabled (0 & 1) + * @param bit_val The Host feature is disabled or enabled (0 & 1) * * return 0 on success; nonzero on failure */ diff --git a/nimble/host/include/host/ble_sm.h b/nimble/host/include/host/ble_sm.h index e61b391b0..f6e9d453f 100644 --- a/nimble/host/include/host/ble_sm.h +++ b/nimble/host/include/host/ble_sm.h @@ -148,7 +148,7 @@ int ble_sm_get_static_passkey_config(uint32_t *passkey, bool *enabled); #else #define ble_sm_inject_io(conn_handle, pkey) \ ((void)(conn_handle), BLE_HS_ENOTSUP) -#if !MYNEWT_VAL(STATIC_PASSKEY) +#if MYNEWT_VAL(STATIC_PASSKEY) #define ble_sm_configure_static_passkey(passkey, enable) \ ((void)(passkey), (void)(enable), BLE_HS_ENOTSUP) #define ble_sm_get_static_passkey_config(passkey, enabled) \ diff --git a/nimble/host/services/dis/src/ble_svc_dis.c b/nimble/host/services/dis/src/ble_svc_dis.c index e96b4fa39..c8c5e97ce 100644 --- a/nimble/host/services/dis/src/ble_svc_dis.c +++ b/nimble/host/services/dis/src/ble_svc_dis.c @@ -427,7 +427,7 @@ ble_svc_dis_included_init(void) int ble_svc_dis_init_dynamic(void) { - ble_svc_dis_data_ptr = nimble_platform_mem_calloc(1, sizeof(ble_svc_dis_data)); + ble_svc_dis_data_ptr = nimble_platform_mem_calloc(1, sizeof(*ble_svc_dis_data_ptr)); if (!ble_svc_dis_data_ptr) { return BLE_HS_ENOMEM; } diff --git a/nimble/host/services/gap/src/ble_svc_gap.c b/nimble/host/services/gap/src/ble_svc_gap.c index 798162603..fb8a0881e 100644 --- a/nimble/host/services/gap/src/ble_svc_gap.c +++ b/nimble/host/services/gap/src/ble_svc_gap.c @@ -24,6 +24,7 @@ #include "host/ble_hs.h" #include "services/gap/ble_svc_gap.h" #include "os/endian.h" +#include "esp_nimble_cfg.h" #if MYNEWT_VAL(BLE_GATTS) && CONFIG_BT_NIMBLE_GAP_SERVICE diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 25988efc0..4dbf9ef51 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -2379,6 +2379,7 @@ ble_gap_rx_rd_all_remote_feat(const struct ble_hci_ev_le_subev_rd_all_rem_feat * event.type = BLE_GAP_EVENT_RD_ALL_REM_FEAT; event.rd_all_rem_feat.status = ev->status; + event.rd_all_rem_feat.conn_handle = le16toh(ev->conn_handle); event.rd_all_rem_feat.max_remote_page = ev->max_remote_page; event.rd_all_rem_feat.max_valid_page = ev->max_valid_page; memcpy(event.rd_all_rem_feat.le_features, ev->le_features, 248); @@ -10362,6 +10363,10 @@ int ble_gap_set_scan_chan(uint8_t state, uint8_t *bitmap) memset(vs_cmd, 0x0, sizeof(vs_cmd)); vs_cmd[0] = state; + + if (bitmap == NULL) { + return BLE_HS_EINVAL; + } memcpy(&vs_cmd[1], bitmap, 5); return ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_SET_SCAN_CHAN, @@ -10605,8 +10610,12 @@ static inline bool is_rpa(const uint8_t *addr) bool ble_gap_rpa_resolve(uint8_t *rpa, uint8_t *ida, uint8_t *addr_type) { + if (!rpa || !ida || !addr_type) { + return false; + } + if (!is_rpa(rpa)) { - return ESP_FAIL; /* reject public / static random / non-RPA */ + return false; /* reject public / static random / non-RPA */ } /* ---- Step 1: Try peer IRKs ---- */ @@ -10629,7 +10638,7 @@ bool ble_gap_rpa_resolve(uint8_t *rpa, uint8_t *ida, uint8_t *addr_type) /* Found a match -> copy peer identity address */ memcpy(ida, sec.peer_addr.val, 6); *addr_type = sec.peer_addr.type; /* set type */ - return ESP_OK; + return true; } } } @@ -10644,9 +10653,9 @@ bool ble_gap_rpa_resolve(uint8_t *rpa, uint8_t *ida, uint8_t *addr_type) if (ble_hs_pvcy_resolve_with_irk(rpa, value.irk)) { /* Match with local IRK -> return ida = 00:00:00:00:00:00 */ memset(ida, 0, 6); - *addr_type = BLE_ADDR_PUBLIC; /* default type */ - return ESP_OK; + *addr_type = BLE_ADDR_PUBLIC; /* default type */ + return true; } - return ESP_FAIL; /* No match */ + return false; /* No match */ } diff --git a/nimble/host/src/ble_gattc.c b/nimble/host/src/ble_gattc.c index c94c3326a..4e5d68629 100644 --- a/nimble/host/src/ble_gattc.c +++ b/nimble/host/src/ble_gattc.c @@ -1574,7 +1574,8 @@ ble_gattc_recover_gatt_proc(uint16_t conn_handle, int enc_status) ble_gattc_write_long(conn_handle, proc->write_long.attr.handle, proc->write_long.attr.offset, om, proc->write_long.cb, proc->write_long.cb_arg); - case BLE_GATT_OP_WRITE_RELIABLE: + break; + case BLE_GATT_OP_WRITE_RELIABLE: for (int i = 0; i < proc->write_reliable.num_attrs; i++) { attrs[i].handle = proc->write_reliable.attrs[i].handle; attrs[i].offset = 0; @@ -1583,7 +1584,8 @@ ble_gattc_recover_gatt_proc(uint16_t conn_handle, int enc_status) ble_gattc_write_reliable(conn_handle, attrs, proc->write_reliable.num_attrs, proc->write_reliable.cb, proc->write_reliable.cb_arg); - } + break; + } } else { err_cb = ble_gattc_err_dispatch_get(proc->op); if (err_cb != NULL) { @@ -5838,7 +5840,6 @@ ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle, { return ble_gatts_indicate_custom(conn_handle, chr_val_handle, txom); } -//#endif int ble_gatts_indicate(uint16_t conn_handle, uint16_t chr_val_handle) diff --git a/nimble/host/src/ble_gattc_cache_conn.c b/nimble/host/src/ble_gattc_cache_conn.c index 81171535c..c3d33cab1 100644 --- a/nimble/host/src/ble_gattc_cache_conn.c +++ b/nimble/host/src/ble_gattc_cache_conn.c @@ -2015,7 +2015,7 @@ ble_gattc_cache_conn_disc_incs(struct ble_gattc_cache_conn *peer) ble_gattc_cache_conn_disc_chrs(peer); } } else { - ble_gattc_cache_conn_disc_chrs(peer); + ble_gattc_cache_conn_disc_chrs(peer); } return; } diff --git a/nimble/host/src/ble_store.c b/nimble/host/src/ble_store.c index 5983ad815..f816db76e 100644 --- a/nimble/host/src/ble_store.c +++ b/nimble/host/src/ble_store.c @@ -495,11 +495,8 @@ ble_store_key_from_value_ead(struct ble_store_key_ead *out_key, const struct ble_store_value_ead *value) { #if NIMBLE_BLE_CONNECT - out_key->peer_addr = value->peer_addr; out_key->idx = 0; -#else - return BLE_HS_ENOTSUP; #endif } #endif diff --git a/nimble/transport/socket/src/ble_hci_socket.c b/nimble/transport/socket/src/ble_hci_socket.c index 15c47534f..573c4991e 100644 --- a/nimble/transport/socket/src/ble_hci_socket.c +++ b/nimble/transport/socket/src/ble_hci_socket.c @@ -87,6 +87,7 @@ struct sockaddr_hci { #include "nimble/nimble_npl.h" #include "nimble/transport.h" #include "socket/ble_hci_socket.h" +#include "esp_nimble_mem.h" /*** * NOTES: