Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't ping self. #43

Open
SteveRMann opened this issue Feb 22, 2023 · 0 comments
Open

Can't ping self. #43

SteveRMann opened this issue Feb 22, 2023 · 0 comments

Comments

@SteveRMann
Copy link

SteveRMann commented Feb 22, 2023

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 <ESP8266Ping.h> //Includes ESP8266WiWi.h
#include <Kaywinnet.h> // 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);
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant