File tree 1 file changed +34
-2
lines changed
1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,38 @@ void WiFiEvent(WiFiEvent_t event)
69
69
}
70
70
}
71
71
72
+ String urlDecode (const String& text)
73
+ {
74
+ String decoded = " " ;
75
+ char temp[] = " 0x00" ;
76
+ unsigned int len = text.length ();
77
+ unsigned int i = 0 ;
78
+ while (i < len)
79
+ {
80
+ char decodedChar;
81
+ char encodedChar = text.charAt (i++);
82
+ if ((encodedChar == ' %' ) && (i + 1 < len))
83
+ {
84
+ temp[2 ] = text.charAt (i++);
85
+ temp[3 ] = text.charAt (i++);
86
+
87
+ decodedChar = strtol (temp, NULL , 16 );
88
+ }
89
+ else {
90
+ if (encodedChar == ' +' )
91
+ {
92
+ decodedChar = ' ' ;
93
+ }
94
+ else {
95
+ decodedChar = encodedChar; // normal ascii char
96
+ }
97
+ }
98
+ decoded += decodedChar;
99
+ }
100
+ return decoded;
101
+ }
102
+
103
+
72
104
void setup ()
73
105
{
74
106
Serial.begin (115200 );
@@ -177,11 +209,11 @@ void wifiDisconnectedLoop()
177
209
preferences.clear ();
178
210
179
211
String qsid;
180
- qsid = currentLine.substring (12 , currentLine.indexOf (' &' )); // parse ssid
212
+ qsid = urlDecode ( currentLine.substring (12 , currentLine.indexOf (' &' ) )); // parse ssid
181
213
Serial.println (qsid);
182
214
Serial.println (" " );
183
215
String qpass;
184
- qpass = currentLine.substring (currentLine.lastIndexOf (' =' ) + 1 , currentLine.lastIndexOf (' ' )); // parse password
216
+ qpass = urlDecode ( currentLine.substring (currentLine.lastIndexOf (' =' ) + 1 , currentLine.lastIndexOf (' ' ) )); // parse password
185
217
Serial.println (qpass);
186
218
Serial.println (" " );
187
219
You can’t perform that action at this time.
0 commit comments