Conversation
|
Testing this on Huzzah32 at the UNR Innevation center on UNR-EXT failed with the following behavior:
Switching to Examples>WiFi>WiFiClientEnterprise.ino initially fails to connect with WiFi.begin(), times-out, and calls ESP.restart(). After restart WiFi.begin() works. Changing the timeout from 30 seconds to 3 seconds works. 2 seconds did not work. Using this code also did not work:
Utilizing ESP.restart() is too janky to include in our firmware, so until we have more time to dig deeper into why it isn't working and figure out if there is a way to fix it gracefully, this PR and enterprise WiFi will unfortunately have to be ice-boxed. |
|
With the following code inside EmotiBitWifi.cpp and a long (>10sec) attemptDelay ESP32 will connect to UNR-EXT enterprise wifi.
However, EmotiBit data is not presently visible in the oscilloscope for an unknown reason -- could be the router is filtering our unicasts, but not sure. Needs to be tested if our auto-reconnect with 100msec attemptDelay will work after dropping the connection. May need to increase WIFI_BEGIN_ATTEMPT_DELAY to >10sec. |
|
2 new problems:
Closing PR as too difficult to accomplish in the near future. |
…p. Moved WiFi.disconnect out of enterprise wifi cred. conditional
|
Added software restart provision. |
| // ToDo: There is no catch right now for timeout. In case of timeout, EmotiBit still continues to complete setup() and proceed to update() | ||
| _emotiBitWiFi.begin(-1, 1); | ||
| _emotiBitWiFi.begin(-1, 1, 20000); | ||
| led.setLED(uint8_t(EmotiBit::Led::BLUE), false); |
There was a problem hiding this comment.
Could there be value to adding the following code to (1) self-heal enterprise gunkiness (2) prevent confusion of entering the main loop before a connection is established?
if (_emotiBitWiFi.status() != WL_CONNECTED)
{ restart }
Does it create any problems/risks?
There was a problem hiding this comment.
Perhaps:
attemptDelay = 20000; // ESP32 has been observed to take >10 seconds to resolve an enterprise connection
maxAttemptsPerCred = 1;
timeout = attemptDelay * maxAttemptsPerCred * _emotibitWifi.getNumCredentials() * 2; // Try cycling through all credentials at least 2x before giving up and trying a restart
_emotiBitWiFi.begin(timeout, maxAttemptsPerCred, attemptDelay );
if (!connected) {restart}
There was a problem hiding this comment.
The current behavior is to try and connect to a network in an infinite loop.
I think this change keep the behavior the same, i.e., an infinite connect loop in setup, AND also improves it by providing a software reset.
Also, agreed that it will help with enterprise WiFi too.
There was a problem hiding this comment.
Added this change
There was a problem hiding this comment.
On testing, i notice that if a user only adds 1 credential, and it happens to be the wrong one, then the Emotibit will restart every 40secs.
Since the EmotiBit will be cycling through setup states, we might want to consider possible UX issues
There was a problem hiding this comment.
As per discussion, added the required change.
New behavior:
If enterprise network is listed in the credential list, then a timeout (As calculated above) will be used before MCU is restarted.
If no enterprise network is listed, then there will be no timeout and the emotibit will keep trying to connect to listed networks.
| credentials[numCredentials].ssid = ssid; | ||
| credentials[numCredentials].pass = password; | ||
| credentials[numCredentials].userid = userid; | ||
| credentials[numCredentials].username = username; |
There was a problem hiding this comment.
Let's add a conditional here to print an error and return -1 when numCredentials >= MAX_CREDENTIALS
There was a problem hiding this comment.
Added. The code now handles passing MAX_ALLOWED number as shown below (with a simulated limit of 1)
Loading configuration file: config.txt
Number of network credentials found in config file: 4
Adding SSID: personal-1 -pass:pass1... success
Adding SSID: personal-2 -pass:pass2...failed to add credential
***Credential storage capacity exceeded***
Ignoring credentials beginning: personal-2
…dentials at least 2 times
…s listed, MCU restarts, else continues to connect to network without timeout
…n connection attempts.
EmotiBitWiFi.cpp
Outdated
| _needsAdvertisingBegin = true; | ||
| while((wifiStatus == WL_IDLE_STATUS) && (millis() - beginDuration < attemptDelay)); // This is necessary for ESP32 unless callback is utilized | ||
| //while((wifiStatus == WL_IDLE_STATUS) && (millis() - beginDuration < attemptDelay)) // This is necessary for ESP32 unless callback is utilized | ||
| while((wifiStatus != WL_CONNECTED) && (millis() - beginDuration < attemptDelay)) // This is necessary for ESP32 unless callback is utilized |
There was a problem hiding this comment.
ESP was not waiting for the full 20 secs (set as attemptDelay)
Snippet from serial monitor:
Attempting to connect to SSID: personal-1
WiFi.begin() duration = 134
attemptDelay: 20000 - WiFi.status() = 6 // Wifi status == WL_DISCONNECTED
attemptDelay: 20000 - WiFi.status() = 1 // WiFi status changes to WL_NO_SSID_AVAIL
WiFi.status() = 1, total duration = 4136 // This WL status makes it jump out of the while(wait for attempDelay) before 20secs
Therefore, the conditional in the while has been changed to make sure the MCU waits for attemptDelay seconds before moving on.
There was a problem hiding this comment.
@nitin710 why would we want to wait 20 seconds if WL_NO_SSID_AVAIL?
There was a problem hiding this comment.
Better to move on faster i guess.
Change has been undone.
Now ESP moves on to the next SSID if network is not available.
EmotiBitWiFi.cpp
Outdated
| _needsAdvertisingBegin = true; | ||
| while((wifiStatus == WL_IDLE_STATUS) && (millis() - beginDuration < attemptDelay)); // This is necessary for ESP32 unless callback is utilized | ||
| //while((wifiStatus == WL_IDLE_STATUS) && (millis() - beginDuration < attemptDelay)) // This is necessary for ESP32 unless callback is utilized | ||
| while((wifiStatus != WL_CONNECTED) && (millis() - beginDuration < attemptDelay)) // This is necessary for ESP32 unless callback is utilized |
There was a problem hiding this comment.
@nitin710 why would we want to wait 20 seconds if WL_NO_SSID_AVAIL?

Description
Requirements
Issues Referenced
Functionality
ssid- Network name you are trying to connect touserid- Your userId. (this may be your university ID. You may need to talk to your university network admin to get these details.username- oftentimes just a repeat of theuseridunless specified by your network adminpassword- Your password associated with your user id.ssid,passwordanduseridto connect to a network. If the username is not provided, thenuseridis used as theusername. (in the current implementation)Documentation update
Testing
Test Configuration:
Testing Results
Binaries for testing
Checklist to allow merge
masterDIGITAL_WRITE_DEBUG= false (if set true while testing)ofxEmotiBitVersion.hScreenshots: