chriscook8 wrote:https://github.com/chriscook8/esp-arduino-apboot
This reads from eeprom to get SSID and password information.s
Thanks a lot for this nice example!!
It has a lot of things in it I can use.
Like another user in another thread I also noticed that it stores the url encoded version of the ssid and pass.
Someone was kind enough to post code to complete this task:
https://gist.github.com/jmsaavedra/7964251
I slightly modified it so we also get the size of the url decoded version as this will likely be smaller
int urldecode(char *dst, const char *src)
{
char a, b;
int new_size = 0;
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';
*dst++ = 16*a+b;
src+=3;
}
else {
*dst++ = *src++;
}
new_size += 1;
}
*dst++ = '\0';
return new_size;
}
For the password I then used following code
int buffer_size = q_pass.length() + 1;
char pass_encoded[buffer_size];
char pass_decoded[buffer_size];
qpass.toCharArray(pass_encoded,buffer_size);
int decoded_size = urldecode(pass_decoded,pass_encoded);
Serial.println("writing eeprom pass:");
for (int i = 0; i < decoded_size; ++i)
{
EEPROM.write(32+i, pass_decoded[i]);
Serial.print("Wrote: ");
Serial.println(pass_decoded[i]);
}
this can probably be improved but I needed something quick