mesh: implement configuration client get beacon message [a2462]

This commit is contained in:
Milanka Ringwald 2019-12-06 11:18:20 +01:00
parent 2c060a94bb
commit aaf0c1d162
2 changed files with 94 additions and 6 deletions

View File

@ -55,10 +55,88 @@
#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;
static void mesh_configuration_client_send_message_acknowledged(uint16_t src, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, mesh_pdu_t *pdu, uint32_t ack_opcode){
uint8_t ttl = mesh_foundation_default_ttl_get();
mesh_upper_transport_setup_access_pdu_header(pdu, netkey_index, appkey_index, ttl, src, dest, 0);
mesh_access_send_acknowledged_pdu(pdu, mesh_access_acknowledged_message_retransmissions(), ack_opcode);
}
static uint8_t mesh_access_validate_envelop_params(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){
btstack_assert(mesh_model != NULL);
// TODO: validate other params
UNUSED(dest);
UNUSED(netkey_index);
UNUSED(appkey_index);
return ERROR_CODE_SUCCESS;
}
// Configuration client messages
static const mesh_access_message_t mesh_configuration_client_beacon_get = {
MESH_FOUNDATION_OPERATION_BEACON_GET, ""
};
#if 0
static const mesh_access_message_t mesh_configuration_client_beacon_set = {
MESH_FOUNDATION_OPERATION_BEACON_SET, "1"
};
static const mesh_access_message_t mesh_configuration_client_composition_data_get = {
MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_GET, "1"
};
static const mesh_access_message_t mesh_configuration_client_default_ttl_get = {
MESH_FOUNDATION_OPERATION_DEFAULT_TTL_GET, ""
};
static const mesh_access_message_t mesh_configuration_client_default_ttl_set = {
MESH_FOUNDATION_OPERATION_DEFAULT_TTL_SET, "1"
};
static const mesh_access_message_t mesh_configuration_client_gatt_proxy_get = {
MESH_FOUNDATION_OPERATION_GATT_PROXY_GET, ""
};
static const mesh_access_message_t mesh_configuration_client_gatt_proxy_set = {
MESH_FOUNDATION_OPERATION_GATT_PROXY_SET, "1"
};
static const mesh_access_message_t mesh_configuration_client_relay_get = {
MESH_FOUNDATION_OPERATION_RELAY_GET, ""
};
static const mesh_access_message_t mesh_configuration_client_relay_set = {
MESH_FOUNDATION_OPERATION_RELAY_SET, "11"
};
static const mesh_access_message_t mesh_configuration_client_publication_get = {
MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_GET, "2m"
};
static const mesh_access_message_t mesh_configuration_client_publication_set = {
MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_SET, "222111m"
};
static const mesh_access_message_t mesh_configuration_client_publication_virtual_address_set = {
MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_VIRTUAL_ADDRESS_SET, "2P2111m"
};
#endif
uint8_t mesh_configuration_send_message_client_config_beacon_get(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
if (status != ERROR_CODE_SUCCESS) return status;
mesh_network_pdu_t * network_pdu = mesh_access_setup_unsegmented_message(&mesh_configuration_client_beacon_get);
if (!network_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
mesh_configuration_client_send_message_acknowledged(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) network_pdu, MESH_FOUNDATION_OPERATION_BEACON_STATUS);
return ERROR_CODE_SUCCESS;;
}
void mesh_configuration_client_register_packet_handler(mesh_model_t *configuration_client_model, btstack_packet_handler_t events_packet_handler){
btstack_assert(events_packet_handler != NULL);
btstack_assert(configuration_client_model != NULL);
configuration_client_model->model_packet_handler = events_packet_handler;
}

View File

@ -52,7 +52,17 @@ extern "C"
* @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);
void mesh_configuration_client_register_packet_handler(mesh_model_t *configuration_client_model, btstack_packet_handler_t events_packet_handler);
/**
* @brief Get configuration beacon
* @param mesh_model
* @param dest
* @param netkey_index
* @param appkey_index
* @return status ERROR_CODE_SUCCESS if successful, otherwise BTSTACK_MEMORY_ALLOC_FAILED
*/
uint8_t mesh_configuration_send_message_client_config_beacon_get(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index);
#ifdef __cplusplus