WiFi + Provision working simultaneously
WiFi + Provision working simultaneously
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?
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?
Re: WiFi + Provision working simultaneously
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().
Re: WiFi + Provision working simultaneously
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.
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.
Re: WiFi + Provision working simultaneously
In short, remember that if the wifi is already connected, calling esp_wifi_connect() will not reconnect.
Re: WiFi + Provision working simultaneously
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!
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!
Re: WiFi + Provision working simultaneously
It seems the WIFI is connecting. Before you call esp_wifi_connect(), you can call esp_wifi_disconnect() first.
Re: WiFi + Provision working simultaneously
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 before .
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:
How do I get around this?
Code: Select all
ESP_ERROR_CHECK(wifi_prov_mgr_disable_auto_stop(0))
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
Re: WiFi + Provision working simultaneously
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`);
Re: WiFi + Provision working simultaneously
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)?
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)?
Re: WiFi + Provision working simultaneously
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: No registered users and 177 guests