ESP32 BLE Mesh Sensor Client with multiple element

RahulSS
Posts: 2
Joined: Fri Sep 17, 2021 10:50 am

ESP32 BLE Mesh Sensor Client with multiple element

Postby RahulSS » Fri Sep 17, 2021 11:49 am

Hello Team,

I am using ESP32 and implementing BLE mesh network and example code i.e. BLE mesh sensor Client and Sensor Server.
To do so 3 ESP32 devices are configured as sensor server and each sensor server is consists of 4 elements. I could able to provision all the devices using nRF mobile application and could able to get all the data from all three servers for respective element we get GET command is sent from nRF application.

Now I have configured one ESP32 with sensor Client with provisioner enabled on client. Sensor client is also configured with elements, and server as sensor server with 4 elements.
With this setup Sensor Client is provisioning the the server device successfully. After this when is start to send get command by button press, i could able to get data only from 1st element of sensor server, rest all GET command are working like Get descriptor, Get sensor Setting.
Its seems that key getting bound to only 1st element of server, not getting bound to rest 3 elements.

Following are code snippets

1. Sensor Server Element Definition:-

Code: Select all

static esp_ble_mesh_elem_t elements[] = {
    ESP_BLE_MESH_ELEMENT(0, root_models, ESP_BLE_MESH_MODEL_NONE),
    ESP_BLE_MESH_ELEMENT(0, extend_model_2, ESP_BLE_MESH_MODEL_NONE),
	ESP_BLE_MESH_ELEMENT(0, extend_model_3, ESP_BLE_MESH_MODEL_NONE),
	ESP_BLE_MESH_ELEMENT(0, extend_model_4, ESP_BLE_MESH_MODEL_NONE),
};
2. Sensor Client:-

Code: Select all

static esp_ble_mesh_client_t config_client;
static esp_ble_mesh_client_t sensor_client;
static esp_ble_mesh_client_t fault;
static esp_ble_mesh_client_t config;
static esp_ble_mesh_client_t trip_log;

static esp_ble_mesh_model_t root_models[] = {
    ESP_BLE_MESH_MODEL_CFG_SRV(&config_server),
    ESP_BLE_MESH_MODEL_CFG_CLI(&config_client),
    ESP_BLE_MESH_MODEL_SENSOR_CLI(NULL, &sensor_client),
};

static esp_ble_mesh_model_t extend_model_1[] = {
		ESP_BLE_MESH_MODEL_SENSOR_CLI(NULL, &fault),
};

static esp_ble_mesh_model_t extend_model_2[] = {
		ESP_BLE_MESH_MODEL_SENSOR_CLI(NULL, &config),
};

static esp_ble_mesh_model_t extend_model_3[] = {
		ESP_BLE_MESH_MODEL_SENSOR_CLI(NULL, &trip_log),
};

static esp_ble_mesh_elem_t elements[] = {
    ESP_BLE_MESH_ELEMENT(0, root_models, ESP_BLE_MESH_MODEL_NONE),
	ESP_BLE_MESH_ELEMENT(0, extend_model_1, ESP_BLE_MESH_MODEL_NONE),
	ESP_BLE_MESH_ELEMENT(0, extend_model_2, ESP_BLE_MESH_MODEL_NONE),
	ESP_BLE_MESH_ELEMENT(0, extend_model_3, ESP_BLE_MESH_MODEL_NONE),
};
So question is how to get data from other elements of sensor server ?
It would be helpful to know how to or what configuration needs to be done to make it working.

Once this is working would like to make GET command work with multiple server also.

Thanks,
RahulSS

JialiangWang
Posts: 7
Joined: Sat Sep 18, 2021 6:22 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby JialiangWang » Sat Sep 18, 2021 7:50 am

Did you bound the app_key to the models of the rest 3 elements? If not, you need to bound it.

RahulSS
Posts: 2
Joined: Fri Sep 17, 2021 10:50 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby RahulSS » Mon Sep 20, 2021 4:40 am

Hi,
Thanks For Reply.

No i did not bound app to other elements, but could not find option to do it.
By default provisioner is binding app key to 1st element only.
Would like to know how to bind app key to other elements, what change need to done on client or server side ??

Thanks !

JialiangWang
Posts: 7
Joined: Sat Sep 18, 2021 6:22 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby JialiangWang » Wed Sep 22, 2021 6:31 am

For client side, you can use esp_ble_mesh_provisioner_bind_app_key_to_local_model(for detail, please refer to https://github.com/espressif/esp-idf/bl ... api.h#L377) function to bind the local app_key to the model.
For server side, client using esp_ble_mesh_config_client_set_state(for detail, please refer to https://github.com/espressif/esp-idf/bl ... api.h#L818) function to send `Config Model App Bind` message to server. When the server received the message that client sent, it will bind the app_key to the specific model.

Hope it helps you.

kg_lunar789
Posts: 4
Joined: Tue Nov 09, 2021 4:12 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby kg_lunar789 » Wed Nov 10, 2021 8:11 pm

I am also having the same issue as OP and could use some clarification on your answer.
The function esp_ble_mesh_provisioner_bind_app_key_to_local_model is called in the client provisioning callback, does this need to be called each time we want to bind a node? so if we have 10 nodes, we need to bind a new node using this function? Also does that mean we need to have a prov_key.app_idx for each node? Right now it looks like there is just one on the client side.

For the second part, using the esp_ble_mesh_config_client_set_state function, this is called in the config client callback, so does that mean we need to call this function for each server node we have as well?

Thanks!

JialiangWang
Posts: 7
Joined: Sat Sep 18, 2021 6:22 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby JialiangWang » Thu Nov 11, 2021 6:46 am

Hi kg_lunar789,

If we have 10 nodes, for the client, you need only using the function esp_ble_mesh_provisioner_bind_app_key_to_local_model to bind app_key one times. but the client need to send `Config Model App Bind` message to the 10 nodes(if there have the server model) to bind app_key respectively by using esp_ble_mesh_config_client_set_state function.

Hope it can help you.

kg_lunar789
Posts: 4
Joined: Tue Nov 09, 2021 4:12 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby kg_lunar789 » Wed Nov 17, 2021 2:01 am

Hi,
Thanks for the reply! This definitely does help as I am very new to BLE mesh.

Since we have to send `Config Model App Bind` message using the esp_ble_mesh_config_client_set_state function, does that mean we need to have an array of esp_ble_mesh_client_common_param_t structures as well as set structure? I noticed that the esp_ble_mesh_config_client_set_state() function takes the address of the common and set structures, but I only see those structs being setup once. I am looking at the provisioner example as well for reference.
Your help is greatly appreciated!
-Kyle Garland

JialiangWang
Posts: 7
Joined: Sat Sep 18, 2021 6:22 am

Re: ESP32 BLE Mesh Sensor Client with multiple element

Postby JialiangWang » Fri Dec 31, 2021 6:14 am

Hi Kyle,

I am sorry to reply so late.

You are right that you need to fill the structures of esp_ble_mesh_client_common_param_t.

About the usage of esp_ble_mesh_config_client_set_state function, you can refer to the example of mesh(https://github.com/espressif/esp-idf/tr ... p_ble_mesh).

Hope it can help you.

Who is online

Users browsing this forum: No registered users and 46 guests