From 0e329b411b892f0756d8e56421a956de874837f9 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 11 Jul 2019 15:20:50 +0200 Subject: [PATCH] mesh: add mesh_node to collect node state --- test/mesh/Makefile | 1 + test/mesh/mesh_access.c | 6 +++- test/mesh/mesh_node.c | 50 +++++++++++++++++++++++++++++++++ test/mesh/mesh_node.h | 62 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 test/mesh/mesh_node.c create mode 100644 test/mesh/mesh_node.h diff --git a/test/mesh/Makefile b/test/mesh/Makefile index e6be08324..2877421e7 100644 --- a/test/mesh/Makefile +++ b/test/mesh/Makefile @@ -19,6 +19,7 @@ CORE += \ hci_transport_h4.c \ btstack_tlv_posix.c \ mesh_iv_index_seq_number.c \ + mesh_node.c \ le_device_db_fs.c \ l2cap.c \ uECC.c \ diff --git a/test/mesh/mesh_access.c b/test/mesh/mesh_access.c index a44b794ea..aaa6c6cf2 100644 --- a/test/mesh/mesh_access.c +++ b/test/mesh/mesh_access.c @@ -49,6 +49,7 @@ #include "btstack_tlv.h" #include "mesh_iv_index_seq_number.h" #include "mesh_proxy.h" +#include "mesh_node.h" #define MEST_TRANSACTION_TIMEOUT_MS 6000 @@ -1755,12 +1756,15 @@ static void mesh_access_secure_network_beacon_handler(uint8_t packet_type, uint1 } void mesh_access_setup_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){ - // set unicast address + // set unicast address - old mesh_network_set_primary_element_address(provisioning_data->unicast_address); mesh_lower_transport_set_primary_element_address(provisioning_data->unicast_address); mesh_upper_transport_set_primary_element_address(provisioning_data->unicast_address); mesh_access_set_primary_element_address(provisioning_data->unicast_address); primary_element_address = provisioning_data->unicast_address; + // set unicast address - new + mesh_node_primary_element_address_set(provisioning_data->unicast_address); + // set device_key mesh_transport_set_device_key(provisioning_data->device_key); diff --git a/test/mesh/mesh_node.c b/test/mesh/mesh_node.c new file mode 100644 index 000000000..d5ad577ed --- /dev/null +++ b/test/mesh/mesh_node.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2019 BlueKitchen GmbH + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * 4. Any redistribution, use, or modification is done solely for + * personal benefit and not for any commercial purpose or for + * monetary gain. + * + * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS + * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Please inquire about commercial licensing options at + * contact@bluekitchen-gmbh.com + * + */ + +#define __BTSTACK_FILE__ "mesh_node.c" + +#include "mesh_node.h" + +static uint16_t primary_element_address; + +void mesh_node_primary_element_address_set(uint16_t unicast_address){ + primary_element_address = unicast_address; +} + +uint16_t mesh_node_primary_element_address_get(void){ + return primary_element_address; +} diff --git a/test/mesh/mesh_node.h b/test/mesh/mesh_node.h new file mode 100644 index 000000000..633599d6c --- /dev/null +++ b/test/mesh/mesh_node.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2019 BlueKitchen GmbH + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * 4. Any redistribution, use, or modification is done solely for + * personal benefit and not for any commercial purpose or for + * monetary gain. + * + * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS + * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Please inquire about commercial licensing options at + * contact@bluekitchen-gmbh.com + * + */ + +#ifndef __MESH_NODE_H +#define __MESH_NODE_H + +#if defined __cplusplus +extern "C" { +#endif + +#include + +/** + * @brief Set unicast address of primary element + * @param unicast_address + */ +void mesh_node_primary_element_address_set(uint16_t unicast_address); + +/** + * @brief Get unicast address of primary element + */ +uint16_t mesh_node_primary_element_address_get(void); + +#if defined __cplusplus +} +#endif + +#endif //__MESH_NODE_H