Add new nimble service in wifi_provisioning example.

CKiamy
Posts: 19
Joined: Wed Nov 23, 2022 3:01 pm

Add new nimble service in wifi_provisioning example.

Postby CKiamy » Tue Dec 20, 2022 7:21 am

Hello everyone!

I am using the wifi_provisioning example provided by espressif for my application. I am planning to use some ble/nimble functionalities while the wifi provisioning service is active and waiting for a connection. I have used the additional endpoint functionality the example provides:
  1. wifi_prov_mgr_init(config);
  2. wifi_prov_mgr_endpoint_create("custom-endpoint");
  3. wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key);
  4. wifi_prov_mgr_endpoint_register("custom-endpoint", custom_ep_handler, custom_ep_data);
However this is not flexible enough for the application. It is better if an extra service with its own function flow. One thing I have tried is using one of this endpoints, and write a byte into it. If the callback custom_ep_handler detects a certain byte, it kills the wifi provisioning and starts another nimble application.
  1. esp_err_t echo_req_handler (uint32_t session_id,
  2.                             const uint8_t *inbuf, ssize_t inlen,
  3.                             uint8_t **outbuf, ssize_t *outlen,
  4.                             void *priv_data)
  5. {
  6.    
  7.     if(*inbuf = certain_byte){
  8.           wifi_prov_mgr_deinit();
  9.           start_other_nimble_application();
  10. }
  11.     return ESP_OK;
  12. }
However this obviously kills the connection with the phone, which is not ideal. Is there a way to add an extra primary service to this wifi prov example without ruining its functionality?

Who is online

Users browsing this forum: benrank, Google [Bot] and 134 guests