ESP_BLE_MESH send message
Posted: Sat May 13, 2023 11:05 am
Hello everyone!
I would like to ask you for help with my BLE Mesh project.
My task is to create a Mesh network with the following topology:
* There are about 15 devices that read information from some sensor and once every N seconds send data (just a number from 0 to 300) to the main device. These devices should consume little power.
* There is ONE master device/gateway that needs to receive data from all other devices on the network and forward those messages to my android app. The master device also has an unlimited power supply.
* There are Relay devices that help to deliver messages from devices with sensors to the main device. These devices are in fixed locations and have an unlimited power supply.
I decided to build on the Vendor Model from the repository https://github.com/espressif/esp-idf/tr ... ndor_model, because it also distinguishes between the main device - Client and slave devices - Server, and also allows you to automate the provisioning process.
The problem is that the Servers in the Vendor Model example send messages to the Client only in response to a message from that very master inside the example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event, esp_ble_mesh_model_cb_param_t *param) callback. I need Servers to be able to send messages to Clients whenever they want.
To do this, I tried to move esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, uint16_t length, uint8_t *data) into a separate function, but I ran into the fact that in order to send a message to the Client, parameters such as param->model_operation.ctx are needed, which I can’t get anywhere except inside the example_ble_mesh_custom_model_cb callback.
I would like to ask for advice on choosing the right model, on how to send messages from the Servers to the Client considering my requirements, on how to receive messages on the Client side and on what functions to use for this.
Basically any implementation tips, code snippets or comments would be very helpful to me.
I would also be very grateful if you could answer my questions below:
1. How to make devices with sensors consume little power? Do I need to explicitly do something for this, or is it enough to disable Relay and send messages once in a limited amount of time?
2. Is it enough to change ESP_BLE_MESH_RELAY_DISABLED to ESP_BLE_MESH_RELAY_ENABLED to enable Relay?
3. Do I need to do provisioning every time I use the devices?
Thank you for reading to the end!
I would like to ask you for help with my BLE Mesh project.
My task is to create a Mesh network with the following topology:
* There are about 15 devices that read information from some sensor and once every N seconds send data (just a number from 0 to 300) to the main device. These devices should consume little power.
* There is ONE master device/gateway that needs to receive data from all other devices on the network and forward those messages to my android app. The master device also has an unlimited power supply.
* There are Relay devices that help to deliver messages from devices with sensors to the main device. These devices are in fixed locations and have an unlimited power supply.
I decided to build on the Vendor Model from the repository https://github.com/espressif/esp-idf/tr ... ndor_model, because it also distinguishes between the main device - Client and slave devices - Server, and also allows you to automate the provisioning process.
The problem is that the Servers in the Vendor Model example send messages to the Client only in response to a message from that very master inside the example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event, esp_ble_mesh_model_cb_param_t *param) callback. I need Servers to be able to send messages to Clients whenever they want.
To do this, I tried to move esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, uint16_t length, uint8_t *data) into a separate function, but I ran into the fact that in order to send a message to the Client, parameters such as param->model_operation.ctx are needed, which I can’t get anywhere except inside the example_ble_mesh_custom_model_cb callback.
I would like to ask for advice on choosing the right model, on how to send messages from the Servers to the Client considering my requirements, on how to receive messages on the Client side and on what functions to use for this.
Basically any implementation tips, code snippets or comments would be very helpful to me.
I would also be very grateful if you could answer my questions below:
1. How to make devices with sensors consume little power? Do I need to explicitly do something for this, or is it enough to disable Relay and send messages once in a limited amount of time?
2. Is it enough to change ESP_BLE_MESH_RELAY_DISABLED to ESP_BLE_MESH_RELAY_ENABLED to enable Relay?
3. Do I need to do provisioning every time I use the devices?
Thank you for reading to the end!