Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to WiFi networks that contain a ' #9472

Open
1 task done
assman opened this issue Apr 9, 2024 · 14 comments
Open
1 task done

Can't connect to WiFi networks that contain a ' #9472

assman opened this issue Apr 9, 2024 · 14 comments
Assignees
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@assman
Copy link

assman commented Apr 9, 2024

Board

ESP32 S3

Device Description

It's an ESP32 S3 WROOM from Freenove. It's got 2 USB C ports, one camera connector. https://store.freenove.com/products/fnk0090

Hardware Configuration

None

Version

v2.0.14

IDE Name

Arduino IDE

Operating System

macOS 14.4.1 Sonoma

Flash frequency

240 MHz (WiFi)

PSRAM enabled

no

Upload speed

115200

Description

My home WiFi SSID is Varun's Network. First I used the WifiScan example from the Arduino IDE to see if the board is able to see my network and ensure that it is in range, which it is. Then I use the following code to connect the board to my WiFi. Unfortunately it doesn't work and the board keeps throwing a WiFi.status() of 1 (WL_NO_SSID_AVAIL). I changed my SSID to one without the ' character and it is able to connect without any issues.

#include<WiFi.h>

const char *ssid = "Varun's Network";

const char *password = "varunvarun";
        
void initWiFi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi ");
  Serial.print(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    Serial.print(WiFi.status());
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

void setup() {
  Serial.begin(115200);
  initWiFi();
  Serial.print("RRSI: ");
  Serial.println(WiFi.RSSI());
}

void loop() {
  // put your main code here, to run repeatedly:
}

Sketch

#include<WiFi.h>

const char *ssid = "Varun's Network";

const char *password = "varunvarun";
        
void initWiFi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi ");
  Serial.print(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    Serial.print(WiFi.status());
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

void setup() {
  Serial.begin(115200);
  initWiFi();
  Serial.print("RRSI: ");
  Serial.println(WiFi.RSSI());
}

void loop() {
  // put your main code here, to run repeatedly:
}

Debug Message

NA

Other Steps to Reproduce

I have checked for similar existing issues within this repo and outside, could not find anything with a solution. I want to be able to connect to networks with special characters because I can't control what people name their SSIDs.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@assman assman added the Status: Awaiting triage Issue is waiting for triage label Apr 9, 2024
@lbernstone
Copy link
Contributor

Can you try const char *ssid = "Varun\'s Network";
Make very sure that you are using the same character as well (copy/paste from the serial monitor). Sometimes browsers/OS can change those quote marks into "smart" quotes. AFAIK apostrophe is allowed in esp32 SSID names.

@assman
Copy link
Author

assman commented Apr 10, 2024

Are you able to connect to a network with an apostrophe? I tried the escape mechanism you suggested but still not able to connect. To confirm that it is the apostrophe causing the issue and not anything else, I did a bunch of tests. My personal hotspot SSID is called iPhone 7, to which the ESP32 is easily able to connect. I renamed the hotspot to Varun's iPhone 7 and I'm facing the same issue, it just doesn't connect.

@lbernstone
Copy link
Contributor

lbernstone commented Apr 10, 2024

Confirmed. This is an arduino-esp32 issue. Works in IDF. Looks like maybe a dhcp failure. Will take some time to debug.
Failure:

10:36:50.912 -> [     4][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
10:36:50.946 -> [    39][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 0 - WIFI_READY
10:36:51.012 -> [   109][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started
10:36:51.012 -> [   111][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
10:36:51.012 -> [   111][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 2 - STA_START
10:36:55.751 -> [  4828][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: lb'moto, BSSID: 5a:4f:da:76:21:5e, Reason: 2
10:36:55.751 -> [  4829][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
10:36:55.751 -> [  4836][W][WiFiGeneric.cpp:1061] _eventCallback(): Reason: 2 - AUTH_EXPIRE

Success:

10:38:28.452 -> [     4][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
10:38:28.485 -> [    39][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 0 - WIFI_READY
10:38:28.551 -> [   108][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started
10:38:28.551 -> [   110][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 2 - STA_START
10:38:28.585 -> [   125][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
10:38:30.043 -> [  1584][V][WiFiGeneric.cpp:355] _arduino_event_cb(): STA Connected: SSID: lbmoto, BSSID: 1e:9b:1d:36:6f:27, Channel: 1, Auth: WPA2_WPA3_PSK
10:38:30.043 -> [  1585][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
10:38:30.076 -> [  1616][V][WiFiGeneric.cpp:369] _arduino_event_cb(): STA Got New IP:192.168.120.252
10:38:30.076 -> [  1617][D][WiFiGeneric.cpp:1039] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
10:38:30.076 -> [  1620][D][WiFiGeneric.cpp:1102] _eventCallback(): STA IP: 192.168.120.252, MASK: 255.255.255.0, GW: 192.168.120.235

@SuGlider
Copy link
Collaborator

@me-no-dev - PTAL. It may be some that you may have fixed within the new Networking Arduino layer.

@SuGlider
Copy link
Collaborator

SuGlider commented Apr 11, 2024

@lbernstone - Thanks for confirming the issue. Did you test it with 2.0.14 or 3.0.0-Alpha2? Or something else...

@SuGlider SuGlider assigned SuGlider and me-no-dev and unassigned SuGlider Apr 11, 2024
@lbernstone
Copy link
Contributor

I tested with both 2.0.14 and master. Debug logs above are from current master. IDF was tested with current master (~5.3).

@SuGlider
Copy link
Collaborator

Thanks for the confirmation @lbernstone!

@lbernstone
Copy link
Contributor

Yep, something in dhcp. WiFiStaticIP example works.

@me-no-dev
Copy link
Member

wait... what is the status now? what works and what doesn't?

@lbernstone
Copy link
Contributor

Original issue is as posted. A simple begin with ssid containing apostrophe fails with AUTH_EXPIRE. If a static config is set first, it connects properly.

@me-no-dev
Copy link
Member

huh? why would IP config have anything to do with WiFi Auth? I'll give it a shot. The only difference that IP config brings is that WiFi is started a bit earlier.

@me-no-dev
Copy link
Member

me-no-dev commented Apr 17, 2024

I can not confirm this:

WiFi.begin("Ficeto's AP", "*********");
[  1311][V][NetworkEvents.cpp:121] checkForEvent(): Network Event: 9 - WIFI_READY
[  1386][V][STA.cpp:205] _onStaEvent(): STA Started
[  1391][V][NetworkEvents.cpp:121] checkForEvent(): Network Event: 11 - STA_START
[  1399][D][STA.cpp:131] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START
STA Started
[  1542][V][STA.cpp:222] _onStaEvent(): STA Connected: SSID: Ficeto's AP, BSSID: 76:4d:28:c6:7a:fc, Channel: 8, Auth: WPA_WPA2_PSK
[  1553][V][NetworkEvents.cpp:121] checkForEvent(): Network Event: 13 - STA_CONNECTED
[  1561][D][STA.cpp:131] _onStaArduinoEvent(): Arduino STA Event: 13 - STA_CONNECTED
STA Connected
[  2265][V][NetworkInterface.cpp:66] _onIpEvent(): sta Got New IP: 192.168.254.36 MASK: 255.255.255.0 GW: 192.168.254.1
[  2277][V][NetworkEvents.cpp:121] checkForEvent(): Network Event: 16 - STA_GOT_IP
[  2284][D][STA.cpp:131] _onStaArduinoEvent(): Arduino STA Event: 16 - STA_GOT_IP
[  2291][D][STA.cpp:189] _onStaArduinoEvent(): STA IP: 192.168.254.36, MASK: 255.255.255.0, GW: 192.168.254.1
*sta: <UP,Ficeto's AP,CH:8,RSSI:-56,N,WPA_WPA2_PSK> (DHCPC,GARP,IP_MOD,V6_REP)
      ether 30:C6:F7:F4:2F:8C
      inet 192.168.254.36 netmask 255.255.255.0 broadcast 192.168.254.255
      gateway 192.168.254.1 dns 192.168.254.3

@lbernstone
Copy link
Contributor

I'll dig out another AP & a esp32 to test on. Failed on my Android 11 phone.

@me-no-dev
Copy link
Member

@lbernstone mine is Mikrotik, maybe has to do with the Android. I tried all chips too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

4 participants