Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By matkar
#22056 Hi,

In the code I declare:
IPAddress local_ip(192,168,3,1);
IPAddress gateway(255,255,255,0);
IPAddress subnet(192,168,3,1);


and in setup() I call:
WiFi.softAPConfig(local_ip, gateway, subnet);
then
WiFi.mode(WIFI_AP);
and
WiFi.softAP(AP_NameChar, WiFiAPPSK);
at last:
Serial.print("AP IP address: ");
Serial.println(WiFi.softAPIP());
Serial.print("AP subnet mask: ");
Serial.println(WiFi.subnetMask());
Serial.print("AP gateway: ");
Serial.println(WiFi.gatewayIP());


In the serial window I get:
AP IP address: 192.168.3.1
AP subnet mask: 0.0.0.0
AP gateway: 0.0.0.0


When checking the result with ipconfig in cmd after connecting to the created AP I get:
IP Address. . . . . . . . . . . . : 192.168.3.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :


Judging by the results IP Address and subnet mask are written correctly with WiFi.softAPConfig() function. Is there something wrong with the read functions? I'm probably missing something obvious...
The IP Address write and read works OK.
User avatar
By matkar
#22057 I've discovered a mistake in my previous post as I couldn't ping the device or open the webpage....
I have switched the definitions for
IPAddress gateway(255,255,255,0);
IPAddress subnet(192,168,3,1);

It should be:
IPAddress gateway(192,168,3,1);
IPAddress subnet(255,255,255,0);


But this does not solve the first issue. Reading those values still returns 0.0.0.0.

cmd ipconfig now returns:
IP Address. . . . . . . . . . . . : 192.168.3.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.3.1
User avatar
By martinayotte
#22168 Hi matkar,

Looking at the ESP8266WiFi.cpp, we can see that those 2 functions are not related to SoftAP, but to STATION_IF. So, it is normal that they are filled with 0.0.0.0, since you don't have any STA connection. If you add a connection to your Wifi router, you will get those filled with what your router will provide.

Code: Select allIPAddress ESP8266WiFiClass::subnetMask()
{
    struct ip_info ip;
    wifi_get_ip_info(STATION_IF, &ip);
    return IPAddress(ip.netmask.addr);
}

IPAddress ESP8266WiFiClass::gatewayIP()
{
    struct ip_info ip;
    wifi_get_ip_info(STATION_IF, &ip);
    return IPAddress(ip.gw.addr);
}