diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 05a5e3bb0..f9018c6e6 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -6630,6 +6630,7 @@ int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr) { #if NIMBLE_BLE_SM +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) ble_addr_t peer_id_addrs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; int num_peers; int rc, i; @@ -6662,6 +6663,9 @@ ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr) #else return BLE_HS_ENOTSUP; #endif +#else + return BLE_HS_ENOTSUP; +#endif } void diff --git a/nimble/host/src/ble_hs_resolv.c b/nimble/host/src/ble_hs_resolv.c index 52bc04c20..c937c8793 100644 --- a/nimble/host/src/ble_hs_resolv.c +++ b/nimble/host/src/ble_hs_resolv.c @@ -181,6 +181,7 @@ is_rpa_resolvable_by_peer_rec(struct ble_hs_dev_records *p_dev_rec, uint8_t *pee return false; } +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static void ble_rpa_replace_id_with_rand_addr(uint8_t *addr_type, uint8_t *peer_addr) { @@ -218,6 +219,7 @@ ble_rpa_replace_id_with_rand_addr(uint8_t *addr_type, uint8_t *peer_addr) } return; } +#endif /* Add peer to peer device records. * @@ -493,6 +495,7 @@ is_irk_nonzero(uint8_t *irk) static int ble_hs_is_on_resolv_list(uint8_t *addr, uint8_t addr_type) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int i; struct ble_hs_resolv_entry *rl = &g_ble_hs_resolv_list[1]; @@ -504,6 +507,7 @@ ble_hs_is_on_resolv_list(uint8_t *addr, uint8_t addr_type) ++rl; } +#endif return 0; } @@ -517,6 +521,7 @@ ble_hs_is_on_resolv_list(uint8_t *addr, uint8_t addr_type) struct ble_hs_resolv_entry * ble_hs_resolv_list_find(uint8_t *addr) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int i; struct ble_hs_resolv_entry *rl = &g_ble_hs_resolv_list[1]; @@ -534,6 +539,7 @@ ble_hs_resolv_list_find(uint8_t *addr) } ++rl; } +#endif return NULL; } @@ -598,12 +604,15 @@ ble_hs_resolv_list_add(uint8_t *cmdbuf) int ble_hs_resolv_list_rmv(uint8_t addr_type, uint8_t *ident_addr) { - int position, rc = BLE_HS_ENOENT; + int rc = BLE_HS_ENOENT; + +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) + int position; /* Remove from IRK records */ position = ble_hs_is_on_resolv_list(ident_addr, addr_type); - if (position) { + if (position) { memmove(&g_ble_hs_resolv_list[position], &g_ble_hs_resolv_list[position + 1], (g_ble_hs_resolv_data.rl_cnt - position) * sizeof (struct @@ -617,6 +626,7 @@ ble_hs_resolv_list_rmv(uint8_t addr_type, uint8_t *ident_addr) * peer_address to its latest received OTA address, this helps when existing bond at * peer side is removed */ ble_rpa_replace_id_with_rand_addr(&addr_type, ident_addr); +#endif return rc; } diff --git a/nimble/host/src/ble_store_util.c b/nimble/host/src/ble_store_util.c index 45b247bce..042941fa0 100644 --- a/nimble/host/src/ble_store_util.c +++ b/nimble/host/src/ble_store_util.c @@ -225,6 +225,7 @@ ble_store_util_count(int type, int *out_count) int ble_store_util_delete_oldest_peer(void) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) ble_addr_t peer_id_addrs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; int num_peers; int rc; @@ -244,7 +245,7 @@ ble_store_util_delete_oldest_peer(void) if (rc != 0) { return rc; } - +#endif return 0; } diff --git a/nimble/host/store/config/src/ble_store_config.c b/nimble/host/store/config/src/ble_store_config.c index 5729ec23e..2df66ce84 100644 --- a/nimble/host/store/config/src/ble_store_config.c +++ b/nimble/host/store/config/src/ble_store_config.c @@ -26,16 +26,24 @@ #include "store/config/ble_store_config.h" #include "ble_store_config_priv.h" +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) struct ble_store_value_sec ble_store_config_our_secs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; +#endif int ble_store_config_num_our_secs; +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) struct ble_store_value_sec ble_store_config_peer_secs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; +#endif + int ble_store_config_num_peer_secs; +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) struct ble_store_value_cccd ble_store_config_cccds[MYNEWT_VAL(BLE_STORE_MAX_CCCDS)]; +#endif + int ble_store_config_num_cccds; #if MYNEWT_VAL(ENC_ADV_DATA) @@ -48,6 +56,7 @@ int ble_store_config_num_eads; * $sec * *****************************************************************************/ +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static void ble_store_config_print_value_sec(const struct ble_store_value_sec *sec) { @@ -70,6 +79,7 @@ ble_store_config_print_value_sec(const struct ble_store_value_sec *sec) BLE_HS_LOG(DEBUG, "\n"); } +#endif static void ble_store_config_print_key_sec(const struct ble_store_key_sec *key_sec) @@ -82,6 +92,7 @@ ble_store_config_print_key_sec(const struct ble_store_key_sec *key_sec) } } +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static int ble_store_config_find_sec(const struct ble_store_key_sec *key_sec, const struct ble_store_value_sec *value_secs, @@ -106,11 +117,13 @@ ble_store_config_find_sec(const struct ble_store_key_sec *key_sec, return -1; } +#endif static int ble_store_config_read_our_sec(const struct ble_store_key_sec *key_sec, struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int idx; idx = ble_store_config_find_sec(key_sec, ble_store_config_our_secs, @@ -121,12 +134,16 @@ ble_store_config_read_our_sec(const struct ble_store_key_sec *key_sec, *value_sec = ble_store_config_our_secs[idx]; return 0; +#else + return BLE_HS_ENOENT; +#endif } static int ble_store_config_write_our_sec(const struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) struct ble_store_key_sec key_sec; int idx; int rc; @@ -156,8 +173,13 @@ ble_store_config_write_our_sec(const struct ble_store_value_sec *value_sec) } return 0; +#else + return BLE_HS_ENOENT; +#endif + } +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static int ble_store_config_delete_obj(void *values, int value_size, int idx, int *num_values) @@ -200,10 +222,12 @@ ble_store_config_delete_sec(const struct ble_store_key_sec *key_sec, return 0; } +#endif static int ble_store_config_delete_our_sec(const struct ble_store_key_sec *key_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int rc; rc = ble_store_config_delete_sec(key_sec, ble_store_config_our_secs, @@ -218,11 +242,15 @@ ble_store_config_delete_our_sec(const struct ble_store_key_sec *key_sec) } return 0; +#else + return BLE_HS_ENOENT; +#endif } static int ble_store_config_delete_peer_sec(const struct ble_store_key_sec *key_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int rc; rc = ble_store_config_delete_sec(key_sec, ble_store_config_peer_secs, @@ -235,14 +263,17 @@ ble_store_config_delete_peer_sec(const struct ble_store_key_sec *key_sec) if (rc != 0) { return rc; } - return 0; +#else + return BLE_HS_ENOENT; +#endif } static int ble_store_config_read_peer_sec(const struct ble_store_key_sec *key_sec, struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int idx; idx = ble_store_config_find_sec(key_sec, ble_store_config_peer_secs, @@ -253,11 +284,16 @@ ble_store_config_read_peer_sec(const struct ble_store_key_sec *key_sec, *value_sec = ble_store_config_peer_secs[idx]; return 0; +#else + return BLE_HS_ENOENT; +#endif + } static int ble_store_config_write_peer_sec(const struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) struct ble_store_key_sec key_sec; int idx; int rc; @@ -285,14 +321,17 @@ ble_store_config_write_peer_sec(const struct ble_store_value_sec *value_sec) if (rc != 0) { return rc; } - return 0; +#else + return BLE_HS_ENOENT; +#endif } /***************************************************************************** * $cccd * *****************************************************************************/ +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) static int ble_store_config_find_cccd(const struct ble_store_key_cccd *key) { @@ -323,13 +362,14 @@ ble_store_config_find_cccd(const struct ble_store_key_cccd *key) return i; } - return -1; } +#endif static int ble_store_config_delete_cccd(const struct ble_store_key_cccd *key_cccd) { +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) int idx; int rc; @@ -350,14 +390,17 @@ ble_store_config_delete_cccd(const struct ble_store_key_cccd *key_cccd) if (rc != 0) { return rc; } - return 0; +#else + return BLE_HS_ENOENT; +#endif } static int ble_store_config_read_cccd(const struct ble_store_key_cccd *key_cccd, struct ble_store_value_cccd *value_cccd) { +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) int idx; idx = ble_store_config_find_cccd(key_cccd); @@ -367,11 +410,15 @@ ble_store_config_read_cccd(const struct ble_store_key_cccd *key_cccd, *value_cccd = ble_store_config_cccds[idx]; return 0; +#else + return BLE_HS_ENOENT; +#endif } static int ble_store_config_write_cccd(const struct ble_store_value_cccd *value_cccd) { +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) struct ble_store_key_cccd key_cccd; int idx; int rc; @@ -397,6 +444,9 @@ ble_store_config_write_cccd(const struct ble_store_value_cccd *value_cccd) } return 0; +#else + return BLE_HS_ENOENT; +#endif } /***************************************************************************** diff --git a/nimble/host/store/ram/src/ble_store_ram.c b/nimble/host/store/ram/src/ble_store_ram.c index a43f7fa56..a2eb34fda 100644 --- a/nimble/host/store/ram/src/ble_store_ram.c +++ b/nimble/host/store/ram/src/ble_store_ram.c @@ -36,16 +36,25 @@ #include "host/ble_hs.h" #include "store/ram/ble_store_ram.h" +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static struct ble_store_value_sec ble_store_ram_our_secs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; +#endif + static int ble_store_ram_num_our_secs; +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static struct ble_store_value_sec ble_store_ram_peer_secs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; +#endif + static int ble_store_ram_num_peer_secs; +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) static struct ble_store_value_cccd ble_store_ram_cccds[MYNEWT_VAL(BLE_STORE_MAX_CCCDS)]; +#endif + static int ble_store_ram_num_cccds; #if MYNEWT_VAL(ENC_ADV_DATA) @@ -58,6 +67,7 @@ static int ble_store_ram_num_eads; * $sec * *****************************************************************************/ +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static void ble_store_ram_print_value_sec(const struct ble_store_value_sec *sec) { @@ -80,6 +90,7 @@ ble_store_ram_print_value_sec(const struct ble_store_value_sec *sec) BLE_HS_LOG(DEBUG, "\n"); } +#endif static void ble_store_ram_print_key_sec(const struct ble_store_key_sec *key_sec) @@ -92,6 +103,7 @@ ble_store_ram_print_key_sec(const struct ble_store_key_sec *key_sec) } } +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static int ble_store_ram_find_sec(const struct ble_store_key_sec *key_sec, const struct ble_store_value_sec *value_secs, @@ -116,11 +128,13 @@ ble_store_ram_find_sec(const struct ble_store_key_sec *key_sec, return -1; } +#endif static int ble_store_ram_read_our_sec(const struct ble_store_key_sec *key_sec, struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int idx; idx = ble_store_ram_find_sec(key_sec, ble_store_ram_our_secs, @@ -131,11 +145,16 @@ ble_store_ram_read_our_sec(const struct ble_store_key_sec *key_sec, *value_sec = ble_store_ram_our_secs[idx]; return 0; +#else + return BLE_HS_ENOENT; +#endif + } static int ble_store_ram_write_our_sec(const struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) struct ble_store_key_sec key_sec; int idx; @@ -157,9 +176,15 @@ ble_store_ram_write_our_sec(const struct ble_store_value_sec *value_sec) } ble_store_ram_our_secs[idx] = *value_sec; + return 0; +#else + return BLE_HS_ENOENT; +#endif + } +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) static int ble_store_ram_delete_obj(void *values, int value_size, int idx, int *num_values) @@ -202,10 +227,12 @@ ble_store_ram_delete_sec(const struct ble_store_key_sec *key_sec, return 0; } +#endif static int ble_store_ram_delete_our_sec(const struct ble_store_key_sec *key_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int rc; rc = ble_store_ram_delete_sec(key_sec, ble_store_ram_our_secs, @@ -213,13 +240,17 @@ ble_store_ram_delete_our_sec(const struct ble_store_key_sec *key_sec) if (rc != 0) { return rc; } - return 0; +#else + return BLE_HS_ENOENT; +#endif + } static int ble_store_ram_delete_peer_sec(const struct ble_store_key_sec *key_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int rc; rc = ble_store_ram_delete_sec(key_sec, ble_store_ram_peer_secs, @@ -227,14 +258,18 @@ ble_store_ram_delete_peer_sec(const struct ble_store_key_sec *key_sec) if (rc != 0) { return rc; } - return 0; +#else + return BLE_HS_ENOENT; +#endif + } static int ble_store_ram_read_peer_sec(const struct ble_store_key_sec *key_sec, struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) int idx; idx = ble_store_ram_find_sec(key_sec, ble_store_ram_peer_secs, @@ -245,11 +280,16 @@ ble_store_ram_read_peer_sec(const struct ble_store_key_sec *key_sec, *value_sec = ble_store_ram_peer_secs[idx]; return 0; +#else + return BLE_HS_ENOENT; +#endif + } static int ble_store_ram_write_peer_sec(const struct ble_store_value_sec *value_sec) { +#if MYNEWT_VAL(BLE_STORE_MAX_BONDS) struct ble_store_key_sec key_sec; int idx; @@ -272,12 +312,17 @@ ble_store_ram_write_peer_sec(const struct ble_store_value_sec *value_sec) ble_store_ram_peer_secs[idx] = *value_sec; return 0; +#else + return BLE_HS_ENOENT; +#endif + } /***************************************************************************** * $cccd * *****************************************************************************/ +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) static int ble_store_ram_find_cccd(const struct ble_store_key_cccd *key) { @@ -311,10 +356,12 @@ ble_store_ram_find_cccd(const struct ble_store_key_cccd *key) return -1; } +#endif static int ble_store_ram_delete_cccd(const struct ble_store_key_cccd *key_cccd) { +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) int idx; int rc; @@ -330,14 +377,18 @@ ble_store_ram_delete_cccd(const struct ble_store_key_cccd *key_cccd) if (rc != 0) { return rc; } - return 0; +#else + return BLE_HS_ENOENT; +#endif + } static int ble_store_ram_read_cccd(const struct ble_store_key_cccd *key_cccd, struct ble_store_value_cccd *value_cccd) { +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) int idx; idx = ble_store_ram_find_cccd(key_cccd); @@ -346,12 +397,17 @@ ble_store_ram_read_cccd(const struct ble_store_key_cccd *key_cccd, } *value_cccd = ble_store_ram_cccds[idx]; + return 0; +#else + return BLE_HS_ENOENT; +#endif } static int ble_store_ram_write_cccd(const struct ble_store_value_cccd *value_cccd) { +#if MYNEWT_VAL(BLE_STORE_MAX_CCCDS) struct ble_store_key_cccd key_cccd; int idx; @@ -370,6 +426,10 @@ ble_store_ram_write_cccd(const struct ble_store_value_cccd *value_cccd) ble_store_ram_cccds[idx] = *value_cccd; return 0; +#else + return BLE_HS_ENOENT; +#endif + }