Local network connected devices

Hi @Blacksheep

Ping is available but pretty low level and hard to use. Here’s and example that worked for me:

unsigned long pingIPAddr;
uint8_t sparkio[4] = {50,16,188,139};
unsigned int wincount = 0;
unsigned int losecount = 0;

void setup() {
    Serial.begin(9600);
    pingIPAddr = sparkio[0]<<24 | sparkio[1]<<16 | sparkio[2]<<8 | sparkio[3];
}

void loop() {
    // long netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts, unsigned long ulPingSize, unsigned long ulPingTimeout)
    long result = netapp_ping_send(&pingIPAddr, 32UL, 32UL, 100UL);
    if (result == 0) {
        Serial.print("Ping Successful! ");
        Serial.print(++wincount);
    } else {
        Serial.print("Ping Failed. ");
        Serial.print(++losecount);
    }
    
    delay(5000);
}
3 Likes