espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.39k stars 7.37k forks source link

Ping library #564

Closed pbecchi closed 5 years ago

pbecchi commented 7 years ago

Since I need it for my ported applications, I have put together a ping library the work on Esp32. I am not an expert of the lwip stack , but the library taken from Lua-RTOS-Esp32 and modified for the IDF , seams to work quite well. I would like now to make a pull-up request but I have different way of doing it: Make a c ping library equivalent to the Esp8266 one so that Esp8266 can run with no changes. in this case I need to know where I should place ping.h and ping.c files. Make a different c++ Ping library and locate that on a new /library/ping directory. Thanks

everslick commented 7 years ago

While I'm in no position to answer your question, I'm interested in testing your lib. If you are willing to share it, you could just put it in here as a comment or attachment.

pbecchi commented 7 years ago

Basic functions are working , but I am in process of writing a library with similar footprint as the ESP8266 one. I have not implemented the function handler that the Esp8266 library have: to implement those I probably have to rewrite it! If it important to do it that way, you have to wait a little more!

everslick commented 7 years ago

no hurry, thanks!

bill-orange commented 7 years ago

I can also use your library. I have odd router disconnects. After 60+ hours of normal operation, the router will not allow a connection to the ESP32 or EPS8266 devices but the connection status on the ESP side shows the connection is good. Since the ESP believes the connection is good even my watchdog is not triggered.

I solved this problem on the ESP8266 systems by having them PING the router once every 6 min. or so. If the PING fails the EPS8266 restarts and all is well. Restarting the connection with a new begin() statement would probably work too.

Thus, for the ESP32 systems I need the PING library.

bill-orange commented 6 years ago

Has there been any progress on this project?

pbecchi commented 6 years ago

Few days more....and I will provide a library ! It will not 100% compatible with the ESP8266 one!

bill-orange commented 6 years ago

That would be super!

lonerzzz commented 6 years ago

Definitely looking forward to seeing it.

pbecchi commented 6 years ago

I have uploaded to github.com/pbecchi/ESP32_ping the library! I have tested ping method and work well on WiFi connection! The call back functions are not working yet ........... I am busy now , but as soon as I have some time I will try to finish!

bill-orange commented 6 years ago

Excellent work. Thank you. Pinging the router is the only reliable way I have found to test the WiFi connection. I think this is a router issue rather than an EPP32/8266 issue. I rearranged you example into a function as shown below.

bool pingtest (IPAddress ia) { //uint8_t first_byte = IP[0]; //int ia[4] = { 192, 168, 0, 1 }; int i = 0; while (Serial.available()) {

char c = Serial.read();
delay(100);
int  val = 0;
while (c != '.' &&  c != 10 && c != 255) {
  if (c >= '0' && c <= '9') {
    val = val * 10 + (c - '0');
  }
  c = Serial.read();
}

ia[i++] = val ;

} IPAddress adr = IPAddress(ia[0], ia[1], ia[2], ia[3]); Serial.printf("Ping : %d . %d . %d . %d ->", ia[0], ia[1], ia[2], ia[3]); if (ping_start(adr, 4, 0, 0, 5)) { //Serial.println("OK"); return true; } else { //Serial.println("FAILED"); return false;

} }

marian-craciunescu commented 6 years ago

I can also confirm that your library is working. Maybe you could do a small wrapper on it

tferrin commented 6 years ago

Very nice! Useful for tracking down network problems.

Since the ping library works this is really not an Arduino ESP32 "issue" and so this thread should be marked closed.

bill-orange commented 6 years ago

Agreed, let’s close it!

RussMathis commented 6 years ago

While this library works for me. I've noticed a 400 byte memory leak that causes my ESP32 to crash. I call the ping routine once per minute until a panic out of memory error.

robjen commented 6 years ago

same problem here ... ESP running for many days but lost network connection after few hours so added this ping library as a keep alive on network ...

now crashes after 40-45 minutes (4 times in a row now)

remove library and happily running well 3 days+

so have to agree there must be a nasty memory leak in there somewhere

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This stale issue has been automatically closed. Thank you for your contributions.