I have an application in mind that using MKR1010 on my local networks that acts once I arrive at home.
I though of a simple 'GeoFencing' mechanism by using the WiFi.ping() command.
I gave My Mobile Phone a fixed IP (basicaly 2 IP's , as I have 2.4 and 5G networks) and used the ping function to check if i'm home.
To my suprise the ping-function gets corrupted once you ping too many times a non-connected device or IP ! >:(
I tried 4 tests - see attachement, and every time I ping unconnected devices too many times (4 to 6 times), the ping-functions results in -1 for ANY IP or host you like to ping, and it nevers recover.
This is my Loop-code (Wifi setup is generic, wifi runs fine for days):
void loop() // Ping test with Assigned local device IP eand google.com
{
int counter=0;
char GeoFence3[] = "192.168.200.19"; // assigned Ip adress by Router for my cellphone
char GeoFence6[] = "www.google.com"; // random global adress to Ping
while (1) {
if (WiFi.status()==WL_CONNECTED) {
counter++;
int result1 =WiFi.ping(GeoFence3);
delay(500);
int result2 =WiFi.ping(GeoFence6);
Serial.print(counter);Serial.print(". ");
Serial.print(result1);Serial.print(", ");
Serial.print(result2);Serial.println(", ");
delay(500);
}
}
This is the Serial-Print result :
1. 140, 10, ==> count 1. Local IP ping = 140, google.com ping is 10
2. 50, 10,
3. 13, 10,
4. 10, 20,
.. ==> Keeps on running ,as long as target is connected :) GOOD !!!
27. 170, 20,
28. -1, 10, ==> Target / Cellphone is disconnected from Wifi, looks ok !
29. -1, 10,
30. -1, 10,
31. -1, 10,
32. -1, -1, ==> EVER ONGOING PING RESULT -1 for both IP's, never recovers !!
33. -1, -1,
34. -1, -1,
I verified many forum and the WifiNINA GitHub, nothing is known of this problem.
Can anyone test this? - I wonder if this is a local problem, of a Library issue.
Mkr1010_PingProblem.txt (3.41 KB)