ble_mesh:example:change the method of get model

This commit is contained in:
Yuan Hong Hui 2022-06-09 17:04:52 +08:00 committed by BOT
parent 2fc0bb7b2a
commit fc82b36847
10 changed files with 137 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

@ -7,60 +7,72 @@
#include "esp_ble_mesh_networking_api.h"
#include "ble_mesh_adapter.h"
esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id)
{
esp_ble_mesh_model_t *model = NULL;
ble_mesh_performance_statistics_t test_perf_statistics;
ble_mesh_node_statistics_t ble_mesh_node_statistics;
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;
}
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);
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

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#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};
@ -36,9 +35,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,
@ -59,21 +57,9 @@ 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),
};
// Configuration Client model
esp_ble_mesh_client_t cfg_cli;
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
esp_ble_mesh_model_t config_client_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&cfg_srv),
ESP_BLE_MESH_MODEL_CFG_CLI(&cfg_cli),
@ -89,49 +75,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
@ -170,33 +122,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

@ -16,8 +16,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
@ -37,42 +38,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
esp_ble_mesh_client_t cfg_cli;
// 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
@ -85,23 +70,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

@ -33,8 +33,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)
{
@ -108,6 +106,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 = {
@ -123,9 +122,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");
@ -145,11 +151,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

@ -102,9 +102,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);
@ -113,12 +115,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

@ -18,6 +18,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;
@ -144,6 +145,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);
@ -164,6 +170,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

@ -40,6 +40,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;
@ -57,7 +58,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];
}