Closed markheloking closed 9 years ago
The compiler complains because NoIP is int and thus is not an exact match to the operator== defined in https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/IPAddress.h#L46 use IPAddress NoIP = IPAddress(0) should resolve the problem.
closing as this is not caused by UIPEthernet but invalid use of == comparing to unsuitable type
The code I'm using reflecting your changes:
void EtherSetup()
{
int DHCPOK = 0;
IPAddress NoIP = IPAddress(0);
do
{
#if USEDHCP == 1
Ethernet.begin(mac);
#else
Ethernet.begin(mac,myIP);
#endif
if(Ethernet.localIP() == NoIP)
{
Serial.println(F("Error fetching DHCP info\n"));
DHCPOK = 0;
}
else
{
DHCPOK = 1;
}
}while(DHCPOK == 0);
Serial.println(F("-=-=-=-=-=-=-=-=-=-=\n"));
Serial.print(F("IP Address : "));
Serial.println(Ethernet.localIP());
Serial.print(F("Subnet Mask : "));
Serial.println(Ethernet.subnetMask());
Serial.print(F("Default Gateway IP: "));
Serial.println(Ethernet.gatewayIP());
Serial.print(F("DNS Server IP : "));
Serial.println(Ethernet.dnsServerIP());
}
Then the compiler gives me an error on IPAddress NoIP = IPAddress(0);
RFIDValidate_4_PostMethod.ino: In function 'void EtherSetup()':
RFIDValidate_4_PostMethod:121: error: call of overloaded 'IPAddress(int)' is ambiguous
D:\Dropbox\Programmeren\RFID\Arduino\Arduino IDE 1.0.5-r2\hardware\arduino\cores\arduino/IPAddress.h:47: note: candidates are: IPAddress::IPAddress(const uint8_t*)
D:\Dropbox\Programmeren\RFID\Arduino\Arduino IDE 1.0.5-r2\hardware\arduino\cores\arduino/IPAddress.h:46: note: IPAddress::IPAddress(uint32_t)
D:\Dropbox\Programmeren\RFID\Arduino\Arduino IDE 1.0.5-r2\hardware\arduino\cores\arduino/IPAddress.h:33: note: IPAddress::IPAddress(const IPAddress&)
I had to use IPAddress NoIP = IPAddress((uint32_t)0);
Is there nothing useful to be done about this? It's rather annoying to cast every integer I'm going to use as an argument...
This is not an issue with UIPEthernet, IPAddress is part of core Arduino.
Good places to discuss and or address this issue are:
http://forum.arduino.cc/index.php?board=11.0 https://groups.google.com/a/arduino.cc/forum/#!forum/developers https://github.com/arduino/Arduino/issues
and before you start to complain there you should read http://www.learncpp.com/cpp-tutorial/76-function-overloading/
The code I'm using is:
Then the compiler gives me an error on
if(Ethernet.localIP() == NoIP)
Seems like there was a problem with overloading the == operator, though I cannot seem to figure out how to resolve it (I cannot dictate it which one to use or something similar). What I want to achieve with this piece of code is that when the DHCP times out, it just gives 0.0.0.0 as IP, mask, etc. Since 0.0.0.0 is never a valid IP in my situation, I would like to check against it to see if the details were correctly fetched using DHCP. Am I doing something wrong?