Add more devices to sensor server example

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

Add more devices to sensor server example

Postby kg_lunar789 » Tue Nov 09, 2021 9:50 pm

Hi all,
I am working on the sensor client/server example and have successfully setup the project for 1 client and 1 server. I want to add another server node (1 client, 2 servers), and it looks like the second server node is provisioned correctly, but when I try to request data, one of the nodes responds with W (64289) BLE_MESH: No matching TX context for ack. I added a second set of ESP_BLE_MESH_MODEL_PUB_DEFINE() for sensor setup and sensor server and also added another model for the second node, but it still looks like I can't receive data from both of them. Here is the setup code for my application:

ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_pub, 20, ROLE_NODE);
static esp_ble_mesh_sensor_srv_t sensor_server = {
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.state_count = ARRAY_SIZE(sensor_states),
.states = sensor_states,
};

ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_setup_pub, 20, ROLE_NODE);
static esp_ble_mesh_sensor_setup_srv_t sensor_setup_server = {
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.state_count = ARRAY_SIZE(sensor_states),
.states = sensor_states,
};
//sensor node 2
ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_pub2, 20, ROLE_NODE);
static esp_ble_mesh_sensor_srv_t sensor_server2 = {
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.state_count = ARRAY_SIZE(sensor_states),
.states = sensor_states,
};

ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_setup_pub2, 20, ROLE_NODE);
static esp_ble_mesh_sensor_setup_srv_t sensor_setup_server2 = {
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
.state_count = ARRAY_SIZE(sensor_states),
.states = sensor_states,
};

static esp_ble_mesh_model_t root_models[] = {
ESP_BLE_MESH_MODEL_CFG_SRV(&config_server),
ESP_BLE_MESH_MODEL_SENSOR_SRV(&sensor_pub, &sensor_server),
ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(&sensor_setup_pub, &sensor_setup_server),
};

static esp_ble_mesh_model_t extend_models[] = {
ESP_BLE_MESH_MODEL_SENSOR_SRV(&sensor_pub2, &sensor_server2),
ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(&sensor_setup_pub2, &sensor_setup_server2),
};

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_models, ESP_BLE_MESH_MODEL_NONE),
};

static esp_ble_mesh_comp_t composition = {
.cid = CID_ESP,
.elements = elements,
.element_count = ARRAY_SIZE(elements),
};

static esp_ble_mesh_prov_t provision = {
.uuid = dev_uuid,
};

Looking at the logs, I can see unique addresses and id's for each sensor node, but i'm not sure the best way to use the main client node to request data from both of them. Currently the example says to click the boot button, which works for 1 node device, but doesn't work for 2+ node devices. What is the best plan of attack for this? I am trying to follow the ble_mesh_node example as well. Thanks for any assistance.

-Kyle Garland

Who is online

Users browsing this forum: No registered users and 226 guests