Hi All
I have successfully used the bluetooth mesh node example to communicate from the nRf iOS provisioning app to my device.
I'm able to provision the device, and set on/off states from the iOS app.
In my device, I've the following elements :
0- read only element
1- read only element
2- get/set/setunack element
I'm trying to modify the node example to add two elements so the app can both read the status of elements 0/1 as well as get/set the state of element 2. I'm not able to add the above element so far.
What I've done is as follow :
Define two models, one is get only, another is get/set
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_model_op_t onoff_op_get_only[] = { // JDS
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, 0},
// Each model operation struct array must use this terminator
// as the end tag of the operation uint.
ESP_BLE_MESH_MODEL_OP_END,
};
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_model_op_t onoff_op_get_set_setunack[] = {
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, 0},
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET, 2, 0},
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK, 2, 0},
// Each model operation struct array must use this terminator
// as the end tag of the operation uint.
ESP_BLE_MESH_MODEL_OP_END,
};
reference all models
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_model_t root_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&config_server),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op_get_only, &onoff_pub, &read_state[0]),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op_get_only, &onoff_pub, &read_state[1]),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op_get_set_setunack, &onoff_pub, &readSet_state[0]),
};
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_elem_t elements[] = {
ESP_BLE_MESH_ELEMENT(0, root_models, ESP_BLE_MESH_MODEL_NONE),
};
What I do not understand is how I can add more elements that are using the same model ? In the node example, the macro ESP_BLE_MESH_ELEMENT is linked to root_models, not to a single model.
So by doing the above, I'm not defining multiple elements but multiple models instead.
By the way, when debugging the above code, the get / set callbacks are no longer called.
Any help in defining multiple elements using similar models would be greatly appreciated.
Thanks
BLE Mesh: Multiple elements on a single device
Re: BLE Mesh: Multiple elements on a single device
Hi,jerome wrote: ↑Wed Feb 20, 2019 12:33 pmHi All
I have successfully used the bluetooth mesh node example to communicate from the nRf iOS provisioning app to my device.
I'm able to provision the device, and set on/off states from the iOS app.
In my device, I've the following elements :
0- read only element
1- read only element
2- get/set/setunack element
I'm trying to modify the node example to add two elements so the app can both read the status of elements 0/1 as well as get/set the state of element 2. I'm not able to add the above element so far.
What I've done is as follow :
Define two models, one is get only, another is get/set
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_model_op_t onoff_op_get_only[] = { // JDS
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, 0},
// Each model operation struct array must use this terminator
// as the end tag of the operation uint.
ESP_BLE_MESH_MODEL_OP_END,
};
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_model_op_t onoff_op_get_set_setunack[] = {
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, 0},
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET, 2, 0},
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK, 2, 0},
// Each model operation struct array must use this terminator
// as the end tag of the operation uint.
ESP_BLE_MESH_MODEL_OP_END,
};
reference all models
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_model_t root_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&config_server),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op_get_only, &onoff_pub, &read_state[0]),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op_get_only, &onoff_pub, &read_state[1]),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op_get_set_setunack, &onoff_pub, &readSet_state[0]),
};
///////////////////////////////////////////////////////////////////////////////////////////
static esp_ble_mesh_elem_t elements[] = {
ESP_BLE_MESH_ELEMENT(0, root_models, ESP_BLE_MESH_MODEL_NONE),
};
What I do not understand is how I can add more elements that are using the same model ? In the node example, the macro ESP_BLE_MESH_ELEMENT is linked to root_models, not to a single model.
So by doing the above, I'm not defining multiple elements but multiple models instead.
By the way, when debugging the above code, the get / set callbacks are no longer called.
Any help in defining multiple elements using similar models would be greatly appreciated.
Thanks
As per the Mesh spec says, the same model shall not exist in the same element. If you are going to define 3 Generic OnOff Server models, they should be put in 3 different elements. I have modified the demo and attach it as below:
Code: Select all
static esp_ble_mesh_model_op_t onoff_op[] = {
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, 0},
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET, 2, 0},
{ ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK, 2, 0},
/* Each model operation struct array must use this terminator
* as the end tag of the operation uint. */
ESP_BLE_MESH_MODEL_OP_END,
};
static esp_ble_mesh_model_t root_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&config_server),
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op,
&onoff_pub, &led_state[0]),
};
static esp_ble_mesh_model_t extend_model_0[] = {
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op,
&onoff_pub, &led_state[1]),
};
static esp_ble_mesh_model_t extend_model_1[] = {
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, onoff_op,
&onoff_pub, &led_state[2]),
};
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_0, ESP_BLE_MESH_MODEL_NONE),
ESP_BLE_MESH_ELEMENT(0, extend_model_1, ESP_BLE_MESH_MODEL_NONE),
};
Code: Select all
if (op->min_len > BLE_MESH_MAX_DATA_SIZE || op->param_cb != 0) {
--op;
LOG_ERROR("%s, Invalid model operation min_len = %d, or param callbak = 0x%x, the last valid opcode = 0x%x",
__func__, op->min_len, op->param_cb, op->opcode);
return;
}
Also recommend to use the Android nRF Mesh App, i found some bugs while using the iOS nRF Mesh App (version V 1.0.2).
Re: BLE Mesh: Multiple elements on a single device
Hi
Thanks for your prompt reply.
I’ll check this.
If my first two elements should support only the GET op, should I define a different model for those elements ?
Jerome
Thanks for your prompt reply.
I’ll check this.
If my first two elements should support only the GET op, should I define a different model for those elements ?
Jerome
Who is online
Users browsing this forum: Bing [Bot] and 69 guests