mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-05 21:59:45 +00:00
le_device_db_memory: make nr of entries configurable via MAX_NR_LE_DEVICE_DB_ENTRIES
This commit is contained in:
parent
eda85fbfc3
commit
22aa151238
@ -115,6 +115,7 @@ MAX_NR_RFCOMM_SERVICES | Max number of RFCOMM services
|
|||||||
MAX_NR_SERVICE_RECORD_ITEMS | Max number of SDP service records
|
MAX_NR_SERVICE_RECORD_ITEMS | Max number of SDP service records
|
||||||
MAX_NR_SM_LOOKUP_ENTRIES | Max number of items in Security Manager lookup queue
|
MAX_NR_SM_LOOKUP_ENTRIES | Max number of items in Security Manager lookup queue
|
||||||
MAX_NR_WHITELIST_ENTRIES | Max number of items in GAP LE Whitelist to connect to
|
MAX_NR_WHITELIST_ENTRIES | Max number of items in GAP LE Whitelist to connect to
|
||||||
|
MAX_NR_LE_DEVICE_DB_ENTRIES | Max number of items in LE Device DB
|
||||||
|
|
||||||
The memory is set up by calling *btstack_memory_init* function:
|
The memory is set up by calling *btstack_memory_init* function:
|
||||||
|
|
||||||
|
@ -32,4 +32,5 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
#endif
|
#endif
|
@ -145,7 +145,8 @@ echo "#define ENABLE_SDP_DES_DUMP" >> btstack_config.h
|
|||||||
echo >> btstack_config.h
|
echo >> btstack_config.h
|
||||||
|
|
||||||
echo "// BTstack configuration. buffers, sizes, .." >> btstack_config.h
|
echo "// BTstack configuration. buffers, sizes, .." >> btstack_config.h
|
||||||
echo "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack_config.h
|
echo "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack_config.h
|
||||||
|
echo "#define MAX_NR_LE_DEVICE_DB_ENTRIES 1" >> btstack_config.h
|
||||||
echo >> btstack_config.h
|
echo >> btstack_config.h
|
||||||
|
|
||||||
echo "// Daemon configuration" >> btstack_config.h
|
echo "// Daemon configuration" >> btstack_config.h
|
||||||
|
@ -34,5 +34,6 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// BTstack configuration. buffers, sizes, ...
|
// BTstack configuration. buffers, sizes, ...
|
||||||
#define HCI_ACL_PAYLOAD_SIZE 1021
|
#define HCI_ACL_PAYLOAD_SIZE 1021
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
// Daemon configuration
|
// Daemon configuration
|
||||||
#define BTSTACK_DEVICE_NAME_DB_INSTANCE btstack_device_name_db_corefoundation_instance
|
#define BTSTACK_DEVICE_NAME_DB_INSTANCE btstack_device_name_db_corefoundation_instance
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_SPP_CONNECTIONS 1
|
#define MAX_SPP_CONNECTIONS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 0
|
||||||
//
|
//
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
// BTstack configuration. buffers, sizes, ...
|
// BTstack configuration. buffers, sizes, ...
|
||||||
#define HCI_ACL_PAYLOAD_SIZE 1021
|
#define HCI_ACL_PAYLOAD_SIZE 1021
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
// Daemon configuration
|
// Daemon configuration
|
||||||
#define ENABLE_SDP
|
#define ENABLE_SDP
|
||||||
|
@ -31,5 +31,6 @@
|
|||||||
#define MAX_NR_BNEP_SERVICES 0
|
#define MAX_NR_BNEP_SERVICES 0
|
||||||
#define MAX_NR_BNEP_CHANNELS 0
|
#define MAX_NR_BNEP_CHANNELS 0
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -33,5 +33,6 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -34,5 +34,6 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -34,5 +34,6 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -35,6 +35,7 @@
|
|||||||
#define MAX_NR_WHITELIST_ENTRIES 1
|
#define MAX_NR_WHITELIST_ENTRIES 1
|
||||||
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
#define MAX_NR_SM_LOOKUP_ENTRIES 3
|
||||||
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
#define MAX_NR_SERVICE_RECORD_ITEMS 1
|
||||||
|
#define MAX_NR_LE_DEVICE_DB_ENTRIES 1
|
||||||
|
|
||||||
// Nun Link Keys stored in WICED DCT
|
// Nun Link Keys stored in WICED DCT
|
||||||
#define NVM_NUM_LINK_KEYS 10
|
#define NVM_NUM_LINK_KEYS 10
|
||||||
|
@ -72,14 +72,17 @@ typedef struct le_device_memory_db {
|
|||||||
|
|
||||||
} le_device_memory_db_t;
|
} le_device_memory_db_t;
|
||||||
|
|
||||||
#define LE_DEVICE_MEMORY_SIZE 4
|
|
||||||
#define INVALID_ENTRY_ADDR_TYPE 0xff
|
#define INVALID_ENTRY_ADDR_TYPE 0xff
|
||||||
|
|
||||||
static le_device_memory_db_t le_devices[LE_DEVICE_MEMORY_SIZE];
|
#ifndef MAX_NR_LE_DEVICE_DB_ENTRIES
|
||||||
|
#error "MAX_NR_LE_DEVICE_DB_ENTRIES not defined, please define in btstack_config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static le_device_memory_db_t le_devices[MAX_NR_LE_DEVICE_DB_ENTRIES];
|
||||||
|
|
||||||
void le_device_db_init(void){
|
void le_device_db_init(void){
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
|
||||||
le_device_db_remove(i);
|
le_device_db_remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +95,7 @@ void le_device_db_set_local_bd_addr(bd_addr_t bd_addr){
|
|||||||
int le_device_db_count(void){
|
int le_device_db_count(void){
|
||||||
int i;
|
int i;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
|
||||||
if (le_devices[i].addr_type != INVALID_ENTRY_ADDR_TYPE) counter++;
|
if (le_devices[i].addr_type != INVALID_ENTRY_ADDR_TYPE) counter++;
|
||||||
}
|
}
|
||||||
return counter;
|
return counter;
|
||||||
@ -106,7 +109,7 @@ void le_device_db_remove(int index){
|
|||||||
int le_device_db_add(int addr_type, bd_addr_t addr, sm_key_t irk){
|
int le_device_db_add(int addr_type, bd_addr_t addr, sm_key_t irk){
|
||||||
int i;
|
int i;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
|
||||||
if (le_devices[i].addr_type == INVALID_ENTRY_ADDR_TYPE){
|
if (le_devices[i].addr_type == INVALID_ENTRY_ADDR_TYPE){
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
@ -163,7 +166,7 @@ void le_device_db_encryption_get(int index, uint16_t * ediv, uint8_t rand[8], sm
|
|||||||
|
|
||||||
// get signature key
|
// get signature key
|
||||||
void le_device_db_remote_csrk_get(int index, sm_key_t csrk){
|
void le_device_db_remote_csrk_get(int index, sm_key_t csrk){
|
||||||
if (index < 0 || index >= LE_DEVICE_MEMORY_SIZE){
|
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
|
||||||
log_error("le_device_db_remote_csrk_get called with invalid index %d", index);
|
log_error("le_device_db_remote_csrk_get called with invalid index %d", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -171,7 +174,7 @@ void le_device_db_remote_csrk_get(int index, sm_key_t csrk){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void le_device_db_remote_csrk_set(int index, sm_key_t csrk){
|
void le_device_db_remote_csrk_set(int index, sm_key_t csrk){
|
||||||
if (index < 0 || index >= LE_DEVICE_MEMORY_SIZE){
|
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
|
||||||
log_error("le_device_db_remote_csrk_set called with invalid index %d", index);
|
log_error("le_device_db_remote_csrk_set called with invalid index %d", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -179,7 +182,7 @@ void le_device_db_remote_csrk_set(int index, sm_key_t csrk){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void le_device_db_local_csrk_get(int index, sm_key_t csrk){
|
void le_device_db_local_csrk_get(int index, sm_key_t csrk){
|
||||||
if (index < 0 || index >= LE_DEVICE_MEMORY_SIZE){
|
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
|
||||||
log_error("le_device_db_local_csrk_get called with invalid index %d", index);
|
log_error("le_device_db_local_csrk_get called with invalid index %d", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -187,7 +190,7 @@ void le_device_db_local_csrk_get(int index, sm_key_t csrk){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void le_device_db_local_csrk_set(int index, sm_key_t csrk){
|
void le_device_db_local_csrk_set(int index, sm_key_t csrk){
|
||||||
if (index < 0 || index >= LE_DEVICE_MEMORY_SIZE){
|
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
|
||||||
log_error("le_device_db_local_csrk_set called with invalid index %d", index);
|
log_error("le_device_db_local_csrk_set called with invalid index %d", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -219,7 +222,7 @@ void le_device_db_local_counter_set(int index, uint32_t counter){
|
|||||||
void le_device_db_dump(void){
|
void le_device_db_dump(void){
|
||||||
log_info("Central Device DB dump, devices: %d", le_device_db_count());
|
log_info("Central Device DB dump, devices: %d", le_device_db_count());
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
|
||||||
if (le_devices[i].addr_type == INVALID_ENTRY_ADDR_TYPE) continue;
|
if (le_devices[i].addr_type == INVALID_ENTRY_ADDR_TYPE) continue;
|
||||||
log_info("%u: %u %s", i, le_devices[i].addr_type, bd_addr_to_str(le_devices[i].addr));
|
log_info("%u: %u %s", i, le_devices[i].addr_type, bd_addr_to_str(le_devices[i].addr));
|
||||||
log_info_key("irk", le_devices[i].irk);
|
log_info_key("irk", le_devices[i].irk);
|
||||||
|
Loading…
Reference in New Issue
Block a user