You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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")
    
About

Avatar for Gordon @Gordon started