I was under the impression than TelnetStream could be used for remote debugging via telnet when using ArduinoOTA. However, he following code built from the ArduinoOTA and TelnetStream examples does not work as expected. It seems that calling ArduinoOTA.handle(); immediately disconnects the telnet session. The code works (for telnet debugging) as expected if the ArduinoOTA lines are commented out. It also works (for OTA updates) if the TelnetStream code is commented out. However if both are included in the code, it does not work.
The output of the telnet command is as follows:
Trying 192.168.x.x...
Connected to 192.168.x.x.
Escape character is '^]'.
HTTP/1.1 404 Not Found
Connection: close
Content-type: text/plain
Content-length: 9
the WiFiS3 library has a bug in WiFiServer. the client is sometimes handled by wrong server.
the firmware is fixed but has still no release after the fix
I was under the impression than TelnetStream could be used for remote debugging via telnet when using ArduinoOTA. However, he following code built from the ArduinoOTA and TelnetStream examples does not work as expected. It seems that calling ArduinoOTA.handle(); immediately disconnects the telnet session. The code works (for telnet debugging) as expected if the ArduinoOTA lines are commented out. It also works (for OTA updates) if the TelnetStream code is commented out. However if both are included in the code, it does not work.
The output of the telnet command is as follows:
Trying 192.168.x.x... Connected to 192.168.x.x. Escape character is '^]'. HTTP/1.1 404 Not Found Connection: close Content-type: text/plain Content-length: 9
Not FoundConnection closed by foreign host.
============ Code ========================
include
include
include
include
include "arduino_secrets.h"
char ssid[] = SECRET_SSID;
char password[] = SECRET_PASS;
void setup() { // attempt to connect to WiFi network: WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) { delay(500); } ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage); TelnetStream.begin(); }
void loop() { ArduinoOTA.handle();
switch (TelnetStream.read()) { case 'R': TelnetStream.stop(); delay(100); break; case 'C': TelnetStream.println("bye bye"); TelnetStream.stop(); break; } static unsigned long next; if (millis() - next > 1000) { next = millis(); log(); } }
void log() { static int i = 0;
char timeStr[20]; sprintf(timeStr, "%02d-%02d-%02d %02d:%02d:%02d", year(), month(), day(), hour(), minute(), second());
TelnetStream.print(i++); TelnetStream.print(" "); TelnetStream.print(timeStr); TelnetStream.print(" A0: "); TelnetStream.println(analogRead(A0)); }