mesh: simplify mesh_transport_key_iterator

This commit is contained in:
Matthias Ringwald 2019-04-25 22:11:12 +02:00
parent 0cdba057f6
commit 7f00ba15e4
2 changed files with 7 additions and 8 deletions

View File

@ -201,13 +201,17 @@ mesh_transport_key_iterator_init(mesh_transport_key_iterator_t *it, uint16_t net
it->netkey_index = netkey_index;
it->aid = aid;
it->akf = akf;
it->first = 1;
it->key = NULL;
if (it->akf){
it->key = NULL;
} else {
it->key = &mesh_transport_device_key;
}
}
int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){
if (it->akf == 0){
return it->first;
return it->key != NULL;
}
// find next matching key
while (1){
@ -219,10 +223,6 @@ int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){
}
const mesh_transport_key_t * mesh_transport_key_iterator_get_next(mesh_transport_key_iterator_t *it){
if (it->akf == 0) {
it->first = 0;
return &mesh_transport_device_key;
}
mesh_transport_key_t * key = it->key;
it->key = NULL;
return key;

View File

@ -104,7 +104,6 @@ typedef struct {
uint16_t netkey_index;
uint8_t akf;
uint8_t aid;
uint8_t first;
} mesh_transport_key_iterator_t;
/**