Skip to content

Commit

Permalink
le_device_db: add le_device_db_max_count() for index iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
mringwal committed Mar 15, 2018
1 parent 1882d12 commit 6fc9dda
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions platform/posix/le_device_db_fs.c
Expand Up @@ -260,6 +260,10 @@ int le_device_db_count(void){
return counter;
}

int le_device_db_max_count(void){
return LE_DEVICE_MEMORY_SIZE;
}

// free device
void le_device_db_remove(int index){
le_devices[index].addr_type = INVALID_ENTRY_ADDR_TYPE;
Expand Down
4 changes: 4 additions & 0 deletions platform/wiced/le_device_db_wiced_dct.c
Expand Up @@ -191,6 +191,10 @@ int le_device_db_count(void){
return counter;
}

int le_device_db_max_count(void){
return NVM_NUM_LE_DEVICES;
}

// get device information: addr type and address
void le_device_db_info(int device_index, int * addr_type, bd_addr_t addr, sm_key_t irk){
int absolute_index = le_device_db_get_absolute_index_for_device_index(device_index);
Expand Down
8 changes: 7 additions & 1 deletion src/ble/le_device_db.h
Expand Up @@ -84,11 +84,17 @@ void le_device_db_set_local_bd_addr(bd_addr_t bd_addr);
int le_device_db_add(int addr_type, bd_addr_t addr, sm_key_t irk);

/**
* @brief get number of devices in db for enumeration
* @brief get number of devices in db
* @returns number of device in db
*/
int le_device_db_count(void);

/**
* @brief get max number of devices in db for enumeration
* @returns max number of device in db
*/
int le_device_db_max_count(void);

/**
* @brief get device information: addr type and address needed to identify device
* @param index
Expand Down
4 changes: 4 additions & 0 deletions src/ble/le_device_db_memory.c
Expand Up @@ -106,6 +106,10 @@ int le_device_db_count(void){
return counter;
}

int le_device_db_max_count(void){
return MAX_NR_LE_DEVICE_DB_ENTRIES;
}

// free device
void le_device_db_remove(int index){
le_devices[index].addr_type = INVALID_ENTRY_ADDR_TYPE;
Expand Down
4 changes: 4 additions & 0 deletions src/ble/le_device_db_tlv.c
Expand Up @@ -170,6 +170,10 @@ int le_device_db_count(void){
return num_valid_entries;
}

int le_device_db_max_count(void){
return NVM_NUM_DEVICE_DB_ENTRIES;
}

void le_device_db_remove(int index){
// delete entry in TLV
le_device_db_tlv_delete(index);
Expand Down

0 comments on commit 6fc9dda

Please sign in to comment.