Here’s my update… I uncommented the KEYWORDS file and got the disconnect function to turn yellow, then i turned everything to basics. I was able to make it do EXACTLY as i want if i used the manual example (the one where i manually set a static IP). Here is the working code… It prints “offline” when the net is unplugged then “online” when it is connected.
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneEthernet.h>
#include <CayenneEthernetW5500.h>
#include <CayenneEthernetW5200.h>
char token[] = "xxxxxxxxxx";
boolean onlineStatus=false;
byte arduino_mac[] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX }; //actual values replaced, just to be safe when i post it...
IPAddress arduino_ip(xxx, xxx, x, xx);
IPAddress dns_ip(x, x, x, x);
IPAddress gateway_ip(xxx, xxx, x, x);
IPAddress subnet_mask(xxx, xxx, xxx, x);
void setup()
{
Serial.begin(9600);
Cayenne.begin(token, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}
CAYENNE_CONNECTED(){onlineStatus=true;}
CAYENNE_DISCONNECTED(){onlineStatus=false;}
void loop()
{
Cayenne.run();
if (onlineStatus==true){
Serial.print("ONLINE ");}
else{
Serial.print("Local ");}
}
But when i tried it for the regular ethernet example (i used the required libraries etc as the default example), it hangs on “getting IP” when network is unplugged… Any work around for that??? Code below if it helps:
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneEthernet.h>
char token[] = "xxxxxxxxxx";
boolean onlineStatus=false;
void setup()
{ Serial.begin(9600);
Cayenne.begin(token);
}
CAYENNE_CONNECTED(){onlineStatus=true;}
CAYENNE_DISCONNECTED(){onlineStatus=false;}
void loop()
{
Cayenne.run();
if (onlineStatus==true){
Serial.print("Online ");}
else{
Serial.print("Off ");}
}
This one hangs on “getting IP” when network is unplugged, while if I used static IP it works fine… but i think i would need the non-static ip route… Any suggestions??? ^____^