Page 1 of 1

Connect an ESP8266 to a SSID containing spaces?

Posted: Sat Nov 16, 2024 9:13 am
by rin67630
Hi,
has someone got a solution with a 8266 to join a Wi-Fi network, which SSID contains spaces?
I tried to escape the spaces with \%20 without luck, it just cannot connect.
Connecting with Smart Config worked once, but it cannot reconnect a second time.
Maybe another Wi-Fi library can do the magic?
If you could get it to work, I'd appreciate to learn how...
Regards
Laszlo

Re: Connect an ESP8266 to a SSID containing spaces?

Posted: Sat Nov 16, 2024 5:52 pm
by atesin
hi... which is the problem in just to call

Code: Select all

WiFi.begin("my spaced ssid", "my spaced password")
i had a similar issue with a command-like shell in which user need to connect wifi by a command like "WIFI SSID PASSWD" ... i instructed (i.e. FORCED xD) users to use urlencoded credentials to avoid writing additional spaces or special chars that could confuse tokenizer, but after decoded credentials could still contain spaces with no problems... anyway, if you need some urldecode function, i share mine:

Code: Select all

char* urlDecode(char* url) {
  char tmp[strlen(url) + 1];
  char* src = url;
  char* dst = tmp;
  char hex[3];
  char rep;
  do {
    rep = *src;
    if ( rep == '%' ) {  // escape
      strlcpy(hex, src + 1, sizeof(hex));  // hexadecimal single byte
      rep = (char) strtol(hex, NULL, 16);  // store as char, if fails just truncates string
      src += strlen(hex);  // increment src according length read
    }
    *dst++ = rep;
  } while ( *src++ );
  return strcpy(url, tmp);
}

Re: Connect an ESP8266 to a SSID containing spaces?

Posted: Sun Nov 17, 2024 2:56 am
by rin67630
Strange: elsewhere, with another ESP8266 and using a TPM router using the same name: "Fritz!Box Fon WLAN 7360", it worked OoB !
???