mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-13 14:51:21 +10:00
0.9 fixed encoding problems
This commit is contained in:
+18
-46
@@ -98,10 +98,6 @@ void WiFiManager::setupConfigPortal() {
|
||||
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
|
||||
server->begin(); // Web server start
|
||||
DEBUG_WM(F("HTTP server started"));
|
||||
/*
|
||||
String ip = "10.1.2.3";
|
||||
optionalIPFromString(&_sta_static_ip, ip.c_str());
|
||||
DEBUG_WM(_sta_static_ip);*/
|
||||
|
||||
}
|
||||
|
||||
@@ -134,6 +130,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
boolean WiFiManager::startConfigPortal(char const *apName, char const *apPassword) {
|
||||
//setup AP
|
||||
WiFi.mode(WIFI_AP);
|
||||
DEBUG_WM("SET AP");
|
||||
|
||||
_apName = apName;
|
||||
_apPassword = apPassword;
|
||||
@@ -203,7 +200,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
|
||||
}
|
||||
|
||||
//check if we have ssid and pass and force those, if not, try with last saved values
|
||||
if (ssid != "" && pass != "") {
|
||||
if (ssid != "") {
|
||||
WiFi.begin(ssid.c_str(), pass.c_str());
|
||||
} else {
|
||||
DEBUG_WM("Using last saved values, should be faster");
|
||||
@@ -213,10 +210,21 @@ int WiFiManager::connectWifi(String ssid, String pass) {
|
||||
int connRes = WiFi.waitForConnectResult();
|
||||
DEBUG_WM ("Connection result: ");
|
||||
DEBUG_WM ( connRes );
|
||||
//not connected, WPS enabled, no pass - first attempt
|
||||
if (_tryWPS && connRes != WL_CONNECTED && pass == "") {
|
||||
startWPS();
|
||||
//should be connected at the end of WPS
|
||||
connRes = WiFi.waitForConnectResult();
|
||||
}
|
||||
return connRes;
|
||||
}
|
||||
|
||||
|
||||
void WiFiManager::startWPS() {
|
||||
DEBUG_WM("START WPS");
|
||||
WiFi.beginWPSConfig();
|
||||
DEBUG_WM("END WPS");
|
||||
}
|
||||
/*
|
||||
String WiFiManager::getSSID() {
|
||||
if (_ssid == "") {
|
||||
DEBUG_WM(F("Reading SSID"));
|
||||
@@ -236,47 +244,11 @@ String WiFiManager::getPassword() {
|
||||
}
|
||||
return _pass;
|
||||
}
|
||||
|
||||
*/
|
||||
String WiFiManager::getConfigPortalSSID() {
|
||||
return _apName;
|
||||
}
|
||||
|
||||
String WiFiManager::urldecode(const char *src)
|
||||
{
|
||||
String decoded = "";
|
||||
char a, b;
|
||||
while (*src) {
|
||||
if ((*src == '%') &&
|
||||
((a = src[1]) && (b = src[2])) &&
|
||||
(isxdigit(a) && isxdigit(b))) {
|
||||
if (a >= 'a')
|
||||
a -= 'a' - 'A';
|
||||
if (a >= 'A')
|
||||
a -= ('A' - 10);
|
||||
else
|
||||
a -= '0';
|
||||
if (b >= 'a')
|
||||
b -= 'a' - 'A';
|
||||
if (b >= 'A')
|
||||
b -= ('A' - 10);
|
||||
else
|
||||
b -= '0';
|
||||
|
||||
decoded += char(16 * a + b);
|
||||
src += 3;
|
||||
} else if (*src == '+') {
|
||||
decoded += ' ';
|
||||
*src++;
|
||||
} else {
|
||||
decoded += *src;
|
||||
*src++;
|
||||
}
|
||||
}
|
||||
decoded += '\0';
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
void WiFiManager::resetSettings() {
|
||||
DEBUG_WM(F("settings invalidated"));
|
||||
DEBUG_WM(F("THIS MAY CAUSE AP NOT TO START UP PROPERLY. YOU NEED TO COMMENT IT OUT AFTER ERASING THE DATA."));
|
||||
@@ -455,8 +427,8 @@ void WiFiManager::handleWifiSave() {
|
||||
DEBUG_WM(F("WiFi save"));
|
||||
|
||||
//SAVE/connect here
|
||||
_ssid = urldecode(server->arg("s").c_str());
|
||||
_pass = urldecode(server->arg("p").c_str());
|
||||
_ssid = server->arg("s").c_str();
|
||||
_pass = server->arg("p").c_str();
|
||||
|
||||
//parameters
|
||||
for (int i = 0; i < _paramsCount; i++) {
|
||||
@@ -464,7 +436,7 @@ void WiFiManager::handleWifiSave() {
|
||||
break;
|
||||
}
|
||||
//read parameter
|
||||
String value = urldecode(server->arg(_params[i]->getID()).c_str());
|
||||
String value = server->arg(_params[i]->getID()).c_str();
|
||||
//store it in array
|
||||
value.toCharArray(_params[i]->_value, _params[i]->_length);
|
||||
DEBUG_WM(F("Parameter"));
|
||||
|
||||
Reference in New Issue
Block a user