Skip to content

WiFi static IP configuration doesn't work after networking refactoring #9435

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

Closed
JAndrassy opened this issue Mar 29, 2024 · 5 comments · Fixed by #9445
Closed

WiFi static IP configuration doesn't work after networking refactoring #9435

JAndrassy opened this issue Mar 29, 2024 · 5 comments · Fixed by #9445
Assignees
Labels
3.0 migration issue relates to migration from 2.X to 3.X version Type: Regression Result of unforeseen consequences of a previous change

Comments

@JAndrassy
Copy link
Contributor

JAndrassy commented Mar 29, 2024

Description

WiFi doesn't use static IP configuration after the networking refactoring. Settings are not applied in NetworkInterface.config because esp_netif is NULL. In begin then DHCP is used.

Sketch

WiFiClientStaticIP example


If I first begin with DHCP then setting static IP works for next begin. But following begin again uses DHCP. This is not right. Already configured static IP configuration has to be used. Static IP should be only cleared with config(INADDR_NONE) (or end()). All WiFi libraries have it that way including the esp8266 WiFi.
The static IP configuration is cleared because ESP_NETIF_HAS_IP_BIT is cleared so config() with default parameters in invoked.

if((getStatusBits() & ESP_NETIF_HAS_IP_BIT) == 0 && !config()){
.

@JAndrassy JAndrassy added the Status: Awaiting triage Issue is waiting for triage label Mar 29, 2024
@Jason2866 Jason2866 added Type: Regression Result of unforeseen consequences of a previous change 3.0 migration issue relates to migration from 2.X to 3.X version and removed Status: Awaiting triage Issue is waiting for triage labels Mar 29, 2024
@me-no-dev
Copy link
Member

@JAndrassy please try #9445

@JAndrassy
Copy link
Contributor Author

JAndrassy commented Apr 2, 2024

second begin with static IP doesn't connect to WiFi. output from my test:

Attempting to connect to SSID "M20" with static IP 192.168.1.177
.
	...success

MAC: 30:AE:A4:08:B2:70
SSID: M20
BSSID: C0:25:E9:C3:2F:8A
RSSI:-56 dBm
IP Address: 192.168.1.177
gateway IP Address: 192.168.1.1
subnet IP mask: 255.255.255.0
DNS server: 192.168.1.1

Attempt to connect to port 80 on 192.168.1.1
	...success

[  2890][W][STA.cpp:157] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
Attempting to connect without resetting static IP configuration

	...success

MAC: 30:AE:A4:08:B2:70
SSID: 
BSSID: 00:00:00:00:00:00
RSSI:0 dBm
IP Address: 192.168.1.177
gateway IP Address: 192.168.1.1
subnet IP mask: 255.255.255.0
DNS server: 192.168.1.1
DNS server2: 8.8.8.8

Attempt to connect to port 80 on 192.168.1.1
[  2923][E][NetworkClient.cpp:258] connect(): connect on fd 48, errno: 118, "Host is unreachable"
	...ERROR

[  2937][W][STA.cpp:548] disconnect(): STA already disconnected.

@me-no-dev
Copy link
Member

enable verbose debug please. Not sure what I am looking at, but here I ran a constant loop of connect, wait 10 seconds, disconnect, wait 5 seconds, repeat. Static IP was kept the same and was able to reconnect to the same AP just fine. Anyway, your IP is there just fine.

@JAndrassy
Copy link
Contributor Author

there is nothing in verbose log for the second begin with static IP. I will debug it now to find out where it fails

@JAndrassy
Copy link
Contributor Author

sorry. I can't replicate it. then it happened on the first and second try. now it works. In many attempts it sometimes doesn't connect to AP in different parts of the test, but that could be a problem of my AP.

so the PR is OK and the problem is solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 migration issue relates to migration from 2.X to 3.X version Type: Regression Result of unforeseen consequences of a previous change
Projects
None yet
3 participants