From 0563f7f094d817bf0db3728e802f99a196569b27 Mon Sep 17 00:00:00 2001 From: Prasad Alatkar Date: Mon, 14 Dec 2020 20:41:03 +0530 Subject: [PATCH] NimBLE: Fix compilation errors when HOST_BASED_PRIVACY is disabled. - When Host based privacy config option is disabled then automatically controller based privacy is enabled. Remove compilation errors for this case. --- nimble/host/src/ble_gap.c | 4 ++-- nimble/host/store/config/src/ble_store_nvs.c | 21 +++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 24f056a33..a5f45e613 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -1519,8 +1519,8 @@ ble_gap_rx_periodic_adv_rpt(const struct ble_hci_ev_le_subev_periodic_adv_rpt *e { struct ble_hs_periodic_sync *psync; struct ble_gap_event event; - ble_gap_event_fn *cb; - void *cb_arg; + ble_gap_event_fn *cb = NULL; + void *cb_arg = NULL; ble_hs_lock(); psync = ble_hs_periodic_sync_find_by_handle(le16toh(ev->sync_handle)); diff --git a/nimble/host/store/config/src/ble_store_nvs.c b/nimble/host/store/config/src/ble_store_nvs.c index 6ee027b43..0966f943e 100644 --- a/nimble/host/store/config/src/ble_store_nvs.c +++ b/nimble/host/store/config/src/ble_store_nvs.c @@ -178,7 +178,9 @@ static int get_nvs_db_attribute(int obj_type, bool empty, void *value, int num_value) { union ble_store_value cur = {0}; +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) struct ble_hs_dev_records p_dev_rec = {0}; +#endif esp_err_t err; int i, count = 0, max_limit = 0; char key_string[NIMBLE_NVS_STR_NAME_MAX_LEN]; @@ -188,11 +190,15 @@ get_nvs_db_attribute(int obj_type, bool empty, void *value, int num_value) for (i = 1; i <= max_limit; i++) { get_nvs_key_string(obj_type, i, key_string); +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) if (obj_type != BLE_STORE_OBJ_TYPE_PEER_DEV_REC) { +#endif err = get_nvs_db_value(obj_type, key_string, &cur); +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) } else { err = get_nvs_peer_record(key_string, &p_dev_rec); } +#endif /* Check if the user is searching for empty index to write to */ if (err == ESP_ERR_NVS_NOT_FOUND) { if (empty) { @@ -204,10 +210,13 @@ get_nvs_db_attribute(int obj_type, bool empty, void *value, int num_value) /* If user has provided value, then the purpose is to find * non-matching entry from NVS */ if (value) { +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) if (obj_type == BLE_STORE_OBJ_TYPE_PEER_DEV_REC) { err = get_nvs_matching_index(&p_dev_rec, value, num_value, sizeof(struct ble_hs_dev_records)); - } else { + } else +#endif + { if (obj_type != BLE_STORE_OBJ_TYPE_CCCD) { err = get_nvs_matching_index(&cur.sec, value, num_value, sizeof(struct ble_store_value_sec)); @@ -374,7 +383,9 @@ populate_db_from_nvs(int obj_type, void *dst, int *db_num) { uint8_t *db_item = (uint8_t *)dst; union ble_store_value cur = {0}; +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) struct ble_hs_dev_records p_dev_rec = {0}; +#endif esp_err_t err; int i; @@ -383,8 +394,9 @@ populate_db_from_nvs(int obj_type, void *dst, int *db_num) for (i = 1; i <= get_nvs_max_obj_value(obj_type); i++) { get_nvs_key_string(obj_type, i, key_string); +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) if (obj_type != BLE_STORE_OBJ_TYPE_PEER_DEV_REC) { - +#endif err = get_nvs_db_value(obj_type, key_string, &cur); if (err == ESP_ERR_NVS_NOT_FOUND) { continue; @@ -392,6 +404,7 @@ populate_db_from_nvs(int obj_type, void *dst, int *db_num) ESP_LOGE(TAG, "NVS read operation failed !!"); return -1; } +#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) } else { err = get_nvs_peer_record(key_string, &p_dev_rec); if (err == ESP_ERR_NVS_NOT_FOUND) { @@ -408,7 +421,9 @@ populate_db_from_nvs(int obj_type, void *dst, int *db_num) memcpy(db_item, &p_dev_rec, sizeof(struct ble_hs_dev_records)); db_item += sizeof(struct ble_hs_dev_records); (*db_num)++; - } else { + } else +#endif + { if (obj_type == BLE_STORE_OBJ_TYPE_CCCD) { ESP_LOGD(TAG, "CCCD in RAM is filled up from NVS index = %d", i); memcpy(db_item, &cur.cccd, sizeof(struct ble_store_value_cccd));