It's not built-in yet, but I merged some code into Espruino's source code to add native UDP support just a few days ago. The hope is to get the Espruino WiFi specific code added for the 1v95 release.
Having said that, you can still send AT commands directly to send the data you want. Just tried this and it works for me:
function sendUDP(addr,port,data,callback) {
if (!callback) callback=function(){};
data = E.toString(data);
var at = wifi.at;
at.cmd('AT+CIPSTART=4,"UDP","'+addr+'",'+port+','+port+',2\r\n',2000,function cb(d) {
if (d=="4,CONNECT") return cb;
if (d!="OK") return callback("ERROR: "+d);
at.cmd('AT+CIPSEND=4,'+data.length+'\r\n', 1000, function cb(d) {
if (d=="OK") {
at.register('> ', function() {
at.unregister('> ');
at.write(data);
return "";
});
return cb;
} else if (d=="Recv "+data.length+" bytes") {
// all good, we expect this
return cb;
} else if (d=="SEND OK") {
at.cmd("AT+CIPCLOSE=4\r\n",1000,function(d) {
callback(d=="OK"?null:"ERROR: "+d);
});
} else {
callback("ERROR: "+d);
}
});
});
}
sendUDP("255.255.255.255",4567,"Hello World\r\n")
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
It's not built-in yet, but I merged some code into Espruino's source code to add native UDP support just a few days ago. The hope is to get the Espruino WiFi specific code added for the 1v95 release.
Having said that, you can still send AT commands directly to send the data you want. Just tried this and it works for me: