-
-
Notifications
You must be signed in to change notification settings - Fork 83
Wifi Static IP assignment does not work #1087
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
Wifi Static IP assignment does not work #1087
Comments
Seems You are first person to use static IP in Wifi client mode. tested on target: ESP_PSRAM_REV0 FW: 1.8.0.291 |
caught same bug ESP32_REV0 FW: 1.8.0.431 |
So I've been doing some investigation and flashed an ESP32 (REV0) with the latest firmware. The configuration is properly stored: It does connect properly, I tried different scenarios:
I've been trying as well non proper connection, in those cases, as expected all goes wrong, you can't connect. I've been trying the sample https://github.com/nanoframework/Samples/blob/main/samples/HTTP/HttpWebRequest/Program.cs and it works just fine. |
The issue is with setting the static IP on the ESP32, where the router is not having a DHCP server running. I will not connect in my case. When you have a DHCP server running on the Router/Gateway the ESP32 will be provisioned with it. So the static IP that you have provisioned in ESP32 is not used at all, the static IP will show in ESP32. One way to test it is to ping the ESP32 static IP and I am sure you will get time out and also check with DHCP server it will show that it has provisioned with a Dynamic IP to ESP32. |
I searched through espressif documentation, and found, that
So I searched, how to disable DHCP client, and found Then searched through So, static IP not implemented properly, I think. Hope this information helps someone, because I'm not c++ programmer and can't handle with it myself |
using nanoFramework.Networking;
using System.Threading;
public class Program
{
public static void Main()
{
// connecting to wifi ap
bool connected;
do
{
WifiNetworkHelper.SetupNetworkHelper("SSID", "PWD");
WifiNetworkHelper.NetworkReady.WaitOne();
connected = WifiNetworkHelper.ConnectFixAddress("SSID", "PWD", new IPConfiguration("192.168.45.115", "255.255.255.0", "192.168.45.1"));
} while (!connected);
Thread.Sleep(Timeout.Infinite);
}
} With this simple code and DHCP server in local network I have unpredictable result. Sometimes ESP32 gets IP from DHCP, sometimes static IP. I have to ping static IP from my PC and reboot board several time, to catch a moment, when static IP assigned. |
@cbagpipe what you are doing is not really a good way. Why would you first connect with DHCP and then with a static address? You should just use |
@Ellerbach ok... I thought |
It does actually connect and setup everything :-) See: https://github.com/nanoframework/System.Device.Wifi/blob/6767df36c7dfd44caf651f21b52f616d57b3f33c/System.Device.Wifi/NetworkHelper/WifiNetworkHelper.cs#L65 |
After doing that my ESP32 not getting static IP anymore. Only DHCP one. |
@cbagpipe thanks for the investigation. So definitely something to adjust on the native side. |
@alberk8 , Please can you see if this is now working. |
Tested with latest firmware and still not working with static IP with WiFi. It is still getting DHCP IP from my router. |
This has been an issue since the IDF changed from TCPIP adapters to the ESP_NETIF interface. Some work needs to be done to make sure all areas are compatible with ESP_NETIF working.
|
By enabling staticipV4, it worked for me: IPConfiguration IPConfiguration = new IPConfiguration("192.168.31.147", "255.255.255.0", "192.168.31.1", new string[] {"8.8.8.8"});
// 0 was the index of the interface I wanted to connect to
NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIPv4(IPConfiguration.IPAddress, IPConfiguration.IPSubnetMask, IPConfiguration.IPGatewayAddress);
success = WifiNetworkHelper.ConnectFixAddress(MySsid, MyPassword, IPConfiguration, token: cs.Token); |
@AdrianSoundy is this completed now? |
No it wasn't completed. The changes have been made but the testing wasn't completed. I'll raise a PR for changes and see if we can get this tested. @alberk8 Are you able to test this ? |
I will try to test this over the week end. |
Library/API/IoT binding
nanoFramework.System.Device.Wifi
Visual Studio version
VS2022 v 17.2.5
.NET nanoFramework extension version
2022.2.0.19
Target name(s)
ESP32_REV0, ESP_PSRAM_REV0
Firmware version
1.8.0.344, 1.8.0.291
Device capabilities
System Information
HAL build info: nanoCLR running @ ESP32 built with ESP-IDF v4.4.1
Target: ESP32
Platform: ESP32
Firmware build Info:
Date: Jun 28 2022
Type: MinSizeRel build, chip rev. >= 0, without support for PSRAM
CLR Version: 1.8.0.379
Compiler: GNU ARM GCC v8.4.0
OEM Product codes (vendor, model, SKU): 0, 0, 0
Serial Numbers (module, system):
00000000000000000000000000000000
0000000000000000
Target capabilities:
Has nanoBooter: NO
IFU capable: NO
Has proprietary bootloader: YES
AppDomains:
Assemblies:
Native Assemblies:
mscorlib v100.5.0.17, checksum 0x004CF1CE
nanoFramework.Runtime.Native v100.0.9.0, checksum 0x109F6F22
nanoFramework.Hardware.Esp32 v100.0.7.3, checksum 0xBE7FF253
nanoFramework.Hardware.Esp32.Rmt v100.0.3.0, checksum 0x0A915860
nanoFramework.Device.OneWire v100.0.4.0, checksum 0xB95C43B4
nanoFramework.Networking.Sntp v100.0.4.4, checksum 0xE2D9BDED
nanoFramework.ResourceManager v100.0.0.1, checksum 0xDCD7DF4D
nanoFramework.System.Collections v100.0.1.0, checksum 0x2DC2B090
nanoFramework.System.Text v100.0.0.1, checksum 0x8E6EB73D
nanoFramework.Runtime.Events v100.0.8.0, checksum 0x0EAB00C9
EventSink v1.0.0.0, checksum 0xF32F4C3E
System.IO.FileSystem v1.0.0.0, checksum 0x3AB74021
System.Math v100.0.5.4, checksum 0x46092CB1
System.Net v100.1.5.0, checksum 0x5BAB8CB3
System.Device.Adc v100.0.0.0, checksum 0xE5B80F0B
System.Device.Dac v100.0.0.6, checksum 0x02B3E860
System.Device.Gpio v100.1.0.4, checksum 0xB6D0ACC1
System.Device.I2c v100.0.0.1, checksum 0xFA806D33
System.Device.Pwm v100.1.0.4, checksum 0xABF532C3
System.IO.Ports v100.1.6.0, checksum 0xB798CE30
System.Device.Spi v100.1.2.0, checksum 0xB6C4B3BD
System.Device.Wifi v100.0.6.4, checksum 0x1C1D3214
Windows.Storage v100.0.2.0, checksum 0x954A4192
++++++++++++++++++++++++++++++++
++ Memory Map ++
++++++++++++++++++++++++++++++++
Type Start Size
++++++++++++++++++++++++++++++++
RAM 0x3ffe49ac 0x0001b000
FLASH 0x00000000 0x00400000
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ Flash Sector Map ++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Region Start Blocks Bytes/Block Usage
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0 0x00010000 1 0x1A0000 nanoCLR
1 0x001B0000 1 0x1F0000 Deployment
2 0x003C0000 1 0x040000 Configuration
+++++++++++++++++++++++++++++++++++++++++++++++++++
++ Storage Usage Map ++
+++++++++++++++++++++++++++++++++++++++++++++++++++
Start Size (kB) Usage
+++++++++++++++++++++++++++++++++++++++++++++++++++
0x003C0000 0x040000 (256kB) Configuration
0x00010000 0x1A0000 (1664kB) nanoCLR
0x001B0000 0x1F0000 (1984kB) Deployment
Description
Assigning Static IP and connecting to an AP. The connection is successful and the Console message show the assigned IP of the ESP32 but viewing the AP GUI will reveal that an DHCP IP is assigned instead.
How to reproduce
Expected behaviour
Static IP is used instead of DHCP.
Screenshots
No response
Sample project or code
No response
Aditional information
No response
The text was updated successfully, but these errors were encountered: