How do I go about this? What information do I need? The calls to
Code: Select all
esp_ble_mesh_server_model_send_msg()
Code: Select all
esp_ble_mesh_server_model_send_msg()
Code: Select all
esp_ble_mesh_msg_ctx_t test_ctx
Code: Select all
test_model = param->model;
test_ctx = param->ctx;
Code: Select all
void button2_msg(){
ESP_LOGI(TAG, "BUTTON 2 PRESS");
esp_err_t err = esp_ble_mesh_server_model_send_msg(test_model, &test_ctx,
ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS, 6, (uint8_t*)"Hello");
if (err) {
ESP_LOGE(TAG, "Send message failed (err %d)", err);
return;
}
}
Code: Select all
static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param)
{
switch (event) {
case ESP_BLE_MESH_MODEL_OPERATION_EVT:
if (param->model_operation.opcode == ESP_BLE_MESH_VND_MODEL_OP_SEND) {
uint16_t tid = *(uint16_t *)param->model_operation.msg;
test_ctx = *param->model_operation.ctx;
ESP_LOGI(TAG, "Recv 0x%06x, tid 0x%04x", param->model_operation.opcode, tid);
char *mydata = "TEST STRING PASSING";
ESP_LOGI(TAG, "NetKey Index: 0x%06x", param->model_operation.ctx->net_idx);
esp_err_t err = esp_ble_mesh_server_model_send_msg(&vnd_models[0],
param->model_operation.ctx, ESP_BLE_MESH_VND_MODEL_OP_STATUS,
strlen(mydata)+1, (uint8_t *)mydata);
if (err) {
ESP_LOGE(TAG, "Failed to send message 0x%06x", ESP_BLE_MESH_VND_MODEL_OP_STATUS);
}
}
break;
Code: Select all
void example_ble_mesh_send_vendor_message(bool resend)
{
esp_ble_mesh_msg_ctx_t ctx = {0};
uint32_t opcode;
esp_err_t err;
ctx.net_idx = prov_key.net_idx;
ctx.app_idx = prov_key.app_idx;
ctx.addr = store.server_addr;
ctx.send_ttl = MSG_SEND_TTL;
ctx.send_rel = MSG_SEND_REL;
opcode = ESP_BLE_MESH_VND_MODEL_OP_SEND;
if (resend == false) {
store.vnd_tid++;
}
err = esp_ble_mesh_client_model_send_msg(vendor_client.model, &ctx, opcode,
sizeof(store.vnd_tid), (uint8_t *)&store.vnd_tid, MSG_TIMEOUT, true, MSG_ROLE);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to send vendor message 0x%06x", opcode);
return;
}
mesh_example_info_store(); /* Store proper mesh example info */
}
Code: Select all
void button_cb_msg(){
char *mydata = "TEST STRING PASSING";
esp_err_t err = esp_ble_mesh_server_model_send_msg(&vnd_models[0],
&test_ctx, ESP_BLE_MESH_VND_MODEL_OP_STATUS,
strlen(mydata)+1, (uint8_t *)mydata);
if (err) {
ESP_LOGE(TAG, "Failed to send message 0x%06x", ESP_BLE_MESH_VND_MODEL_OP_STATUS);
}
}
Users browsing this forum: No registered users and 82 guests