Merge branch 'bugfix/remove_get_modle_and_get_comp_api' into 'master'

ble_mesh:example:change the method of get model

See merge request espressif/esp-idf!18449
This commit is contained in:
Island 2022-10-24 19:41:59 +08:00
commit 310a18e59f
10 changed files with 132 additions and 181 deletions

View File

@ -1,5 +1,5 @@
set(srcs "ble_mesh_adapter.c"
"ble_mesh_cfg_srv_model.c"
"ble_mesh_model.c"
"ble_mesh_console_lib.c"
"ble_mesh_console_main.c"
"ble_mesh_console_system.c"

View File

@ -10,60 +10,69 @@
ble_mesh_performance_statistics_t test_perf_statistics;
ble_mesh_node_statistics_t ble_mesh_node_statistics;
esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id)
{
esp_ble_mesh_model_t *model = NULL;
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
ESP_BLE_MESH_MODEL_PUB_DEFINE(model_pub_config, 2 + 1, ROLE_NODE);
switch (model_id) {
case ESP_BLE_MESH_MODEL_ID_CONFIG_SRV:
model = &config_server_models[0];
break;
#if (CONFIG_BLE_MESH_CFG_CLI)
case ESP_BLE_MESH_MODEL_ID_CONFIG_CLI:
model = &gen_onoff_cli_models[1];
break;
#endif
case ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV:
model = &gen_onoff_srv_models[1];
break;
#if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
case ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI:
model = &gen_onoff_cli_models[2];
break;
#endif
case ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_CLI:
model = &test_perf_cli_models[0];
break;
case ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_SRV:
model = &test_perf_srv_models[0];
break;
}
return model;
}
static esp_ble_mesh_model_t srv_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_0, &onoff_server),
};
esp_ble_mesh_model_t vendor_srv_models[] = {
ESP_BLE_MESH_VENDOR_MODEL(CID_ESP, ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_SRV,
test_perf_srv_op, NULL, NULL),
};
static esp_ble_mesh_elem_t srv_elements[] = {
ESP_BLE_MESH_ELEMENT(0, srv_models, vendor_srv_models),
};
static esp_ble_mesh_comp_t srv_composition = {
.cid = CID_ESP,
.elements = srv_elements,
.element_count = ARRAY_SIZE(srv_elements),
};
//client models
esp_ble_mesh_model_t cli_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
ESP_BLE_MESH_MODEL_CFG_CLI(&cfg_cli),
ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI(&model_pub_config, &gen_onoff_cli),
ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_0, &onoff_server),
};
esp_ble_mesh_model_t vendor_cli_models[] = {
ESP_BLE_MESH_VENDOR_MODEL(CID_ESP, ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_CLI,
test_perf_cli_op, &vendor_model_pub_config, &test_perf_cli),
};
static esp_ble_mesh_elem_t cli_elements[] = {
ESP_BLE_MESH_ELEMENT(0, cli_models, vendor_cli_models),
};
static esp_ble_mesh_comp_t cli_composition = {
.cid = CID_ESP,
.elements = cli_elements,
.element_count = ARRAY_SIZE(cli_elements),
};
esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id)
{
esp_ble_mesh_comp_t *comp = NULL;
switch (model_id) {
case ESP_BLE_MESH_MODEL_ID_CONFIG_SRV:
comp = &config_server_comp;
case ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV:
case ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_SRV:
comp = &srv_composition;
break;
case ESP_BLE_MESH_MODEL_ID_CONFIG_CLI:
comp = &config_client_comp;
break;
case ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV:
comp = &gen_onoff_srv_comp;
break;
#if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
case ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI:
comp = &gen_onoff_cli_comp;
break;
#endif
case ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_CLI:
comp = &test_perf_cli_comp;
comp = &cli_composition;
break;
case ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_SRV:
comp = &test_perf_srv_comp;
default:
break;
}
return comp;

View File

@ -11,7 +11,8 @@
#include "freertos/semphr.h"
#include "ble_mesh_console_lib.h"
#include "ble_mesh_cfg_srv_model.h"
#include "ble_mesh_model.h"
#include "esp_ble_mesh_local_data_operation_api.h"
#define TAG "ble_mesh_console"
@ -109,7 +110,6 @@ extern SemaphoreHandle_t ble_mesh_node_sema;
void ble_mesh_node_init(void);
void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_addr);
esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id);
esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id);
void ble_mesh_node_statistics_get(void);
int ble_mesh_node_statistics_accumulate(uint8_t *data, uint32_t value, uint16_t type);

