I've been running an ESP8266 on a Pico to control a servo (venetian blind tilt), using HTTP. However, I'm switching to a TCP socket instead to control via nc, so that I can do immediate variable control from a remote rotary encoder rather than the slow open-request-response-close HTTP method.
That seems to be working, but I was wondering if it was possible to effectively do socket.setConsole(); I know it's not that straightforward, as it would be if it were acting as a serial port, but is there some way of passing incoming data from socket.on('data', function () { /* pass to console */ })? It'd be nice to just send servo.set(...) commands via nc rather than making up a new protocol.
Incidentally, I was having trouble running the HTTP server and the TCP socket server running at the same time, even though from what I can see AT+CIPMUX=1 is set. Code:
var ESP8266 = require("ESP8266WiFi_0v25");
var Net = require('net');
var HTTP = require('http');
// ...
wifi.connect(..., ..., function (err) {
// ...
http = HTTP.createServer(onRequest);
http.listen(80);
ssock = Net.createServer(onConnect);
ssock.listen(3000);
});
Error is:
>Uncaught Error: CIPSERVER failed (no change)
at line 2 col 20
(a?a:"Timeout")+")");}
If either the http pair or the ssock pair are commented, no problem. Before I spend too much time fiddling, has anyone managed to do two separate servers at the same time, or is this a known limitation?
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.
I've been running an ESP8266 on a Pico to control a servo (venetian blind tilt), using HTTP. However, I'm switching to a TCP socket instead to control via
nc
, so that I can do immediate variable control from a remote rotary encoder rather than the slow open-request-response-close HTTP method.That seems to be working, but I was wondering if it was possible to effectively do
socket.setConsole();
I know it's not that straightforward, as it would be if it were acting as a serial port, but is there some way of passing incoming data fromsocket.on('data', function () { /* pass to console */ })
? It'd be nice to just sendservo.set(...)
commands vianc
rather than making up a new protocol.Incidentally, I was having trouble running the HTTP server and the TCP socket server running at the same time, even though from what I can see
AT+CIPMUX=1
is set. Code:Error is:
If either the
http
pair or thessock
pair are commented, no problem. Before I spend too much time fiddling, has anyone managed to do two separate servers at the same time, or is this a known limitation?Thanks, as ever :)