Repository: incubator-mynewt-core Updated Branches: refs/heads/master b6914bf28 -> c7d7a0ebf
MYNEWT-754 BLE Host - cfgable RAM store capacity Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c2654f30 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c2654f30 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c2654f30 Branch: refs/heads/master Commit: c2654f308cb21b41653583b951fcdcd85bb17f4e Parents: 5ac0005 Author: Christopher Collins <[email protected]> Authored: Fri Apr 28 18:09:41 2017 -0700 Committer: Christopher Collins <[email protected]> Committed: Thu May 11 18:00:16 2017 -0700 ---------------------------------------------------------------------- net/nimble/host/store/ram/src/ble_store_ram.c | 21 ++++++++++----------- net/nimble/host/syscfg.yml | 11 +++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c2654f30/net/nimble/host/store/ram/src/ble_store_ram.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/store/ram/src/ble_store_ram.c b/net/nimble/host/store/ram/src/ble_store_ram.c index 4e018a9..387112c 100644 --- a/net/nimble/host/store/ram/src/ble_store_ram.c +++ b/net/nimble/host/store/ram/src/ble_store_ram.c @@ -27,21 +27,20 @@ #include <string.h> #include "sysinit/sysinit.h" +#include "syscfg/syscfg.h" #include "host/ble_hs.h" #include "store/ram/ble_store_ram.h" -/* XXX: This should be configurable. */ -#define STORE_MAX_SLV_LTKS 4 -#define STORE_MAX_MST_LTKS 4 -#define STORE_MAX_CCCDS 16 - -static struct ble_store_value_sec ble_store_ram_our_secs[STORE_MAX_SLV_LTKS]; +static struct ble_store_value_sec + ble_store_ram_our_secs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; static int ble_store_ram_num_our_secs; -static struct ble_store_value_sec ble_store_ram_peer_secs[STORE_MAX_MST_LTKS]; +static struct ble_store_value_sec + ble_store_ram_peer_secs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)]; static int ble_store_ram_num_peer_secs; -static struct ble_store_value_cccd ble_store_ram_cccds[STORE_MAX_CCCDS]; +static struct ble_store_value_cccd + ble_store_ram_cccds[MYNEWT_VAL(BLE_STORE_MAX_CCCDS)]; static int ble_store_ram_num_cccds; /***************************************************************************** @@ -156,7 +155,7 @@ ble_store_ram_write_our_sec(struct ble_store_value_sec *value_sec) idx = ble_store_ram_find_sec(&key_sec, ble_store_ram_our_secs, ble_store_ram_num_our_secs); if (idx == -1) { - if (ble_store_ram_num_our_secs >= STORE_MAX_SLV_LTKS) { + if (ble_store_ram_num_our_secs >= MYNEWT_VAL(BLE_STORE_MAX_BONDS)) { BLE_HS_LOG(DEBUG, "error persisting our sec; too many entries " "(%d)\n", ble_store_ram_num_our_secs); return BLE_HS_ENOMEM; @@ -270,7 +269,7 @@ ble_store_ram_write_peer_sec(struct ble_store_value_sec *value_sec) idx = ble_store_ram_find_sec(&key_sec, ble_store_ram_peer_secs, ble_store_ram_num_peer_secs); if (idx == -1) { - if (ble_store_ram_num_peer_secs >= STORE_MAX_MST_LTKS) { + if (ble_store_ram_num_peer_secs >= MYNEWT_VAL(BLE_STORE_MAX_BONDS)) { BLE_HS_LOG(DEBUG, "error persisting peer sec; too many entries " "(%d)\n", ble_store_ram_num_peer_secs); return BLE_HS_ENOMEM; @@ -346,7 +345,7 @@ ble_store_ram_write_cccd(struct ble_store_value_cccd *value_cccd) ble_store_key_from_value_cccd(&key_cccd, value_cccd); idx = ble_store_ram_find_cccd(&key_cccd); if (idx == -1) { - if (ble_store_ram_num_cccds >= STORE_MAX_SLV_LTKS) { + if (ble_store_ram_num_cccds >= MYNEWT_VAL(BLE_STORE_MAX_CCCDS)) { BLE_HS_LOG(DEBUG, "error persisting cccd; too many entries (%d)\n", ble_store_ram_num_cccds); return BLE_HS_ENOMEM; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c2654f30/net/nimble/host/syscfg.yml ---------------------------------------------------------------------- diff --git a/net/nimble/host/syscfg.yml b/net/nimble/host/syscfg.yml index d7ffddb..a1dd1fe 100644 --- a/net/nimble/host/syscfg.yml +++ b/net/nimble/host/syscfg.yml @@ -314,3 +314,14 @@ syscfg.defs: description: > Enables advertising of Eddystone beacons. value: 1 + + # Store settings. + BLE_STORE_MAX_BONDS: + description: > + Number of bonds to persist before recycling old ones. + value: 4 + BLE_STORE_MAX_CCCDS: + description: > + Number of client characteristic configuration descriptors to + persist before recycling old ones. + value: 16