View File

@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "ble_mesh_cfg_srv_model.h"
#include "esp_ble_mesh_generic_model_api.h"
#include "ble_mesh_model.h"
uint8_t dev_uuid[16] = {0xdd, 0xdd};
ble_mesh_node_config_params ble_mesh_node_prestore_params[NODE_MAX_GROUP_CONFIG];
@ -29,9 +28,8 @@ esp_ble_mesh_prov_t prov = {
};
esp_ble_mesh_model_pub_t vendor_model_pub_config;
ESP_BLE_MESH_MODEL_PUB_DEFINE(model_pub_config, 2 + 1, ROLE_NODE);
// configure server module
// Configuration server model
esp_ble_mesh_cfg_srv_t cfg_srv = {
.relay = ESP_BLE_MESH_RELAY_ENABLED,
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
@ -52,21 +50,7 @@ esp_ble_mesh_cfg_srv_t cfg_srv = {
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
};
esp_ble_mesh_model_t config_server_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
};
esp_ble_mesh_elem_t config_server_elements[] = {
ESP_BLE_MESH_ELEMENT(0, config_server_models, ESP_BLE_MESH_MODEL_NONE),
};
esp_ble_mesh_comp_t config_server_comp = {
.cid = CID_ESP,
.elements = config_server_elements,
.element_count = ARRAY_SIZE(config_server_elements),
};
// config client model
// Configuration Client model
esp_ble_mesh_client_t cfg_cli;
esp_ble_mesh_model_t config_client_models[] = {
@ -84,49 +68,15 @@ esp_ble_mesh_comp_t config_client_comp = {
.element_count = ARRAY_SIZE(config_client_elements),
};
// configure special model
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
static esp_ble_mesh_gen_onoff_srv_t onoff_server = {
// Generic OnOff Server model
esp_ble_mesh_gen_onoff_srv_t onoff_server = {
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
};
esp_ble_mesh_model_t gen_onoff_srv_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_0, &onoff_server),
};
esp_ble_mesh_elem_t gen_onoff_srv_elements[] = {
ESP_BLE_MESH_ELEMENT(0, gen_onoff_srv_models, ESP_BLE_MESH_MODEL_NONE),
};
esp_ble_mesh_comp_t gen_onoff_srv_comp = {
.cid = CID_ESP,
.elements = gen_onoff_srv_elements,
.element_count = ARRAY_SIZE(gen_onoff_srv_elements),
};
// config generic onoff client
// Generic OnOff Client model
#if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
esp_ble_mesh_client_t gen_onoff_cli;
esp_ble_mesh_model_t gen_onoff_cli_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
ESP_BLE_MESH_MODEL_CFG_CLI(&cfg_cli),
ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI(&model_pub_config, &gen_onoff_cli),
ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_0, &onoff_server),
};
esp_ble_mesh_elem_t gen_onoff_cli_elements[] = {
ESP_BLE_MESH_ELEMENT(0, gen_onoff_cli_models, ESP_BLE_MESH_MODEL_NONE),
};
esp_ble_mesh_comp_t gen_onoff_cli_comp = {
.cid = CID_ESP,
.elements = gen_onoff_cli_elements,
.element_count = ARRAY_SIZE(gen_onoff_cli_elements),
};
#endif //CONFIG_BLE_MESH_GENERIC_ONOFF_CLI
//CONFIG VENDOR MODEL TEST PERFORMANCE
@ -165,33 +115,3 @@ esp_ble_mesh_model_t config_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
ESP_BLE_MESH_MODEL_CFG_CLI(&cfg_cli),
};
esp_ble_mesh_model_t test_perf_cli_models[] = {
ESP_BLE_MESH_VENDOR_MODEL(CID_ESP, ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_CLI,
test_perf_cli_op, &vendor_model_pub_config, &test_perf_cli),
};
esp_ble_mesh_elem_t test_perf_cli_elements[] = {
ESP_BLE_MESH_ELEMENT(0, config_models, test_perf_cli_models),
};
esp_ble_mesh_comp_t test_perf_cli_comp = {
.cid = CID_ESP,
.elements = test_perf_cli_elements,
.element_count = ARRAY_SIZE(test_perf_cli_elements),
};
esp_ble_mesh_model_t test_perf_srv_models[] = {
ESP_BLE_MESH_VENDOR_MODEL(CID_ESP, ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_SRV,
test_perf_srv_op, NULL, NULL),
};
esp_ble_mesh_elem_t test_perf_srv_elements[] = {
ESP_BLE_MESH_ELEMENT(0, config_models, test_perf_srv_models),
};
esp_ble_mesh_comp_t test_perf_srv_comp = {
.cid = CID_ESP,
.elements = test_perf_srv_elements,
.element_count = ARRAY_SIZE(test_perf_srv_elements),
};

