From 39cd8755fb5f3f9b909ef8d05cb4132ca1b5825a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 12 Jul 2019 17:06:43 +0200 Subject: [PATCH] mesh: mesh_node_get_device_uuid returns NULL if not set --- src/mesh/mesh_node.c | 3 +++ src/mesh/mesh_node.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/mesh/mesh_node.c b/src/mesh/mesh_node.c index c325792e0..c395d404a 100644 --- a/src/mesh/mesh_node.c +++ b/src/mesh/mesh_node.c @@ -51,6 +51,7 @@ static uint16_t mesh_element_index_next; static btstack_linked_list_t mesh_elements; static uint8_t mesh_node_device_uuid[16]; +static int mesh_node_have_device_uuid; void mesh_node_primary_element_address_set(uint16_t unicast_address){ primary_element_address = unicast_address; @@ -117,12 +118,14 @@ mesh_element_t * mesh_element_iterator_next(mesh_element_iterator_t * iterator){ void mesh_node_set_device_uuid(const uint8_t * device_uuid){ memcpy(mesh_node_get_device_uuid, device_uuid, 16); + mesh_node_have_device_uuid = 1; } /** * @brief Get Device UUID */ const uint8_t * mesh_node_get_device_uuid(void){ + if (mesh_node_have_device_uuid == 0) return NULL; return mesh_node_device_uuid; } diff --git a/src/mesh/mesh_node.h b/src/mesh/mesh_node.h index 95b5b16e7..75a988c81 100644 --- a/src/mesh/mesh_node.h +++ b/src/mesh/mesh_node.h @@ -140,6 +140,7 @@ void mesh_node_set_device_uuid(const uint8_t * device_uuid); /** * @brief Get Device UUID + * @returns device_uuid if set, NULL otherwise */ const uint8_t * mesh_node_get_device_uuid(void);