mesh: appkey management - add/delete key to/from linked list

This commit is contained in:
Matthias Ringwald 2019-04-25 21:35:49 +02:00
parent 01e2bf9489
commit 8d3c795711
2 changed files with 28 additions and 0 deletions

View File

@ -153,6 +153,7 @@ void mesh_network_key_list_add_from_provisioning_data(const mesh_provisioning_da
// key management
static mesh_transport_key_t test_application_key;
static mesh_transport_key_t mesh_transport_device_key;
static btstack_linked_list_t application_keys;
void mesh_application_key_set(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key){
test_application_key.appkey_index = appkey_index;
@ -170,6 +171,14 @@ void mesh_transport_set_device_key(const uint8_t * device_key){
memcpy(mesh_transport_device_key.key, device_key, 16);
}
void mesh_transport_key_add(mesh_transport_key_t * transport_key){
btstack_linked_list_add(&application_keys, (btstack_linked_item_t *) transport_key);
}
int mesh_transport_key_remove(mesh_transport_key_t * transport_key){
return btstack_linked_list_remove(&application_keys, (btstack_linked_item_t *) transport_key);
}
const mesh_transport_key_t * mesh_transport_key_get(uint16_t appkey_index){
if (appkey_index == MESH_DEVICE_KEY_INDEX){
return &mesh_transport_device_key;

View File

@ -184,12 +184,31 @@ int mesh_network_key_nid_iterator_has_more(mesh_network_key_iterator_t *it);
*/
const mesh_network_key_t * mesh_network_key_nid_iterator_get_next(mesh_network_key_iterator_t *it);
/**
* Transport Keys = Application Keys + Device Key
*/
/**
* Set device key
* @param device_key
*/
void mesh_transport_set_device_key(const uint8_t * device_key);
/**
* @brief Add network key to list
* @param application key
* @note AID needs to be set
*/
void mesh_transport_key_add(mesh_transport_key_t * transport_key);
/**
* @brief Remove network key from list
* @param application key
* @return 0 if removed
* @note key is only removed from list, memory is not released
*/
int mesh_transport_key_remove(mesh_transport_key_t * transport_key);
/**
* Add Application Key
* @param appkey_index