Each device has a single vendor server. When the device state changes, any device is to publish a message to the all nodes address. The provisioner uses its configuration client to bind an app key to the servers on the other nodes, and also to set the publication address.
What I don't understand is what I need to do to get the provisioner device also publishing in exactly the same way. Here's what I've tried, extracted from the provisioner event handler:
- case ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT:
- ESP_LOGI(TAG,
- "ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT, "
- "err_code %d",
- param->provisioner_add_app_key_comp.err_code);
- if (param->provisioner_add_app_key_comp.err_code == 0)
- {
- prov_key.app_idx = param->provisioner_add_app_key_comp.app_idx;
- esp_err_t err =
- esp_ble_mesh_provisioner_bind_app_key_to_local_model(PROV_OWN_ADDR,
- prov_key
- .app_idx,
- MODEL_ID,
- COMPANY_ID);
- if (err != ESP_OK)
- {
- ESP_LOGE(TAG, "Failed to bind AppKey to vendor client");
- }
- }
- break;
- case ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT:
- ESP_LOGI(TAG,
- "ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT, "
- "err_code %d",
- param->provisioner_add_app_key_comp.err_code);
- if (param->provisioner_bind_app_key_to_model_comp.err_code == 0)
- {
- // Configure our local node to publish to 0xFFFF.
- myPub.publish_addr = 0xFFFF;
- myPub.retransmit = 0;
- myPub.ttl = 7;
- myPub.period = 0;
- myPub.app_idx =
- param->provisioner_bind_app_key_to_model_comp.app_idx;
- }
- break;
Why does publish care what role I'm in? Isn't it just sending a message?E (970394) BLE_MESH: bt_mesh_set_client_model_role, Invalid parameter
E (970394) BLE_MESH: btc_ble_mesh_model_call_handler, Failed to set model role
Any suggestions on getting this to work? I think I need to add the app key to the list of keys used when it publishes as a node, but I don't know how to do that locally (as opposed to using a configuration client on another node to set it up).