Connect an ESP8266 to a SSID containing spaces?

rin67630
Posts: 141
Joined: Sun Mar 11, 2018 5:13 pm

Connect an ESP8266 to a SSID containing spaces?

Postby rin67630 » Sat Nov 16, 2024 9:13 am

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

User avatar
atesin
Posts: 3
Joined: Sat Nov 16, 2024 4:58 pm

Re: Connect an ESP8266 to a SSID containing spaces?

Postby atesin » Sat Nov 16, 2024 5:52 pm

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);
}

rin67630
Posts: 141
Joined: Sun Mar 11, 2018 5:13 pm

Re: Connect an ESP8266 to a SSID containing spaces?

Postby rin67630 » Sun Nov 17, 2024 2:56 am

Strange: elsewhere, with another ESP8266 and using a TPM router using the same name: "Fritz!Box Fon WLAN 7360", it worked OoB !
???

Who is online

Users browsing this forum: No registered users and 31 guests