Page 1 of 1

ESP8266 receivedata

Posted: 19:19, 04 Feb 2016
by kosmonout
Hi there,

Started to adapt the java script section of the esp8266 code to my needs. Unfortunately JS is somewhat new too me. I like to pickup TCP status text send by the 8266 (implemented and verified that it is working) and show that on the evo app. So, I need a event driven routine that read outs the tcp buffer. I copied and paste something like this:

Code: Select all

app.receivedData = function (data) {
   if (app.connected) {
      var data = new Uint8Array(data);

      if (data[0] === "A") {
         $('#LightsOn').text('High');
      } else if (data[0] === "U") {
         $('#LightsOn').text('Low');
      }

      console.log('Data received: [' + data[0] + ', ' + data[1] + ', ' + data[2] + ']');
   } else {
      // Disconnect and show an error message to the user.
      app.disconnect('Disconnected');

      // Write debug information to console
      console.log('Error - No device connected.');
   }
};


Probably there is more setup to do. Because it does not work........

Re: ESP8266 receivedata

Posted: 03:55, 06 Feb 2016
by Fredrik
I assume you mean that your function app.receivedData() is never called.

You'll then need to add this line to the end of the app.js file:

Code: Select all

chrome.sockets.tcp.onReceive.addListener(function(info) { app.receivedData(info.data); });