,local_ip就是您将获得的。
我正在使用ESP8266上的Smart Config WiFi使用Esptouch。我确实将IP更改为静态IP,但没有连接。那么有人有什么想法可以帮助我吗?对不起,我的英语不好
const IPAddress& demo = WiFi.localIP();
//setup getway
int gateway0 = int(demo[0]);
int gateway1 = int(demo[1]);
int gateway2 = int(demo[2]);
int gateway3 = 1;
IPAddress gateway(gateway0,gateway1,gateway2,gateway3);
//setup ip
IPAddress ip(gateway0, gateway1, gateway2, 233);
//setup subnet
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip,gateway,subnet);
Serial.println("");
Serial.println("WiFi connected");
Serial.println(WiFi.localIP());
当您的ESP处于AP_STA(或AP)模式时,您想更改本地IP吗?
如果是,将其添加到您的代码:
IPAddress local_IP(192, 168, 10,11);
IPAddress gateway(192, 168, 4, 9);
IPAddress subnet(255, 255, 255, 0);
WiFi.softAPConfig(local_IP, gateway, subnet);
WiFi.softAP(ssid, password);`//change the SSID and password
您可以更改值,如果您执行wifi.localip()。