View File

@ -8,8 +8,9 @@
#define _BLE_MESH_CFG_SRV_MODEL_H_
#include "esp_ble_mesh_defs.h"
#if (CONFIG_BLE_MESH_CFG_CLI)
#include "esp_ble_mesh_config_model_api.h"
#endif
#if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
#include "esp_ble_mesh_generic_model_api.h"
#endif //CONFIG_BLE_MESH_GENERIC_ONOFF_CLI
@ -29,42 +30,26 @@ extern esp_ble_mesh_prov_t prov;
extern esp_ble_mesh_model_pub_t vendor_model_pub_config;
// configure server module
// Configuration Server model
extern esp_ble_mesh_cfg_srv_t cfg_srv;
extern esp_ble_mesh_model_t config_server_models[];
extern esp_ble_mesh_elem_t config_server_elements[];
extern esp_ble_mesh_comp_t config_server_comp;
// config client model
// Configuration Client model
extern esp_ble_mesh_client_t cfg_cli;
extern esp_ble_mesh_model_t config_client_models[];
extern esp_ble_mesh_elem_t config_client_elements[];
extern esp_ble_mesh_comp_t config_client_comp;
// configure special module
// Generic OnOff Server model
extern esp_ble_mesh_gen_onoff_srv_t onoff_server;
extern esp_ble_mesh_model_op_t gen_onoff_srv_model_op_config[];
extern esp_ble_mesh_model_t gen_onoff_srv_models[];
extern esp_ble_mesh_elem_t gen_onoff_srv_elements[];
extern esp_ble_mesh_comp_t gen_onoff_srv_comp;
// config generic onoff client
// Generic OnOff Client model
#if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
extern esp_ble_mesh_client_t gen_onoff_cli;
extern esp_ble_mesh_model_t gen_onoff_cli_models[];
extern esp_ble_mesh_elem_t gen_onoff_cli_elements[];
extern esp_ble_mesh_comp_t gen_onoff_cli_comp;
#endif //CONFIG_BLE_MESH_GENERIC_ONOFF_CLI
//CONFIG VENDOR MODEL TEST PERFORMANCE
@ -77,23 +62,17 @@ extern esp_ble_mesh_comp_t gen_onoff_cli_comp;
#define ESP_BLE_MESH_VND_MODEL_OP_TEST_PERF_STATUS ESP_BLE_MESH_MODEL_OP_3(0x04, CID_ESP)
extern esp_ble_mesh_client_t test_perf_cli;
extern esp_ble_mesh_model_op_t test_perf_srv_op[];
extern esp_ble_mesh_model_op_t test_perf_cli_op[];
extern esp_ble_mesh_model_t config_models[];
extern esp_ble_mesh_model_t test_perf_cli_models[];
extern esp_ble_mesh_elem_t test_perf_cli_elements[];
extern esp_ble_mesh_comp_t test_perf_cli_comp;
extern esp_ble_mesh_model_t test_perf_srv_models[];
extern esp_ble_mesh_elem_t test_perf_srv_elements[];
extern esp_ble_mesh_comp_t test_perf_srv_comp;
#if (CONFIG_BLE_MESH_CFG_CLI)
void ble_mesh_configuration_client_model_cb(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param);
#endif
#if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
void ble_mesh_generic_onoff_client_model_cb(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param);
#endif
#endif //_BLE_MESH_CFG_SRV_MODEL_H_

View File

