mesh: add skeleton files for mesh_configuration_client

This commit is contained in:
Milanka Ringwald 2019-12-06 09:25:36 +01:00
parent 04f45ea11b
commit cc2a5f42a2
5 changed files with 151 additions and 0 deletions

View File

@ -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 \

View File

@ -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"

View File

@ -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 <string.h>
#include <stdio.h>
#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;
}

View File

@ -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 <stdint.h>
#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

View File

@ -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);