- Newest
- Most votes
- Most comments
Hi Frank.
When the WiFi connects, the stock demo firmware automatically stops the BLE provisioning. However, there is a delay that I think should allow you to get a response to your SaveNetworkReq before the BLE is stopped: https://github.com/aws/amazon-freertos/blob/main/demos/wifi_provisioning/aws_wifi_connect_task.c#L101 . The stock demo firmware delay is 5s; perhaps it's been reduced in your system?
For the connect now flag, this is where it's used: https://github.com/aws/amazon-freertos/blob/main/libraries/ble/src/services/wifi_provisioning/iot_ble_wifi_provisioning.c#L596 . The _connectNetwork()
function then calls WIFI_ConnectAP()
.
If you don't connect when you add the network, I see two ways to connect later.
Firstly, the application firmware can trigger a connection to a previously saved network by calling IotBleWifiProv_Connect()
: https://github.com/aws/amazon-freertos/blob/main/libraries/ble/src/services/wifi_provisioning/iot_ble_wifi_provisioning.c#L974 . That's done from here: https://github.com/aws/amazon-freertos/blob/main/demos/wifi_provisioning/aws_wifi_connect_task.c#L129 . And this appears to only happen when the system boots up: https://github.com/aws/amazon-freertos/blob/main/demos/wifi_provisioning/aws_wifi_connect_task.c#L162 . In the stock demo firmware anyway.
Secondly, it seems if you send another add/save network request for a WiFi network you already added/provisioned previously, it will be connected: https://github.com/aws/amazon-freertos/blob/main/libraries/ble/src/services/wifi_provisioning/iot_ble_wifi_provisioning.c#L749
I hope this helps. I haven't played with this code before. This is just a reading of the source.
Relevant content
- Accepted Answerasked 9 months ago
- asked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
Hi, thanks for the response. I've had success with the latter approach, that is, I'm setting the connect flag to false initially and then later saving it again with a value of true. This at least lets my user choose a network and get it connected. Once it's connected though, if I try to list networks again, I get no response from the device (not even a failure response).
I've also noticed another issue. At my office we have a 2.4ghz network and a 5ghz network. My ESP32 dev board shows me both of them when I try to list networks (assuming I'm not already connected) but it can only connect to the 2.4ghz network. If I try to connect to the other one, it appears to succeed, but my device never connects to IOT services.
Once WiFi is connected, the Bluetooth provisioning service is stopped, so none of the BLE commands can work, including ListNetworks.
Is there some way I can test to see if WiFi is connected, short of trying to list networks and waiting for it to time out?