When I use DHCP with ether.dhcpSetup() the DNS lookup for NTP ether.dnsLookup("0.pool.ntp.org") works fine, but when I use a static setup (because my Android app needs to know the IP address) with ether.staticSetup(myip); then this returns false and I don't get an IP address from the NTP pool. How come?
I have an Arduino Nano ATmega328 with a ENC28j60 ethernet shield, and therefore use the EtherCard libray.
Full MWE:
#include <EtherCard.h> // https://github.com/jcw/ethercard
#include <Time.h> // http://www.arduino.cc/playground/Code/Time
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = {192, 168, 2, 106};
const char poolNTP[] PROGMEM = "0.pool.ntp.org"; //pool to get time server from
uint8_t ntpMyPort = 123; //port for the time server, no idea why needed
byte Ethernet::buffer[700];
void setup () {
Serial.begin(9600);
//do not forget to add the extra '10' argument because of this ethernet shield
if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0) {
Serial.println(F("Failed to access Ethernet controller"));
}
//static setup
ether.staticSetup(myip);
ether.printIp("Address: http://", ether.myip);
//this works
// if (!ether.dhcpSetup())
// Serial.println(F("DHCP failed"));
//Find ip address of a time server from the pool
if (!ether.dnsLookup(poolNTP)) {
Serial.println("DNS failed"); //with static setup this line is executed, not so with DHCP
}
ether.printIp("Lookup IP : ", ether.hisip);
}
void loop () {}
dhcpSetup()doesn't take any parameters, so no way to give it my ip?