ESP-BLE-MESH How to bind all the models received in composition data to the default AppKey?

Al_daespexplorer
Posts: 1
Joined: Thu Nov 02, 2023 3:12 am

ESP-BLE-MESH How to bind all the models received in composition data to the default AppKey?

Postby Al_daespexplorer » Thu Nov 02, 2023 3:43 am

Hi smart people,

I am very new to ble mesh networking, and I am playing with esp32s3-devkitc-1 boards. I reviewed the vendor_client/vendor_server and onoff_client/onoff_server examples provided by ESP as part of the ESP-IDF. I chose esp-idf framework over arduino framework. What I want to achieve is to be able to have three onoff servers (three leds connected to the board) and one vendor (customized) to disseminate string data from Node A (controlling the LED's) to Node B, the client, which happens to be the provisioner. I have spent several hours to find out how to bind the default app key to all the models (three onoff and one vendor), because the code seems to bind the app key only to one of the onoff models (the first onoff model in my model structure.) Here is the relevant part of the server code (node A) for you to have a better idea. Note that I created similar structure at the client (provisioner) node (Node B) and added the config_client as the second element of the root model:

Code: Select all

// controlling LED 1
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
static esp_ble_mesh_gen_onoff_srv_t onoff_led_1 = {
    .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
    .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
};

// controlling LED 2
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
static esp_ble_mesh_gen_onoff_srv_t onoff_led_2 = {
    .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
    .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
};

// controlling LED 3
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
static esp_ble_mesh_gen_onoff_srv_t onoff_led_3 = {
    .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
    .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
};

static esp_ble_mesh_model_op_t vnd_op[] = {
    ESP_BLE_MESH_MODEL_OP(ESP_BLE_MESH_VND_OP_SEND, 2),
    ESP_BLE_MESH_MODEL_OP_END,
};

static esp_ble_mesh_model_t vnd_models[] = {
    ESP_BLE_MESH_VENDOR_MODEL(CID_ESP, ESP_BLE_MESH_VND_MODEL_ID_SRV,
    vnd_op, NULL, NULL),
};

static esp_ble_mesh_model_t root_models[] = {
    ESP_BLE_MESH_MODEL_CFG_SRV(&config_server),
    ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_0, &onoff_led_1),
};

static esp_ble_mesh_model_t extended_model_1[] = {
    ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_1, &onoff_led_2),
};

static esp_ble_mesh_model_t extended_model_2[] = {
    ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(&onoff_pub_2, &onoff_led_3),
};

static esp_ble_mesh_elem_t elements[] = {
    ESP_BLE_MESH_ELEMENT(0, root_models, vnd_models),
    ESP_BLE_MESH_ELEMENT(0, extended_model_1, ESP_BLE_MESH_MODEL_NONE),
    ESP_BLE_MESH_ELEMENT(0, extended_model_2, ESP_BLE_MESH_MODEL_NONE), 
};
I suspected that after receiving composition data at Node B (provisioner) and parsing it, the combination of the model_id, company_id, and unicast_addr should be used to bind each and every model to the app key. Still, I don't even see this happening in any of the examples. To be fair, I couldn't find an example with more than one server (if we don't consider the mandatory config server).

Now, can anyone help me understand this and bind all models to the app key?

esp32besbar
Posts: 14
Joined: Fri Mar 17, 2023 3:29 pm

Re: ESP-BLE-MESH How to bind all the models received in composition data to the default AppKey?

Postby esp32besbar » Mon Nov 06, 2023 1:59 pm

Could you please send the code regarding the provisioning? It will be easier to help you if we can look at the code.

Who is online

Users browsing this forum: Baidu [Spider] and 167 guests