• @PaddeK ahh, ok. Thanks - I look forward to a PR when it's ready. It could potentially be difficult since the ESP8266 should be powered off when not connected.

    As a hack for sending UDP, you can do something like this for now:

    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);
          }
        });
      });
    }
    

    But I have attached my extremely work in progress UDP implementation.

    It may be that this just isn't possible with the ESP8266 AT firmware. As far as I can tell the AT firmware provides no information on where a UDP packet came from (address/port), so it might not be possible to send a response back to the right address (unless you know for sure where Alexa is).

  • It may be that this just isn't possible with the ESP8266 AT firmware. As far as I can tell the AT firmware provides no information on where a UDP packet came from (address/port), so it might not be possible to send a response back to the right address (unless you know for sure where Alexa is).

    The CIPSTATUS (implementation source link) seems to be the command returning the remote_port/ip information. Perhaps that could be send for every +IPD received?

About

Avatar for opichals @opichals started