Hello!
I am using the Ethernet.maintain function in my sketch and on the page (http://arduino.cc/en/Reference/EthernetMaintain ) it says it returns a byte explaining what the result of the attempt to maintain the IP address was. How do i check what the result was? Can i print that byte to Serial or something? How?
Reading this: http://arduino.cc/en/Reference/Return isn't helping me...
Thanks guys, you're awesome!
E
byte returnedValue = Ethernet.maintain();
switch (returnedValue) {
case 0: Serial.println("nothing happened"); break;
case 1: Serial.println("renew failed"); break;
case 2: Serial.println("renew success); break;
case 3: Serial.println("rebind fail"); break;
case 4: Serial.println("rebind success"); break;
default: Serial.print("Unexpected returned value: ");
Serial.println((int)returnedValue);
break;
system
June 9, 2013, 12:45pm
3
johnwasser:
Aren't those magic numbers defined anywhere?
johnwasser:
byte returnedValue = Ethernet.maintain();
switch (returnedValue) {
case 0: Serial.println("nothing happened"); break;
case 1: Serial.println("renew failed"); break;
case 2: Serial.println("renew success); break;
case 3: Serial.println("rebind fail"); break;
case 4: Serial.println("rebind success"); break;
default: Serial.print("Unexpected returned value: ");
Serial.println((int)returnedValue);
break;
Thanks John!
will this also call the function or do i have to do that before?
will your code substitute mine in functionality?
if(currentTime - ethernetMaintainTimeLapsed > 60000) {
Ethernet.maintain();
ethernetMaintainInterval = currentTime;
}
Thanks!!
Arrch
June 9, 2013, 6:34pm
5
enricovara:
will this also call the function or do i have to do that before?
if(currentTime - ethernetMaintainTimeLapsed > 60000) {
Ethernet.maintain();
ethernetMaintainInterval = currentTime;
}
That will call the function, but you return value will be discarded.
enricovara:
Thanks John!
will this also call the function or do i have to do that before?
will your code substitute mine in functionality?
if(currentTime - ethernetMaintainTimeLapsed > 60000) {
Ethernet.maintain(); <<<<< Put it in place of this line
ethernetMaintainInterval = currentTime;
}
Thanks!!
Thank you all, problem solved, and I think I understand 'return' now ciao!