I'm still a newbie on the ESP8266 but I have a ESP-01 and I have flashed it with the latest AT firmware found here https://github.com/espressif/esp8266_at/tree/master/bin. I'm using the Arduino 1.6.4 IDE and everything seems to work as expected but I have a question about setting a static IP address for the device.
If I set the IP after I connect it works but based on other sources I should be able to do it before I do WiFi.begin. This works but what happens if there is no DHCP server? I assume that the device will try to get a DHCP address before looking at the next line of code and that will introduce a long wait, right?
WiFi.begin(AP_SSID, AP_PASSWORD);
WiFi.config(AP_IPADD,AP_IPGW,AP_IPSUB);
And how do I set a DNS server? By looking at the source code here https://github.com/esp8266/Arduino/blob/esp8266-sdk-1.0/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp I thought that it could be set like this:
WiFi.begin(AP_SSID, AP_PASSWORD);
WiFi.config(AP_IPADD,AP_IPGW,AP_IPSUB,AP_IPDNS);
based on this code:
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns)
{
struct ip_info info;
info.ip.addr = static_cast<uint32_t>(local_ip);
info.gw.addr = static_cast<uint32_t>(gateway);
info.netmask.addr = static_cast<uint32_t>(subnet);
wifi_station_dhcpc_stop();
wifi_set_ip_info(STATION_IF, &info);
// Set DNS-Server
ip_addr_t d;
d.addr = static_cast<uint32_t>(dns);
dns_setserver(0,&d);
_useStaticIp = true;
}
but I get this
...packages/esp8266/hardware/esp8266/1.6.4-673-g8cd3697/libraries/ESP8266WiFi/src/ESP8266WiFi.h:88:10: note: candidate expects 3 arguments, 4 provided
no matching function for call to 'ESP8266WiFiClass::config(IPAddress&, IPAddress&, IPAddress&, IPAddress&)'
Thanks in advance!