Page 1 of 1

Generic User Property Server Model not receiving messages

Posted: Mon May 08, 2023 9:20 pm
by agurusami
description
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
  1. static esp_ble_mesh_gen_user_prop_srv_t prop_server = {
  2.     .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
  3.     .rsp_ctrl.set_auto_rsp =  ESP_BLE_MESH_SERVER_AUTO_RSP,
  4.     .rsp_ctrl.status_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
  5. };
  6.  
  7. ESP_BLE_MESH_MODEL_PUB_DEFINE(property_serv_pub, 2+3, ROLE_NODE);
  8.  
  9. 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){
  10.     usr_prop_serv_model->properties = properties;
  11.     usr_prop_serv_model->property_count = properties_count;
  12. }
  13.  
  14. //NOTE: This function is never getting hit. Should I assume that this means that the server is not receiving messages?
  15. void generic_server_cb (esp_ble_mesh_generic_server_cb_event_t event,
  16.                             esp_ble_mesh_generic_server_cb_param_t *param){
  17.     ESP_LOGI("RECEIVED_MSG_EVENT", "event 0x%02x, opcode 0x%04x, src 0x%04x, dst 0x%04x",
  18.         event, param->ctx.recv_op, param->ctx.addr, param->ctx.recv_dst);
  19. }

  1. esp_ble_mesh_model_t secondary_models[] = {
  2.     ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(&property_serv_pub, &prop_server)
  3. };
  4. esp_ble_mesh_elem_t elements[] = {
  5.     ESP_BLE_MESH_ELEMENT(NO_DESCRIPTOR, root_models, ESP_BLE_MESH_MODEL_NONE),
  6.     ESP_BLE_MESH_ELEMENT(NO_DESCRIPTOR, secondary_models, ESP_BLE_MESH_MODEL_NONE),
  7. };
  8.  
  9. esp_err_t ble_mesh_init(esp_ble_mesh_generic_property_t * gen_usr_properties, uint8_t length_of_usr_properties) {
  10.     fill_user_property_server_model(&prop_server, gen_usr_properties, length_of_usr_properties);
  11.     esp_err_t err = ESP_OK;
  12.     memcpy(dev_uuid + 2, esp_bt_dev_get_address(), 6);
  13.     esp_ble_mesh_register_prov_callback(provisioning_callback);
  14.     esp_ble_mesh_register_generic_server_callback(generic_server_cb);
  15.     err = esp_ble_mesh_init(&provision, &composition);
  16.     err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
  17.     return err;
  18. }
  19.  
  20. void app_main(void)
  21. {  
  22.     struct net_buf_simple *usr_property_role_buffer = NET_BUF_SIMPLE(2);
  23.     net_buf_simple_init(usr_property_role_buffer, 0);
  24.     uint8_t data = 0x01;
  25.     net_buf_simple_add_mem(usr_property_role_buffer, &data, 1);
  26.     esp_ble_mesh_generic_property_t *usr_property_role = (esp_ble_mesh_generic_property_t*)calloc(1, sizeof(esp_ble_mesh_generic_property_t));
  27.     usr_property_role->id = 0x1111;
  28.     usr_property_role->user_access = 0x03;
  29.     usr_property_role->admin_access = 0x03;
  30.     usr_property_role->manu_access = 0x03;
  31.     usr_property_role->val = usr_property_role_buffer;
  32.     esp_ble_mesh_generic_property_t properties[] = {
  33.         *usr_property_role
  34.     };
  35.     err = ble_mesh_init(properties, 1);
  36. }