I cannot verify that a simple generic user property server model is receiving messages from a generic user property client model. Is this model functional? If so, can anyone please provide me with a working example? I'm new to the ESP-IDF framework, so please bear with me if this is a basic mistake!
Thank you!
local setup
Espressif IDF v1.6.2 extension on VSCode
ESP32-C3 chip
custom nRFMesh Provisioner app ( acts as both provisioner and sends the set unack message from a generic user property client model.)
troubleshooting steps taken
-used a BLE packet sniffer to verify the set unack message was being sent over the network
-debugged via JTAG/GDB to verify the server model had the intended user properties with read/write access
-programmed a Generic User Property Client Model on the same node (using the ESP-IDF framework) to send a get message[/list][/list]
relevant code snippets
- static esp_ble_mesh_gen_user_prop_srv_t prop_server = {
- .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
- .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
- .rsp_ctrl.status_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
- };
- ESP_BLE_MESH_MODEL_PUB_DEFINE(property_serv_pub, 2+3, ROLE_NODE);
- void fill_user_property_server_model(esp_ble_mesh_gen_user_prop_srv_t * usr_prop_serv_model, esp_ble_mesh_generic_property_t * properties, uint8_t properties_count){
- usr_prop_serv_model->properties = properties;
- usr_prop_serv_model->property_count = properties_count;
- }
- //NOTE: This function is never getting hit. Should I assume that this means that the server is not receiving messages?
- void generic_server_cb (esp_ble_mesh_generic_server_cb_event_t event,
- esp_ble_mesh_generic_server_cb_param_t *param){
- ESP_LOGI("RECEIVED_MSG_EVENT", "event 0x%02x, opcode 0x%04x, src 0x%04x, dst 0x%04x",
- event, param->ctx.recv_op, param->ctx.addr, param->ctx.recv_dst);
- }
- esp_ble_mesh_model_t secondary_models[] = {
- ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(&property_serv_pub, &prop_server)
- };
- esp_ble_mesh_elem_t elements[] = {
- ESP_BLE_MESH_ELEMENT(NO_DESCRIPTOR, root_models, ESP_BLE_MESH_MODEL_NONE),
- ESP_BLE_MESH_ELEMENT(NO_DESCRIPTOR, secondary_models, ESP_BLE_MESH_MODEL_NONE),
- };
- esp_err_t ble_mesh_init(esp_ble_mesh_generic_property_t * gen_usr_properties, uint8_t length_of_usr_properties) {
- fill_user_property_server_model(&prop_server, gen_usr_properties, length_of_usr_properties);
- esp_err_t err = ESP_OK;
- memcpy(dev_uuid + 2, esp_bt_dev_get_address(), 6);
- esp_ble_mesh_register_prov_callback(provisioning_callback);
- esp_ble_mesh_register_generic_server_callback(generic_server_cb);
- err = esp_ble_mesh_init(&provision, &composition);
- err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
- return err;
- }
- void app_main(void)
- {
- struct net_buf_simple *usr_property_role_buffer = NET_BUF_SIMPLE(2);
- net_buf_simple_init(usr_property_role_buffer, 0);
- uint8_t data = 0x01;
- net_buf_simple_add_mem(usr_property_role_buffer, &data, 1);
- esp_ble_mesh_generic_property_t *usr_property_role = (esp_ble_mesh_generic_property_t*)calloc(1, sizeof(esp_ble_mesh_generic_property_t));
- usr_property_role->id = 0x1111;
- usr_property_role->user_access = 0x03;
- usr_property_role->admin_access = 0x03;
- usr_property_role->manu_access = 0x03;
- usr_property_role->val = usr_property_role_buffer;
- esp_ble_mesh_generic_property_t properties[] = {
- *usr_property_role
- };
- err = ble_mesh_init(properties, 1);
- }