how to do a non-blocking ping?
I use ESP8266Ping.h but every time ping is failed , I have latency and sometimedisconnect,
it’s quite normal, but how to workaround?
how to do a non-blocking ping?
I use ESP8266Ping.h but every time ping is failed , I have latency and sometimedisconnect,
it’s quite normal, but how to workaround?
Unfortunately, it’s the nature of the beast. If a device is online then it’ll return the ping quickly but if it’s offline then the machine doing the pinging has to wait until it’s satisfied that it’s a genuine timeout.
I don’t know if you can hack the esp8288ping library to shorten the timeout period, but that might give you false negatives.
An alternative is to implement a heartbeat for each device. If they’re running Blynk then set a v pin high every so often (say every 5 seconds).
Your monitoring device reads each v pin less often (say every 10 seconds to make sure it’s high, then sets it low.
If a device is offline then the corresponding v pin will be low when read.
As each device you’re monitoring will have its own Auth code, you’d need to use a series of API calls on your monitoring device which contains the Auth code to read the v pin and set it low for each device that you’re monitoring.
Hope that makes sense?
Pete.
yes Pete, that make sense for nodeMCU only …
servers are online 24/7 so if one of them come down it may not be a big issue.
the real probleme is for mobile phone, since I ping IP to verify the presence of each member of the family.
but I 've ideas …
thank you for your help Pete.
I suppose that if the device that’s doing the pinging doesn’t do anything else then it could be disconnected intentionally from Blynk, using Blynk.disconnect() then when it detects a change in status of one of the devices it’s monitoring it could do a blynk.connect(), update the server, then disconnect again and continue pinging?
Pete.
it makes sense too.
but the nodemcu that’s doing pinging, control the lights and the HVAC and turn off them if nobody present.
I have to change ping timer when the mobile don’t reply at ping.
from 5 mn to 60 mn
It might be wise to look for a different solution. Ping is not intended for this usage.Can’t you do anything with Geofencing capabilities?
I already thought about that
but GPS drains the phone battery
and data must be active to communicate with blynk.
thank you for your help Bastiaan.
Can’t you set the timeout for the ping to a much lower rate? I’m not sure how it’s done from ESPPing, but I guess that could solve some issues
You can also consider switching to RPi Zero W or Onion Omega2, as Linux allows easy multitasking
@Lichtsignaal
I explore the source code, we can’t ,
because then delay when ping failed is always 2 or 300 ns.
I have no bloking issue when ping reply ok…
it’s a good idea Volodymyr, before the end of the year I will transfer my local sever from PC to orange pi.
I’ve an other way to workaround
timers !
if ping failed,
it means that the person is outside
so I can ping the mobile once an hour instead of each 10 mn.