JAndrassy / TelnetStream

Arduino Stream implementation over Telnet for OTA logging and debugging
GNU Affero General Public License v3.0
164 stars 17 forks source link

TelnetStream or TelnetPrint does not work if combined with ArduinoOTA on UNO R4 WIFI #33

Closed mskressin closed 7 months ago

mskressin commented 1 year ago

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

JAndrassy commented 1 year ago

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