From cc2a5f42a2b7b74490bf7dcb95cc47974a63204d Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 6 Dec 2019 09:25:36 +0100 Subject: [PATCH] mesh: add skeleton files for mesh_configuration_client --- example/Makefile.inc | 1 + src/btstack.h | 1 + src/mesh/mesh_configuration_client.c | 64 ++++++++++++++++++++++++++++ src/mesh/mesh_configuration_client.h | 62 +++++++++++++++++++++++++++ test/mesh/mesh_pts.c | 23 ++++++++++ 5 files changed, 151 insertions(+) create mode 100644 src/mesh/mesh_configuration_client.c create mode 100644 src/mesh/mesh_configuration_client.h diff --git a/example/Makefile.inc b/example/Makefile.inc index bbbd4d5a5..051340619 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -138,6 +138,7 @@ MESH = \ gatt_bearer.c \ mesh.c \ mesh_access.c \ + mesh_configuration_client.c \ mesh_configuration_server.c \ mesh_crypto.c \ mesh_foundation.c \ diff --git a/src/btstack.h b/src/btstack.h index a7fd3a059..8047fad86 100644 --- a/src/btstack.h +++ b/src/btstack.h @@ -139,6 +139,7 @@ #include "mesh/gatt_bearer.h" #include "mesh/mesh.h" #include "mesh/mesh_access.h" +#include "mesh/mesh_configuration_client.h" #include "mesh/mesh_configuration_server.h" #include "mesh/mesh_crypto.h" #include "mesh/mesh_foundation.h" diff --git a/src/mesh/mesh_configuration_client.c b/src/mesh/mesh_configuration_client.c new file mode 100644 index 000000000..225b752b1 --- /dev/null +++ b/src/mesh/mesh_configuration_client.c @@ -0,0 +1,64 @@ +/* + * 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_configuration_client.c" + +#include +#include + +#include "mesh/mesh_configuration_client.h" + +#include "bluetooth_company_id.h" +#include "btstack_debug.h" +#include "btstack_memory.h" +#include "btstack_util.h" + +#include "mesh/mesh_access.h" +#include "mesh/mesh_foundation.h" +#include "mesh/mesh_generic_model.h" +#include "mesh/mesh_keys.h" +#include "mesh/mesh_network.h" +#include "mesh/mesh_upper_transport.h" + + +void mesh_configuration_client_register_packet_handler(mesh_model_t *mesh_model, btstack_packet_handler_t configuration_packet_handler){ + btstack_assert(configuration_packet_handler != NULL); + btstack_assert(mesh_model != NULL); + + mesh_model->model_packet_handler = configuration_packet_handler; +} + diff --git a/src/mesh/mesh_configuration_client.h b/src/mesh/mesh_configuration_client.h new file mode 100644 index 000000000..967fdaac4 --- /dev/null +++ b/src/mesh/mesh_configuration_client.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_CONFIGURATION_CLIENT_H +#define __MESH_CONFIGURATION_CLIENT_H + +#include + +#include "mesh/mesh_access.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief Register packet handler + * @param configuration_client_model + * @param events_packet_handler + */ +void mesh_configuration_client_register_packet_handler(mesh_model_t *mesh_model, btstack_packet_handler_t events_packet_handler); + + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff --git a/test/mesh/mesh_pts.c b/test/mesh/mesh_pts.c index cc3927d25..280b42c1f 100644 --- a/test/mesh/mesh_pts.c +++ b/test/mesh/mesh_pts.c @@ -65,6 +65,8 @@ static mesh_model_t mesh_generic_level_server_model; static mesh_generic_level_state_t mesh_generic_level_state; static mesh_publication_model_t generic_level_server_publication; +static mesh_model_t mesh_configuration_client_model; + static char gap_name_buffer[30]; static char gap_name_prefix[] = "Mesh "; @@ -196,6 +198,7 @@ static void mesh_state_update_message_handler(uint8_t packet_type, uint16_t chan mesh_subevent_state_update_bool_get_value(packet)); break; default: + printf("mesh_state_update_message_handler: event not parsed"); break; } break; @@ -204,6 +207,21 @@ static void mesh_state_update_message_handler(uint8_t packet_type, uint16_t chan } } +static void mesh_configuration_message_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ + if (packet_type != HCI_EVENT_PACKET) return; + + switch(packet[0]){ + case HCI_EVENT_MESH_META: + switch(packet[2]){ + default: + printf("mesh_configuration_message_handler: event not parsed"); + break; + } + break; + default: + break; + } +} // PTS // helper network layer, temp @@ -651,6 +669,11 @@ int btstack_main(void) mesh_vendor_model.model_identifier = mesh_model_get_model_identifier(BLUETOOTH_COMPANY_ID_BLUEKITCHEN_GMBH, MESH_BLUEKITCHEN_MODEL_ID_TEST_SERVER); mesh_element_add_model(mesh_node_get_primary_element(), &mesh_vendor_model); + // Setup Configuration Client model + mesh_configuration_client_model.model_identifier = mesh_model_get_model_identifier_bluetooth_sig(MESH_SIG_MODEL_ID_GENERIC_LEVEL_SERVER); + mesh_configuration_client_register_packet_handler(&mesh_configuration_client_model, &mesh_configuration_message_handler); + mesh_element_add_model(mesh_node_get_primary_element(), &mesh_configuration_client_model); + // Enable PROXY mesh_foundation_gatt_proxy_set(1);