Hi all,
I'm trying to code a sketch that continuosly ping some IP addresses on the LAN and posts the results on a Web Server in case one of the IP is not reachable.
I made (with some suggestions) a working sketch that makes the ping tasks.
I also have the code for the web server (simply the "Web Server" example)
I'm trying to make them work together, but I have some issues: it seams that if I put the instruction
ICMPEchoReply echoReply = ping(pingAddr, 4);
anywhere in the loop of the web server example, the web server stops working. I suppose that the problem is due to a multiple call of some functions, but I can't find wich one.
Could someone help me?
I'm working on Arduino UNO and Etherneth shield2.
Due to the shield model (W5500 chipset) I had to use a custom Ethernet library, that integrates some ICMP functions too.
Here the "ping" code:
#include <SPI.h>
#include <Ethernet.h>
#include <ICMPPing.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xE1}; // max address for ethernet shield
byte ip[] = {172, 19, 63, 37}; // ip address for ethernet shield
byte DefaultRouter[] = { 172, 19, 62, 104 };
byte DomainNameServer[] = { 192, 168, 0, 3 };
byte SubnetMask[] = { 255, 255, 240, 0} ;
IPAddress pingAddr(172, 19, 69, 77); // ip address to ping
SOCKET pingSocket = 0;
char buffer [256];
ICMPPing ping(pingSocket, (uint16_t)random(0, 255));
void setup()
{
// start Ethernet
Ethernet.begin(mac, ip, DefaultRouter, DomainNameServer, SubnetMask );
Serial.begin(9600);
}
void loop()
{
ICMPEchoReply echoReply = ping(pingAddr, 4);
if (echoReply.status == SUCCESS)
{
Serial.println("success");
}
else
{
Serial.println("failed");
}
delay(500);
}
Thank you!