-
• #2
Hi,
It looks like something like this will work to add Ping if you need it:
wifi.ping = function(addr, callback) { var time; this.at.cmd('AT+PING="'+addr+'"\r\n',1000,function cb(d) { if (d && d[0]=="+") { time=d.substr(1); return cb; } else if (d=="OK") callback(time); else callback(); }); }
but I'll see about adding that to the Espruino WiFi library.
I'm afraid I can't see a way of getting the default gateway address - but if you figure out how to get it from the ESP8266 via AT commands then I'm happy to add that.
-
• #3
You are always helpfull Gordon. This is the reason why i like to be a patreon.
Sacha
-
• #4
Thanks! :)
-
• #5
Just to add - this is now part of the Espruino WiFi library -
wifi.ping
-
• #6
Dear Grodon, I use wifi.ping with setInterval under v1.96 and NodeMCU, it have memory leak in case if I use callback function and function wifi.ping always return undefined. It's NodeMCU issues?
setInterval(function(){ console.log(wifi.ping("192.168.2.1", function(b){ //console.log(b); })); console.log(process.memory().free); }, 5000);
result:
undefined 1371 undefined 1303 undefined 1218 undefined 1134 undefined 1061 undefined 976 undefined 891 undefined 806 undefined 721 undefined 636 undefined 551 undefined 466 undefined 381 undefined 296 undefined 211 undefined 126 undefined 41 Execution Interrupted New interpreter error: Execution Interrupted
-
• #7
Yes, it looks likely it's an ESP8266 bug (however that's a lot of data to be leaked - are you sure you're not running other code as well?)
Please can you post this in the ESP8266 forum and carry on there? You're more likely to be able to get help there as I don't know the internals of the ESP8266 port that well.
-
• #8
Yes, Grodon, I recheck it and run only this code(see below) and have same result.
I posted this in the ESP8266 forum: http://forum.espruino.com/conversations/323848/
Thank you.var wifi = require("Wifi"); wifi.stopAP(); function onInit() { wifi.connect("ssid", {password: "password"}); setInterval(function(){ console.log(wifi.ping("192.168.2.1", function(b){ //console.log(b); })); console.log(process.memory().free); }, 5000); }
Dear Gordon
Besides the udp send/receive functions i have another wish for 1.95 ;-).
Could you please implement the ping function in the wifi library as well.
Is there a way to get the default gateway address received by the dhcp protocoll ?
Thanks
Sacha