-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve WPS stability and a small lighting fix #116
Changes from 3 commits
4ee682a
360ec94
c2d2abd
031d754
5caba25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
#include "TFTs.h" | ||
#include "esp_wps.h" | ||
#include "WiFi_WPS.h" | ||
#include "sdkconfig.h" | ||
|
||
#include "IPGeolocation_AO.h" | ||
|
||
|
@@ -19,6 +20,7 @@ double GeoLocTZoffset = 0; | |
static esp_wps_config_t wps_config; | ||
void wpsInitConfig() | ||
{ | ||
memset(&wps_config, 0, sizeof(esp_wps_config_t)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems to be the safest way to init. We could also just use the macro from Expressif ;)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like using vendor specific macros when it literally does the same thing as a standard C function that every good C programmer should know about. This VS Code also gave me a weird squiggly for that macro since we don't directly Just being an opinionated C programmer lol |
||
wps_config.wps_type = ESP_WPS_MODE; | ||
strcpy(wps_config.factory_info.manufacturer, ESP_MANUFACTURER); | ||
strcpy(wps_config.factory_info.model_number, ESP_MODEL_NUMBER); | ||
|
@@ -61,6 +63,7 @@ void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) | |
WifiState = wps_failed; | ||
Serial.println("WPS Failed, retrying"); | ||
esp_wifi_wps_disable(); | ||
wpsInitConfig(); | ||
esp_wifi_wps_enable(&wps_config); | ||
esp_wifi_wps_start(0); | ||
break; | ||
|
@@ -70,6 +73,7 @@ void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) | |
tfts.print("/"); // retry | ||
tfts.setTextColor(TFT_BLUE, TFT_BLACK); | ||
esp_wifi_wps_disable(); | ||
wpsInitConfig(); | ||
esp_wifi_wps_enable(&wps_config); | ||
esp_wifi_wps_start(0); | ||
WifiState = wps_active; | ||
|
@@ -173,8 +177,7 @@ void WifiReconnect() | |
void WiFiStartWps() | ||
{ | ||
// erase settings | ||
snprintf(stored_config.config.wifi.ssid, sizeof(stored_config.config.wifi.ssid), "%s", WiFi.SSID().c_str()); | ||
stored_config.config.wifi.password[0] = '\0'; // empty string as password | ||
memset(&stored_config.config.wifi, 0, sizeof(stored_config.config.wifi)); //zero out the entire WiFi config | ||
stored_config.config.wifi.WPS_connected = 0x11; // invalid = different than 0x55 | ||
Serial.println(""); Serial.print("Saving config! Triggered from WPS start..."); | ||
stored_config.save(); | ||
|
@@ -208,9 +211,10 @@ void WiFiStartWps() | |
} | ||
tfts.setTextColor(TFT_WHITE, TFT_BLACK); | ||
snprintf(stored_config.config.wifi.ssid, sizeof(stored_config.config.wifi.ssid), "%s", WiFi.SSID().c_str()); // Copy the SSID into the stored configuration safely | ||
stored_config.config.wifi.password[0] = '\0'; // Since the password cannot be retrieved from WPS, set it to an empty string | ||
memset(&stored_config.config.wifi.password, 0, sizeof(stored_config.config.wifi.password)); // Since the password cannot be retrieved from WPS, set it to an empty string | ||
stored_config.config.wifi.WPS_connected = StoredConfig::valid; // Mark the configuration as valid | ||
Serial.println(); Serial.print("Saving config! Triggered from WPS success..."); | ||
Serial.println(); | ||
Serial.print("Saving config! Triggered from WPS success..."); | ||
stored_config.save(); | ||
Serial.println(" WPS finished."); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
#define WIFI_WPS_H | ||
|
||
#include "GLOBAL_DEFINES.h" | ||
#include <string.h> | ||
|
||
enum WifiState_t | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also like to use specific versions, but we want to keep it simpler for beginners, so no specific versions in the "public" version of the platformio.ini please.
I have and use my "private" one, with very specific verisons sometimes for testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rolled back since it didn't fix the problem anyways