From 8d3c79571184157dd0027be728f99b5ea1a6d980 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 25 Apr 2019 21:35:49 +0200 Subject: [PATCH] mesh: appkey management - add/delete key to/from linked list --- test/mesh/mesh_keys.c | 9 +++++++++ test/mesh/mesh_keys.h | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/test/mesh/mesh_keys.c b/test/mesh/mesh_keys.c index fa53f814e..98724b2e4 100644 --- a/test/mesh/mesh_keys.c +++ b/test/mesh/mesh_keys.c @@ -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; diff --git a/test/mesh/mesh_keys.h b/test/mesh/mesh_keys.h index ab96e45af..02c87eba8 100644 --- a/test/mesh/mesh_keys.h +++ b/test/mesh/mesh_keys.h @@ -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