@ -28,8 +28,6 @@ typedef struct {
ble_mesh_client_get_set_state_t configuration_client_model_operation;
void ble_mesh_register_configuration_client_model_command(void);
void ble_mesh_configuration_client_model_cb(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param);
void ble_mesh_register_configuration_client_model(void)
{
@ -208,6 +206,7 @@ void ble_mesh_configuration_client_model_cb(esp_ble_mesh_cfg_client_cb_event_t e
int ble_mesh_configuration_client_model_operation(int argc, char **argv)
{
int err = ESP_OK;
esp_ble_mesh_elem_t *element = NULL;
const uint8_t *app_key = NULL;
esp_ble_mesh_cfg_default_ttl_set_t ttl_set;
esp_ble_mesh_cfg_gatt_proxy_set_t proxy_set;
@ -239,7 +238,17 @@ int ble_mesh_configuration_client_model_operation(int argc, char **argv)
.company_id = 0xFFFF,
};
client_common.model = ble_mesh_get_model(ESP_BLE_MESH_MODEL_ID_CONFIG_CLI);
element = esp_ble_mesh_find_element(esp_ble_mesh_get_primary_element_address());
if (!element) {
ESP_LOGE(TAG, "Element 0x%04x not exists", esp_ble_mesh_get_primary_element_address());
return ESP_FAIL;
}
client_common.model = esp_ble_mesh_find_sig_model(element, ESP_BLE_MESH_MODEL_ID_CONFIG_CLI);
if (!client_common.model) {
ESP_LOGE(TAG, "CfgClient:LoadModel,Fail");
return ESP_FAIL;
}
ESP_LOGD(TAG, "enter %s \n", __func__);
@ -357,8 +366,6 @@ int ble_mesh_configuration_client_model_operation(int argc, char **argv)
err = esp_ble_mesh_config_client_set_state(&client_common, (esp_ble_mesh_cfg_client_set_state_t *)&heartbeat_pub_set);
}
}
} else if (strcmp(configuration_client_model_operation.action_type->sval[0], "reg") == 0) {
err = esp_ble_mesh_register_config_client_callback(ble_mesh_configuration_client_model_cb);
}
}

View File

