Hello Dude,
I have some problem with programming for Ethernet shield and new to Ethernet library. I have an arduino official shield. I tried the example and got it work until come to Ethernet.maintain() function. IDE is v1.0.3. I want to check whether Arduino is connected and stay online or not. My reference is from Google Code Archive - Long-term storage for Google Code Project Hosting.. Here is my code for checking connection via DHCP,
void checkConnection()
{
Serial.print(F("\n\rInside checkConnection() function"));
delay(1000);
switch(Ethernet.maintain()) {
case 0: Serial.print(F("\n\rDHCP: Nothing happened")); break;
case 1: Serial.print(F("\n\rDHCP: Renew failed")); break;
case 2: Serial.print(F("\n\rDHCP: Renew success")); break;
case 3: Serial.print(F("\n\rDHCP: Rebind fail")); break;
case 4: Serial.print(F("\n\rDHCP: Rebind success")); break;
default: Serial.print(F("\n\rDHCP: Unexpected number")); break;
}
// print your local IP address:
Serial.print(F("\n\rCurrent IP address: "));
Serial.print(Ethernet.localIP()); // print your local IP address:
}
My problem is that "Ethernet.maintain() function" still showing "nothing happened" even if I disconnected the RJ-45 cable from the Ethernet Shield. Please refer to Ethernet - Arduino Reference. Am I missing something? And is it correct way to check connection?
Inside checkConnection() function
DHCP: Nothing happened
Current IP address: 192.168.1.2
Merry Christmas and happy new year,
pak