Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passes garbage to on_input if first input string is empty. #9

Closed
alex-fu27 opened this issue Jun 25, 2021 · 2 comments
Closed

Passes garbage to on_input if first input string is empty. #9

alex-fu27 opened this issue Jun 25, 2021 · 2 comments

Comments

@alex-fu27
Copy link

ESP Telnet passes garbage to the on_input callback if the first input string is empty and only \n is sent via telnet.

To reproduce, compile and upload:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPTelnet.h>

ESPTelnet tnServer;

void setup()
{
	Serial.begin(9600);

	Serial.write("setting up wifi...\n");
	WiFi.hostname("hostname");
	WiFi.begin("wifi", "password");
	WiFi.setAutoReconnect(true);
	while (WiFi.status() != WL_CONNECTED) {
		delay(100);
	}

	Serial.write("setting up telnet...\n");
	tnServer.onConnect([](String){
			tnServer.print("yo ");
			});
	tnServer.onInputReceived([](String s){
			Serial.write("garbage: '");
			Serial.print(s);
			Serial.write("'\n");
			});
	tnServer.begin();

	Serial.write("done\n");
}

void loop()
{
	tnServer.loop();
}

Then connect via serial monitor, connect with Telnet and just hit enter on the yo prompt. You will see something like garbage: '�������� ��!��"��' in the serial monitor.

@LennartHennigs
Copy link
Owner

Hey, thanks for pointing this out. I will take a look...

@LennartHennigs
Copy link
Owner

I could only reproduce this on ESP8266, not on ESP32.
Added code, that now manually flushes the client upon connection – and I filter for ASCII chars...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants