mesh: add general mesh_network_key_iterator

This commit is contained in:
Matthias Ringwald 2019-04-23 19:17:55 +02:00
parent 1f32e0a720
commit a4f63a5f4d
2 changed files with 36 additions and 3 deletions

View File

@ -74,6 +74,19 @@ const mesh_network_key_t * mesh_network_key_list_get(uint16_t netkey_index){
return NULL;
}
// mesh network key iterator over all keys
void mesh_network_key_iterator_init(mesh_network_key_iterator_t *it){
btstack_linked_list_iterator_init(&it->it, &network_keys);
}
int mesh_network_key_iterator_has_more(mesh_network_key_iterator_t *it){
return btstack_linked_list_iterator_has_next(&it->it);
}
const mesh_network_key_t * mesh_network_key_iterator_get_next(mesh_network_key_iterator_t *it){
return (mesh_network_key_t *) btstack_linked_list_iterator_next(&it->it);
}
// mesh network key iterator for a given nid
void mesh_network_key_nid_iterator_init(mesh_network_key_iterator_t *it, uint8_t nid){
btstack_linked_list_iterator_init(&it->it, &network_keys);

View File

@ -135,21 +135,41 @@ const mesh_network_key_t * mesh_network_key_list_get(uint16_t netkey_index);
void mesh_network_key_list_add_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data);
/**
*
* @brief Iterate over all network keys
* @param it
*/
void mesh_network_key_iterator_init(mesh_network_key_iterator_t *it);
/**
* Check if another network_key is available
* @param it
* @return
*/
int mesh_network_key_iterator_has_more(mesh_network_key_iterator_t *it);
/**
* Get net network_key
* @param it
* @return
*/
const mesh_network_key_t * mesh_network_key_iterator_get_next(mesh_network_key_iterator_t *it);
/**
* @brief Iterate over all network keys with a given NID
* @param it
* @param nid
*/
void mesh_network_key_nid_iterator_init(mesh_network_key_iterator_t *it, uint8_t nid);
/**
*
* Check if another network_key with given NID is available
* @param it
* @return
*/
int mesh_network_key_nid_iterator_has_more(mesh_network_key_iterator_t *it);
/**
*
* Get net network_key with given NID
* @param it
* @return
*/