dancol90 / ESP8266Ping

Ping library for ESP8266 Arduino core
GNU Lesser General Public License v2.1
265 stars 136 forks source link

Can't ping self. #43

Open SteveRMann opened 1 year ago

SteveRMann commented 1 year ago

If I don't call ping(), the ESP responds to ICMP ping requests from other devices on the local network. If I call ping(), the ESP cannot be pinged.

My test code:

`#define SKETCH "pingTest"

define VERSION "1.00" // Four characters

/ This program is a test of the ping function /

//-------------------------

include //Includes ESP8266WiWi.h

include // WiFi credentials

char pingIP[20]; // IP that we're going to ping.

//** SERIAL ** void beginSerial() { Serial.begin(115200); delay(1000); Serial.println(); Serial.println(SKETCH); Serial.println(VERSION); Serial.println(); }

//** WiFi ** void setup_wifi() { Serial.println(); Serial.println("Connecting to "); Serial.println(MY_SSID);

//WiFi.hostname(SKETCH); WiFi.begin(MY_SSID, MY_PASSWORD); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print(WiFi.status()); Serial.print(" "); }

Serial.println("\nWiFi connected, "); Serial.print("MAC Address: "); Serial.println(WiFi.macAddress()); Serial.print("IP address: "); Serial.println(WiFi.localIP()); Serial.print("Hostname: "); Serial.println(WiFi.hostname().c_str()); Serial.print(F("Default Gateway: ")); Serial.println(WiFi.gatewayIP().toString()); Serial.print(F("Subnet Mask: ")); Serial.println(WiFi.subnetMask()); }

//** PING **

void pingit() { Serial.print(pingIP); Serial.print(F(": ")); if (Ping.ping(pingIP)) { // Ping Serial.println("OK"); } else { Serial.println("Fail"); } // yield(); // Reset the WDT on the ESP8266 }

//** SETUP ** void setup() { beginSerial(); setup_wifi(); }

//** LOOP ** void loop() { strcpy(pingIP, "192.168.1.1"); pingit(); strcpy(pingIP, "192.168.1.57"); pingit(); strcpy(pingIP, "192.168.1.124"); pingit(); strcpy(pingIP, "192.168.1.183"); pingit(); strcpy(pingIP, "127.0.0.1"); pingit();

Serial.println(F("---------------")); delay(1000); } `