WiFi + Provision working simultaneously

daviherc
Posts: 10
Joined: Wed Apr 28, 2021 5:31 pm

WiFi + Provision working simultaneously

Postby daviherc » Wed Apr 28, 2021 5:35 pm

Hello all,

I'd like my ESP32 to be open to new network configurations while connected to the internet. My situation is that the ESP32 should sometimes switch from one WiFi network to another through user input.

Currently, I can set the ESP32 to connect to the first network through the WiFi Provisioning Manager, but if I reactivate the provisioning manager the internet connection breaks. Is there any way around this?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: WiFi + Provision working simultaneously

Postby ESP_YJM » Thu Apr 29, 2021 10:16 am

You can remove esp_wifi_disconnect() in function wifi_prov_mgr_start_provisioning() and add esp_wifi_disconnect() in function wifi_connect_timer_cb(),before the esp_wifi_connect().

daviherc
Posts: 10
Joined: Wed Apr 28, 2021 5:31 pm

Re: WiFi + Provision working simultaneously

Postby daviherc » Sun May 02, 2021 10:45 pm

Thank you, worked perfectly.

I did not use the second change so I could decouple the connection action from the provision action, so I called the connect function elsewhere.

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: WiFi + Provision working simultaneously

Postby ESP_YJM » Thu May 06, 2021 2:40 am

In short, remember that if the wifi is already connected, calling esp_wifi_connect() will not reconnect.

daviherc
Posts: 10
Joined: Wed Apr 28, 2021 5:31 pm

Re: WiFi + Provision working simultaneously

Postby daviherc » Tue Aug 10, 2021 1:31 pm

Hello again,

I wanted to perform a similar procedure with the ESP32: I want the ESP32 to be open to new provisionings while it is trying to connect, to allow the user to change networks if the current is unstable.

I tried to use those changes mentioned above, but I keep getting the errors:

GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
E (2866) wifi:sta is connecting, return error
- "ESP_ERR_WIFI_CONN"
- "ESP_ERR_WIFI_SSID"

I am calling:

wifi_prov_mgr_start_provisioning(WIFI_PROV_SECURITY_1, pop_, service_name_, NULL);
esp_wifi_connect();

Would there be any workarounds to that? Should I implement my own provisioning method?

Thank you!

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: WiFi + Provision working simultaneously

Postby ESP_YJM » Wed Sep 15, 2021 7:42 am

It seems the WIFI is connecting. Before you call esp_wifi_connect(), you can call esp_wifi_disconnect() first.

karunt
Posts: 93
Joined: Sat Apr 03, 2021 7:58 am

Re: WiFi + Provision working simultaneously

Postby karunt » Wed Oct 27, 2021 4:22 pm

Along similar lines, is there a way to re-provision ESP32 after it's been successfully provisioned once without restarting the chip? Basically, I'd like for ESP32 to continue staying available for new wifi credentials after being successfully being provisioned once without restarting the chip. To do this, I tried disabling the auto-stop feature calling

Code: Select all

ESP_ERROR_CHECK(wifi_prov_mgr_disable_auto_stop(0))
before

Code: Select all

ESP_ERROR_CHECK(wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key))
.

Appreciate some help with the following questions:

1. Is it poor practice to keep the chip in provisioning mode perpetually after receiving credentials once? Is there a better approach than disabling the auto-stop feature?
2. When I try to re-provision the chip with new wifi credentials (having disabled the auto-stop feature), I get the following errors:

Code: Select all

E (245642) wifi_prov_mgr: Wi-Fi credentials already received by provisioning app
E (245652) wifi_prov_handlers: Failed to apply Wi-Fi Credentials
How do I get around this?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: WiFi + Provision working simultaneously

Postby ESP_YJM » Thu Oct 28, 2021 11:49 am

Please allow me to express your needs: you want to continue to configure the network and use the new WIFI configuration after the device is successfully configured. I think the API `wifi_prov_mgr_disable_auto_stop(0)` can't achieve your needs. Because, one provisioning seesion(Before beginning to end) only allows one Wi-Fi credentials received, no matter whether the Wi-Fi credentials can connect to the AP. It will keep this Wi-Fi credentials until the customer erase the NVS or re-provisioning. For re-provisioning, i think you need first stop it(`wifi_prov_mgr_stop_provisioning`) and then start it(`wifi_prov_mgr_start_provisioning`);

karunt
Posts: 93
Joined: Sat Apr 03, 2021 7:58 am

Re: WiFi + Provision working simultaneously

Postby karunt » Thu Oct 28, 2021 2:02 pm

Here's what I'm trying to achieve. After provisioning the chip once, I want to be able to re-provision it in case there's an error in the wifi credentials or I need to provide it an alternate set of wifi credentials to connect to an alternate wifi ssid. The problem I'm facing is that once the chip receives wifi credentials, the current provisioning example turns off the provisioning process and the chip no longer advertises itself to nearby devices. So how to re-initiate the provisioning process from a nearby device without resetting/restarting the chip, especially if the chip no longer advertises itself?

If I understood correctly, I thought wifi_prov_mgr_disable_auto would prevent wifi_prov_mgr_stop_provisioning from running. Then can I not just set prov_ctx-->prov_state to WIFI_PROV_STATE_IDLE, erase nvs, and reconnect to the chip (since it continues to advertise itself)?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: WiFi + Provision working simultaneously

Postby ESP_YJM » Fri Oct 29, 2021 3:11 am

For your question "So how to re-initiate the provisioning process from a nearby device without resetting/restarting the chip, especially if the chip no longer advertises itself?", i think you use wifi_prov_mgr_disable_auto to forbid provision stopped is right. You can add an endpoint by API wifi_prov_mgr_endpoint_register that can be reached by your device. In this endpoint callback function, you can re-provision. Maybe there is no API to set prov_ctx-->prov_state directly. It is internal, you may need call stop and start provisioning.

Who is online

Users browsing this forum: Google [Bot] and 156 guests