@ -25,8 +25,6 @@ typedef struct {
static ble_mesh_gen_onoff_state_t gen_onoff_state;
void ble_mesh_register_gen_onoff_client_command(void);
void ble_mesh_generic_onoff_client_model_cb(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param);
void ble_mesh_register_gen_onoff_client(void)
{
@ -100,6 +98,7 @@ void ble_mesh_generic_onoff_client_model_cb(esp_ble_mesh_generic_client_cb_event
int ble_mesh_generic_onoff_client_model(int argc, char **argv)
{
int err = ESP_OK;
esp_ble_mesh_elem_t *element = NULL;
esp_ble_mesh_generic_client_set_state_t gen_client_set;
esp_ble_mesh_generic_client_get_state_t gen_client_get;
esp_ble_mesh_client_common_param_t onoff_common = {
@ -115,9 +114,16 @@ int ble_mesh_generic_onoff_client_model(int argc, char **argv)
return 1;
}
onoff_common.model = ble_mesh_get_model(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI);
if (onoff_common.model == NULL) {
element = esp_ble_mesh_find_element(esp_ble_mesh_get_primary_element_address());
if (!element) {
ESP_LOGE(TAG, "Element 0x%04x not exists", esp_ble_mesh_get_primary_element_address());
return ESP_FAIL;
}
onoff_common.model = esp_ble_mesh_find_sig_model(element, ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI);
if (!onoff_common.model) {
ESP_LOGI(TAG, "GenONOFFClient:LoadModel,Fail");
return ESP_FAIL;
}
arg_int_to_value(gen_onoff_state.appkey_idx, onoff_common.ctx.app_idx, "appkey_index");
@ -137,11 +143,6 @@ int ble_mesh_generic_onoff_client_model(int argc, char **argv)
}
else if (strcmp(gen_onoff_state.action_type->sval[0], "set") == 0) {
err = esp_ble_mesh_generic_client_set_state(&onoff_common, &gen_client_set);
} else if (strcmp(gen_onoff_state.action_type->sval[0], "reg") == 0) {
err = esp_ble_mesh_register_generic_client_callback(ble_mesh_generic_onoff_client_model_cb);
if (err == ESP_OK) {
ESP_LOGI(TAG, "GenONOFFClient:Reg,OK");
}
}
}
ESP_LOGD(TAG, "exit %s\n", __func__);

View File

@ -103,9 +103,11 @@ cleanup:
int ble_mesh_test_performance_client_model(int argc, char **argv)
{
esp_ble_mesh_elem_t *element = NULL;
esp_ble_mesh_model_t *model;
esp_err_t result = ESP_OK;
ble_mesh_test_perf_throughput_data *profile_data = NULL;
uint16_t company_id = CID_ESP;
ESP_LOGD(TAG, "enter %s\n", __func__);
int nerrors = arg_parse(argc, argv, (void **) &test_perf_client_model);
@ -114,12 +116,24 @@ int ble_mesh_test_performance_client_model(int argc, char **argv)
return 1;
}
model = ble_mesh_get_model(ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_CLI);
element = esp_ble_mesh_find_element(esp_ble_mesh_get_primary_element_address());
if (!element) {
ESP_LOGE(TAG, "Element 0x%04x not exists", esp_ble_mesh_get_primary_element_address());
return ESP_FAIL;
}
model = esp_ble_mesh_find_vendor_model(element, company_id, ESP_BLE_MESH_VND_MODEL_ID_TEST_PERF_CLI);
if (!model) {
ESP_LOGI(TAG, "VendorClient:LoadModel,Fail");
return ESP_FAIL;
}
if (strcmp(test_perf_client_model.action_type->sval[0], "init") == 0) {
result = esp_ble_mesh_client_model_init(model);
if (result == ESP_OK) {
ESP_LOGI(TAG, "VendorClientModel:Init,OK");
} else {
ESP_LOGE(TAG, "VendorClientModel:Init,Fail,%d", result);
}
} else if (strcmp(test_perf_client_model.action_type->sval[0], "start") == 0) {
profile_data = malloc(sizeof(ble_mesh_test_perf_throughput_data));

View File

@ -19,6 +19,7 @@
#include "transaction.h"
#include "esp_ble_mesh_config_model_api.h"
#include "ble_mesh_console_decl.h"
#include "ble_mesh_model.h"
typedef struct {
struct arg_str *static_val;
@ -145,6 +146,11 @@ typedef struct {
} ble_mesh_provisioner_heartbeat_t;
static ble_mesh_provisioner_heartbeat_t heartbeat;
extern void ble_mesh_generic_onoff_client_model_cb(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param);
extern void ble_mesh_configuration_client_model_cb(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param);
void ble_mesh_register_cmd(void);
// Register callback function
void ble_mesh_prov_cb(esp_ble_mesh_prov_cb_event_t event, esp_ble_mesh_prov_cb_param_t *param);
@ -165,6 +171,8 @@ int ble_mesh_register_cb(int argc, char** argv)
esp_ble_mesh_register_prov_callback(ble_mesh_prov_cb);
esp_ble_mesh_register_custom_model_callback(ble_mesh_model_cb);
esp_ble_mesh_register_generic_server_callback(ble_mesh_generic_server_model_cb);
esp_ble_mesh_register_generic_client_callback(ble_mesh_generic_onoff_client_model_cb);
esp_ble_mesh_register_config_client_callback(ble_mesh_configuration_client_model_cb);
ESP_LOGI(TAG, "Bm:Reg,OK");
ESP_LOGD(TAG, "exit %s\n", __func__);
return 0;

View File

@ -32,6 +32,7 @@ void ble_mesh_register_server(void)
int ble_mesh_module_publish_message(int argc, char **argv)
{
esp_err_t err;
esp_ble_mesh_elem_t *element = NULL;
esp_ble_mesh_model_t *model = NULL;
uint8_t *data = NULL;
uint8_t device_role = ROLE_NODE;
@ -49,7 +50,19 @@ int ble_mesh_module_publish_message(int argc, char **argv)
get_value_string((char *)msg_publish.data->sval[0], (char *) data);
arg_int_to_value(msg_publish.role, device_role, "device role");
model = ble_mesh_get_model(msg_publish.model->ival[0]);
element = esp_ble_mesh_find_element(esp_ble_mesh_get_primary_element_address());
if (!element) {
ESP_LOGE(TAG, "Element 0x%04x not exists", esp_ble_mesh_get_primary_element_address());
return ESP_FAIL;
}
model = esp_ble_mesh_find_sig_model(element, msg_publish.model->ival[0]);
if (!model) {
ESP_LOGE(TAG, "MsgPublishLoad Model Fail");
return ESP_FAIL;
}
if (msg_publish.role->count != 0) {
device_role = msg_publish.role->ival[0];
}