-
• #2
You want to look at wifi.ping to an address on the Internet - depending on the response you can work out if you have an Internet connection
-
• #3
I tried this on a ESP8266 where it is working with a ip address. In the docs it states the parameter should be 'hostname', but when I try with a hostname I get an error:
w.ping('google.com', (details) => { console.log(details) }); Uncaught Error: Not a valid IP address.
When I try this on a ESP32 I get:
w=require('Wifi') =function () { [native code] } >w.ping('212.51.158.12', (details) => { console.log(details) }); Uncaught Error: Function "ping" not found!
Both ESP's are running espruino 2v00
The ping method may work for me when it would be available on both platforms however it's somewhat tricky, because you can not decide how many pings are issued.
Where could I find the source code of the 'net' Library?
-
• #4
Sun 2019.02.17
@fanThomas Does this get you in the ball park?
https://github.com/espruino/Espruino/blob/master/libs/network/jswrap_net.c
-
• #5
Sorry - ping was only recently added to the esp32 build - it might not be on a release build yet - which firmware are you on the esp32?
-
• #6
I am running under 2v00
I am trying to make my things resistive to all sort of annoyances that can occour. Currently I am working on network disruptions, when the wireless router is still responsive but cannot connect to the internet. While I use websocket connections I saw that the websocket module wants to create a socket connection using net.connect(), but unfortunately I could not find any possibility to detect this condition in the documentation. I get just a message at the console:
I don't know whether this is specific on the ESP32.