Hey folks! Update on this matter, I was able to pass a string from a node to another by making a simple modification to the custom vendor model example (git patch below):
Code: Select all
diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c
index ef9afa98de..80e11833bb 100644
--- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c
+++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c
@@ -483,8 +483,10 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event
case ESP_BLE_MESH_MODEL_OPERATION_EVT:
if (param->model_operation.opcode == ESP_BLE_MESH_VND_MODEL_OP_STATUS) {
int64_t end_time = esp_timer_get_time();
- ESP_LOGI(TAG, "Recv 0x%06x, tid 0x%04x, time %lldus",
- param->model_operation.opcode, store.vnd_tid, end_time - start_time);
+ uint8_t *d = param->model_operation.msg;
+ char *levalue = (char *)d;
+ ESP_LOGI(TAG, "Recv 0x%06x, tid 0x%04x, time %lldus the string %s",
+ param->model_operation.opcode, store.vnd_tid, end_time - start_time, levalue);
}
break;
case ESP_BLE_MESH_MODEL_SEND_COMP_EVT:
diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c
index 4d4decff4f..10b67d2cb6 100644
--- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c
+++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c
@@ -157,10 +157,11 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t 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;
+ char *mydata = "TEST STRING PASSING";
ESP_LOGI(TAG, "Recv 0x%06x, tid 0x%04x", param->model_operation.opcode, tid);
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,
- sizeof(tid), (uint8_t *)&tid);
+ strlen(mydata)+1, (uint8_t *)mydata);
if (err) {
ESP_LOGE(TAG, "Failed to send message 0x%06x", ESP_BLE_MESH_VND_MODEL_OP_STATUS);
}
So, you can just press the button (GPIO 0, which should be the onboard button for most esp32 boards) in the client node, and you'll see the string "TEST STRING PASSING" in the console, that came from the server node.