Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation issue when Max Bonds or CCCD is set as 0 #1632

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nimble/host/src/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6106,6 +6106,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;
Expand Down Expand Up @@ -6138,6 +6139,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
Expand Down
3 changes: 2 additions & 1 deletion nimble/host/src/ble_store_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,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;
Expand All @@ -211,7 +212,7 @@ ble_store_util_delete_oldest_peer(void)
if (rc != 0) {
return rc;
}

#endif
return 0;
}

Expand Down
58 changes: 54 additions & 4 deletions nimble/host/store/config/src/ble_store_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,31 @@
#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;

/*****************************************************************************
* $sec *
*****************************************************************************/

#if MYNEWT_VAL(BLE_STORE_MAX_BONDS)
static void
ble_store_config_print_value_sec(const struct ble_store_value_sec *sec)
{
Expand All @@ -65,6 +74,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)
Expand All @@ -77,6 +87,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,
Expand All @@ -101,11 +112,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,
Expand All @@ -116,12 +129,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;
Expand Down Expand Up @@ -151,8 +168,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)
Expand Down Expand Up @@ -195,10 +217,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,
Expand All @@ -213,11 +237,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,
Expand All @@ -230,14 +258,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,
Expand All @@ -248,11 +279,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;
Expand Down Expand Up @@ -280,14 +316,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)
{
Expand Down Expand Up @@ -318,13 +357,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;

Expand All @@ -345,14 +385,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);
Expand All @@ -362,11 +405,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;
Expand All @@ -392,6 +439,9 @@ ble_store_config_write_cccd(const struct ble_store_value_cccd *value_cccd)
}

return 0;
#else
return BLE_HS_ENOENT;
#endif
}

/*****************************************************************************
Expand Down
Loading
Loading