ESP8266 receivedata
Posted: 19:19, 04 Feb 2016
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:
Probably there is more setup to do. Because it does not work........
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........