I am a professional software engineer, but most of the repositories here are related to my hobby Arduino.
If you want to say thank you with a donation, you can or use PayPal
Arduino Stream implementation over Telnet for OTA logging and debugging
License: GNU Affero General Public License v3.0
Can a setting be added to stream to more than one client?
Same data, send only.
In ArduinoWiFiServerESP.h we read:
#ifndef ESP32 // has wrong client.flush()
for (uint8_t i = 0; i < MAX_MONITORED_CLIENTS; i++) {
if (connectedClients[i]) {
connectedClients[i].flush();
}
}
#endif
therefore flush does nothing on esp32?
Why is it so?
Which bug should be solved in esp32 libs to make TelnetStream.flush() work.
Upon compiling for an ESP32 (TTGO T1)
I get this flow of errors:
In file included from /Volumes/Data/Activities/3_Maker/libraries/NetApiHelpers/src/ArduinoWiFiServer.h:48,
from /Volumes/Data/Activities/3_Maker/libraries/TelnetStream/src/NetTypes.h:38,
from /Volumes/Data/Activities/3_Maker/libraries/TelnetStream/src/TelnetStream.h:22,
from /Volumes/Data/Activities/3_Maker/ESP32_Victron_on_Steroids_V04.2024/a_Libs_Vars.ino:56:
/Volumes/Data/Activities/3_Maker/libraries/NetApiHelpers/src/ServerTemplate.h: In instantiation of 'class ServerTemplate<WiFiServer, WiFiClient>':
/Volumes/Data/Activities/3_Maker/libraries/TelnetStream/src/TelnetStream.h:27:13: required from here
/Volumes/Data/Activities/3_Maker/libraries/NetApiHelpers/src/ServerTemplate.h:118:16: error: 'void ServerTemplate<TServer, TClient>::flush() [with TServer = WiFiServer; TClient = WiFiClient]' marked 'override', but does not override
virtual void flush() override {
^~~~~
/Volumes/Data/Activities/3_Maker/ESP32_Victron_on_Steroids_V04.2024/f_Stats.ino: In function 'void statsRun()':
/Volumes/Data/Activities/3_Maker/ESP32_Victron_on_Steroids_V04.2024/f_Stats.ino:158:32: warning: 'DynamicJsonDocument' is deprecated: use JsonDocument instead [-Wdeprecated-declarations]
DynamicJsonDocument doc(1024);
^
In file included from /Volumes/Data/Activities/3_Maker/libraries/ArduinoJson/src/ArduinoJson.hpp:53,
from /Volumes/Data/Activities/3_Maker/libraries/ArduinoJson/src/ArduinoJson.h:9,
from /Volumes/Data/Activities/3_Maker/ESP32_Victron_on_Steroids_V04.2024/a_Libs_Vars.ino:31:
/Volumes/Data/Activities/3_Maker/libraries/ArduinoJson/src/ArduinoJson/compatibility.hpp:125:58: note: declared here
class ARDUINOJSON_DEPRECATED("use JsonDocument instead") DynamicJsonDocument
^~~~~~~~~~~~~~~~~~~
Compiling with the previous version 1.2.6 it works fine.
Can you please check?
Thank you.
Hey, thanks for you work and updating to Arduino's WiFiS3 library.
I just tried to do some tests with the new Arduino Uno R4 WiFi but unfortunately I can't get my advanced chat server example to work because:
error: 'class WiFiServer' has no member named 'accept'
Is it possible to implement this feature?
Here's the full example:
#include <WiFiS3.h>
#include <TelnetPrint.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key index number (needed only for WEP)
int status = WL_IDLE_STATUS;
boolean alreadyConnected = false; // whether or not the client was connected previously
NetClient *Clients;
#define MAX_CLIENTS 8
#define SERVER_PORT 23
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true)
;
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
Serial.println("Please upgrade the firmware");
}
// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Clients = new NetClient[MAX_CLIENTS];
// start the server:
TelnetPrint = NetServer(23);
TelnetPrint.begin();
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
//----Advanced Chat Server--------------
NetClient newClient = TelnetPrint.accept();
if (newClient) {
for (byte i = 0; i < MAX_CLIENTS; i++) {
if (!Clients[i]) {
Serial.print("We have a new client #");
Serial.println(i);
newClient.print("Hello, client number: ");
newClient.println(i);
// Once we "accept", the client is no longer tracked by the server
// so we must store it into our list of clients
Clients[i] = newClient;
break;
}
}
}
for (byte i = 0; i < MAX_CLIENTS; i++) {
if (Clients[i] && Clients[i].connected()) {
if (Clients[i].available()) {
while (Clients[i].available()) {
char rc = Clients[i].read();
Serial.print(rc);
}
}
}
}
// stop any clients which disconnect
for (byte i = 0; i < MAX_CLIENTS; i++) {
if (Clients[i] && !Clients[i].connected()) {
Clients[i].stop();
Serial.print("Client #");
Serial.print(i);
Serial.println(" disconnected");
}
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
Hello,
I have been using this library for months without an issue....however... i can simulate a crash on demand.
ESP8266 wemos D1 mini.
SoftAP (Soft access point only)
serial data comes on on Software serial port and is sent out ot telnet stream. Any client that connects can see the telnetstream.
This all works fine for months.
To cause a crash, i connect to the wemos server let the stream start then disconnect from the server. On my windows laptop its just connect and disconnect. On disconnect, the system crashes. If i run the code with telnetstream commented out and replaced with a print statement, no crashes occur.
I have tried TelnetStream2 and dont get the crashes, however, TelnetStream2 only supports one client at a time.
Regards and thanks
Hello all.
I have spent ages on this including google, with no success.
I have client software on other ESP devices that log onto this server ESP32..so far so good.
Serial data is fed into the serial port and sent out to any connected ESP, which in turn is send via that ESP's serial port. A serial bridge if you will. Any data fed into the sever serial port, is streamed out to the other client serial ports.
My Issue
My repeatable issue is, if I have a few ESP's connected to the server and one is unplugged or resets, all serial data just stops. I am guessing the server is waiting for that client to connect.
THE QUESTION
Does anyone know a good way to have a client ignored vie the telnetstream? ie just keep sending to the other ports.
The code below is stripped down just to show the function
//###################################
#include <WiFi.h>
#include <TelnetStream.h>
#include <SoftwareSerial.h>
#define serial_2_rx 23 //ESP32
TelnetStreamClass telnet1(10112);
/////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
void readSerial2() {
while (Serial2.available()) {
char c2 = Serial2.read();
telnet1.print(c2);
Serial.print(c2);
}
}
////////// SETUP ////////////////
void setup() {
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, serial_2_rx, -1);
// WiFi.softAP("test", "");
// put your setup code here, to run once:
WiFi.softAP("test", "");
telnet1.begin();
Serial.println("Connected to the WiFi network");
}
////////////////// LOOP /////////////////////////
void loop() {
readSerial2();
}
I am using telnestream to send data to mutiple clients. Ie, serial data in, gets sent to telnetstream.
Now and then, a client drops off line and leaves a port open. after some time, i run out of ports.
I use CPU.reset() every hour just to clear the ports back to zero.
Is there a way of checking how many clients are connected?
Using TCP server i can, but i am not using TCP server.
PS, yes, I have looked on google before posting here.
Thank you
Hi
I'm looking for some example of Telnet Terminal with an ESP32 in AP mode, when I connected my pc to the esp 32 wifi connection, I use putty with IP 192.168.4.1
but it didn't work
could some one help me ?
Thank you
I have been using your streamclass with my code, with great succes I might add.
I just want to understand, you do NOT implement the RFC854 (https://tools.ietf.org/html/rfc854) specfication. Instead your class is a tcp wrapper class, that behaves like a serial stream (or any other stream for that matter).
Thus my question is: Am I correct it is basically a serial /stream over tcp implementation?
void TelnetStreamClass::flush() {
if (disconnected())
return;
//return client.flush();
// should read
client.flush();
}
Not an issue, but i was wondering if there is a command to test if someone is connected. I can test e.g.
while(TelnetStream.available()) ....
but is there a test to determine if anyone has even opened the telnet stream?
Got an application in which the telnet is scarcely used, so a test for a client would be more time conserving I guess....
Thanks!
Hi,
I deployed this for the first time about 9 months ago on a couple of IOT sensors around my house. It initially worked fine so I suspect my code but don't know how to diagnose.
I constantly get "Connection Refused" from all my sensors. OTA still works so I don't think it's routing or firewall and I've tried a couple of different telnet clients and devices - all with the same problem.
Can you advise: common mistakes that could cause this (and if possible how to fix) error, and/or how to get more information other than Connection Refused (i.e. a connection refused reason).
This is all on ESP8266 (1 NodeMCU and a couple of D1 Minis).
Thanks in advance
Cannot compile with esp8266 version 3.1.1
Multiple errors
error: type 'Print' is not a base type for type 'ArduinoWiFiServer'
110 | using Print::write;
warning: 'WiFiClient WiFiServer::available(uint8_t*)' is deprecated: Renamed to accept(). [-Wdeprecated-declarations]
42 | WiFiClient accept() {return WiFiServer::available();}
Hi. Thanks.
I'm using the Arduino IDE most recent version on Win 11 and just moved to Espressif's ESP32 3.0.0 Board package from 2.0.17.
Getting new error messages not seen with previous Espressif ESP32 2.0.x versions. Been using your TelnetStream library for years. Love it!
Any thoughts?
Thanks again.
c:\Users\thor\Dropbox\My Documents\Arduino\libraries\NetApiHelpers\src/ServerTemplate.h: In instantiation of 'class ServerTemplate<NetworkServer, NetworkClient>':
c:\Users\thor\Dropbox\My Documents\Arduino\libraries\TelnetStream\src/TelnetStream.h:27:13: required from here
c:\Users\thor\Dropbox\My Documents\Arduino\libraries\NetApiHelpers\src/ServerTemplate.h:116:16: error: type 'Print' is not a base type for type 'ServerTemplate<NetworkServer, NetworkClient>'
116 | using Print::write;
| ^~~~~
c:\Users\thor\Dropbox\My Documents\Arduino\libraries\NetApiHelpers\src/ServerTemplate.h:70:18: error: 'size_t ServerTemplate<TServer, TClient>::write(uint8_t) [with TServer = NetworkServer; TClient = NetworkClient; size_t = unsigned int; uint8_t = unsigned char]' marked 'override', but does not override
70 | virtual size_t write(uint8_t b) override {
| ^~~~~
c:\Users\thor\Dropbox\My Documents\Arduino\libraries\NetApiHelpers\src/ServerTemplate.h:74:18: error: 'size_t ServerTemplate<TServer, TClient>::write(const uint8_t*, size_t) [with TServer = NetworkServer; TClient = NetworkClient; size_t = unsigned int; uint8_t = unsigned char]' marked 'override', but does not override
74 | virtual size_t write(const uint8_t *buf, size_t size) override {
| ^~~~~
c:\Users\thor\Dropbox\My Documents\Arduino\libraries\NetApiHelpers\src/ServerTemplate.h:118:16: error: 'void ServerTemplate<TServer, TClient>::flush() [with TServer = NetworkServer; TClient = NetworkClient]' marked 'override', but does not override
118 | virtual void flush() override {
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 <WiFiS3.h>
#include <ArduinoOTA.h>
#include <TelnetStream.h>
#include <TimeLib.h>
#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));
}
In the ESP32 example "TelentStreamEsp32Test", if I replace the loop with:
void loop()
{
//TelnetStream.read();
TelnetStream.println("this won't work");
delay(100);
}
I see nothing when I telnet in. However if I then un-comment the 1st line, it works.
Also see example here (line 14):
Ive been trying to compile https://github.com/SensorsIot/ESP32-OTA.git on arduinodroid, specifically the
code and i keep getting
/src/TelnetStream.h:27:13: error: cannot declare field 'TelnetStreamClass::server' to be of abstract type 'EthernetServer'
I think it may be cause of an update somewhere along the way, i'm sorry if this is the wrong way of doing this, i'm still learning, and have no clue where to start fixing this...
TelnetStream.stop(); doesn't stop. I expect the connection to be dropped/disconnected on the client side, however nothing happens and instead I am still connected and receiving telnet messages. I am using ESP32-CAM
Hi, I'm having compilation errors with the library.
I'm working on an Arduino Mega with an Ethernet shield that works with the standard Ethernet library.
However this is the errors I get when I try uploading the TelnetPrintEthTest example:
c:\Users\...\Documents\Arduino\libraries\TelnetStream\src\TelnetStream.cpp: In member function 'virtual void TelnetStreamClass::flush()':
c:\Users\...\Documents\Arduino\libraries\TelnetStream\src\TelnetStream.cpp:66:10: error: 'class EthernetServer' has no member named 'flush' server.flush();
Not a bug, just a suggestion to make your library easier to use whenever you have a lot of .print or .println of your object
It is a lot to type "TelnetStream.print(whatever I want to print)
Would be better to be able to do this:
TelnetStream ts; // create new object
and then be able to do:
ts.print(whatever I want);
Hi Juraj,
First, many thanks for TelnetStream. It turned out to be just what I wanted to implement a simple digital clock display (). Unfortunately, it seems that a recent ESP8266 core code update is causing us problems. My code suddenly started giving compile errors (non-fatal) and telnet stopped working.
In file included from .pio/libdeps/esp01_1m/TelnetStream/src/NetTypes.h:30,
from .pio/libdeps/esp01_1m/TelnetStream/src/TelnetStream.h:22,
from /home/PlatformIO/ESP01S_DS3231/src/alarm.ino:46:
/home/.platformio/packages/framework-arduinoespressif8266/libraries/Ethernet/src/Ethernet.h:39: warning: "MAX_SOCK_NUM" redefined
39 | #define MAX_SOCK_NUM 8
|
In file included from /home/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/ESP8266WiFi.h:28,
from /home/PlatformIO/ESP01S_DS3231/src/alarm.ino:42:
/home/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/wl_definitions.h:42: note: this is the location of the previous definition
42 | #define MAX_SOCK_NUM 4
|
In file included from /home/.platformio/packages/framework-arduinoespressif8266/libraries/ArduinoOTA/ArduinoOTA.h:5,
from /home/PlatformIO/ESP01S_DS3231/src/alarm.ino:47:
/home/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiUdp.h:28: warning: "UDP_TX_PACKET_MAX_SIZE" redefined
28 | #define UDP_TX_PACKET_MAX_SIZE 8192
|
In file included from .pio/libdeps/esp01_1m/TelnetStream/src/NetTypes.h:30,
from .pio/libdeps/esp01_1m/TelnetStream/src/TelnetStream.h:22,
from /home/PlatformIO/ESP01S_DS3231/src/alarm.ino:46:
/home/.platformio/packages/framework-arduinoespressif8266/libraries/Ethernet/src/Ethernet.h:150: note: this is the location of the previous definition
150 | #define UDP_TX_PACKET_MAX_SIZE 24
It seems like the __has_include(Ethernet.h) is causing the problem, so to fix my specific issue, I simply commented-out the whole section:-
// #elif __has_include(<Ethernet.h>)
// #include <Ethernet.h>
// #define NetClient EthernetClient
// #define NetServer EthernetServer
This gets us back to a clean compile and a working application.
Thought you might like to know, just in case anyone else sees the same thing.
Best wishes from Japan,
-John-
It so appears that at startup the client buffer is not empty. After some debugging the buffer had some 28 characters in the buffer containing meaningless info. As I 'poll' every 2 secs for a possible input (read) it took a while to react before the buffer was empty. Also after inputting a single character through Telnet it of course registers 3 chars, ending with \r\n (return & newline). That means that after a character read it has to poll again through the buffer to empty the \r\n
I added the following code:
while(TelnetStream.available())
TelnetStream.read(); // empty buffer. Required because at startup the buffer is filled with garbage
// and after a single letter command there is still a return and Newline.
However some sort of client flush command would be nice.
Thanks
Referring the #30 I see that now the sketch compiles but it seems no any telnet server is available.
Any suggestion?
it returns error when compile for Arduino OPTA
`/Users/xxx/Documents/Arduino/libraries/TelnetStream/src/TelnetStream.cpp: In member function 'boolean TelnetStreamClass::disconnected()':
/Users/xxx/Documents/Arduino/libraries/TelnetStream/src/TelnetStream.cpp:27:7: error: no match for 'operator!' (operand type is 'arduino::EthernetServer')
if (!server)
^~~~~~~
/Users/xxx/Documents/Arduino/libraries/TelnetStream/src/TelnetStream.cpp:27:7: note: candidate: operator!(bool)
/Users/xxx/Documents/Arduino/libraries/TelnetStream/src/TelnetStream.cpp:27:7: note: no known conversion for argument 1 from 'arduino::EthernetServer' to 'bool'
exit status 1
Compilation error: exit status 1`
I'm using TelnetStream and it works, but only if I connect in a narrow window of time after I connect to my AP. If I try too early I get Connection Refused and if I'm too late I get a >
prompt. At that prompt nothing happens no matter what I type. I'm only using output commands like TelnetStream.print
for debugging. I'm not checking for input. Is there something I can type at the prompt to enable printing? Do I have to check for something coming in? I'm on an esp8266 esp12-e.
Should I use TelnetPrint?
This is not an issue but a question:
Is it possible to make a function that both outputs Serial.print and telnetStream.print (and the others, like printnl() and printf() etc).
I know have to program for both outputs e.g.
Serial.print("foobar");
telnetStream.print("foobar");
and
Serial.printf("%i", integervalue);
telnetStream.printf("%i", integervalue);
To keep the code simple and readable I'd like to combine the two output commands to e.g.
message.print("foobar");
message.printf("%i", some integer);
At which the output ("foobar") is both printed to the serial output as to the telnet client.
Thanks.
Is it possible to declare two instances of TelnetStream?
I am sending data to several units and wanted a different channel for specific data, rather than using the serial port.
Esp32 serial port resets the micro each time you connect a terminal to the port.
Ie
TelnetStream Telnet1(23)
Telnet Stream Telnet2(100)
I used TelnetPrint on some ESP32.
Now I wanted to use it on an ESP8266.
Here it happens that after some runtime a connection via port 23 can still be established, but no more data is sent from the ESP to the client.
I only use TelnetPrint.println TelnetPrint.print for debugging
My system
ESP8266 ESP01
ESP 2.7.4
ThingSpeak
ESP8266WebServer
ESP8266HTTPClient
ArduinoOTA
On the ESP32 this does not happen with the same code.
Is it possible that this is caused by WLAN interruptions?
The ESPs are installed in an area where WLAN is only available at certain times.
gcc linker fails TelnetStreamEthTest example with EthernetENC library on all architectures with "EthernetServer.cpp.o: plugin needed to handle lto object"
this is some error of gcc with arduino dot-a-linked library
the TelnetPrintEthTest verifies without problems.
possible workarounds:
dot_a_linkage=true
. consequence is a larger build resultError when compiling 1.3.0 version.
.pio/libdeps/esp32dev/NetApiHelpers/src/ServerTemplate.h:118:16: error: 'void ServerTemplate<TServer, TClient>::flush() [with TServer = WiFiServer; TClient = WiFiClient]' marked 'override', but does not override
it was not there on 1.2.4 version.
Will you please remove line 29 from TelnetStream.cpp?
Sometime someone will enter a capital “C” and than the connection is closed.
Maybe you can code a more exceptional exit like “quit” or .. “exit”.
Would be much appreciated!
It is a great library that I use in all of my esp projects!
Hello everyone!
I have a problem with this library... When using
TelnetStream.flush();
TelnetStream.stop();
ESP32 does not close the communication.
I attach my code here so you can help me. The idea of this code is to close the communication when 'C' is written in the terminal. It works because the message "Closing the Telnet Communication..." is displayed but the communication remains effective.
Thanks in advance for your help !
#include <TelnetStream.h>
void setupOTA() {
Serial.println("Starting Telnet Communication...");
TelnetStream.begin();
Serial.println("Telnet Initialized!");
Serial.println("You can open a new terminal and write the command:\n$ telnet " + WiFi.localIP().toString());
}
void debug(const char* string) {
Serial.print(string);
TelnetStream.print(String(string));
}
void debugln(const char* string) {
Serial.println(string);
TelnetStream.println(String(string));
}
void handle() {
switch (TelnetStream.read()) {
case 'C':
TelnetStream.println("\nClosing the Telnet Communication...");
TelnetStream.flush();
TelnetStream.stop();
break;
case 'R':
debugln("\nRebooting...");
ESP.restart();
break;
}
}
I would like to use TelnetStream to have an option to have a telnet connection for remote debugging. However, it does not work with Arduino Core. Any chance that it will get an update?
It does not compile with esp8266 in arduino ide 1.8.19
Arduino:1.8.19 (Linux), Tarjeta:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
In file included from /home/chepecarlos/Arduino/libraries/TelnetStream/src/NetTypes.h:28,
from /home/chepecarlos/Arduino/libraries/TelnetStream/src/TelnetStream.h:22,
from /tmp/arduino_modified_sketch_653462/TelnetStreamEsp32Test.ino:3:
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h: In constructor 'ArduinoWiFiServer::ArduinoWiFiServer(const IPAddress&, uint16_t)':
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h:37:82: error: no matching function for call to 'WiFiServer::WiFiServer(const IPAddress&, uint16_t&)'
37 | ArduinoWiFiServer(const IPAddress& addr, uint16_t port) : WiFiServer(addr, port) {}
| ^
In file included from /home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFi.h:32,
from /tmp/arduino_modified_sketch_653462/TelnetStreamEsp32Test.ino:1:
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFiServer.h:36:3: note: candidate: 'WiFiServer::WiFiServer(uint16_t)'
36 | WiFiServer(uint16_t);
| ^~~~~~~~~~
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFiServer.h:36:3: note: candidate expects 1 argument, 2 provided
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFiServer.h:31:7: note: candidate: 'constexpr WiFiServer::WiFiServer(const WiFiServer&)'
31 | class WiFiServer : public Server {
| ^~~~~~~~~~
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFiServer.h:31:7: note: candidate expects 1 argument, 2 provided
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFiServer.h:31:7: note: candidate: 'constexpr WiFiServer::WiFiServer(WiFiServer&&)'
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFiServer.h:31:7: note: candidate expects 1 argument, 2 provided
In file included from /home/chepecarlos/Arduino/libraries/TelnetStream/src/NetTypes.h:28,
from /home/chepecarlos/Arduino/libraries/TelnetStream/src/TelnetStream.h:22,
from /tmp/arduino_modified_sketch_653462/TelnetStreamEsp32Test.ino:3:
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h: In member function 'virtual size_t ArduinoWiFiServer::write(const uint8_t*, size_t)':
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h:77:32: error: 'ESTABLISHED' was not declared in this scope
77 | if (client.status() == ESTABLISHED) {
| ^~~~~~~~~~~
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h:90:32: error: 'ESTABLISHED' was not declared in this scope
90 | if (client.status() == ESTABLISHED && client.availableForWrite() > 0) {
| ^~~~~~~~~~~
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h: In member function 'ArduinoWiFiServer::operator bool()':
/home/chepecarlos/Arduino/libraries/TelnetStream/src/ArduinoWiFiServer.h:123:40: error: 'LISTEN' was not declared in this scope
123 | operator bool() {return (status() == LISTEN);}
| ^~~~~~
/tmp/arduino_modified_sketch_653462/TelnetStreamEsp32Test.ino: In function 'void setup()':
TelnetStreamEsp32Test:18:14: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
18 | WiFi.begin(ssid, pass);
| ^~~~
| |
| const char*
In file included from /tmp/arduino_modified_sketch_653462/TelnetStreamEsp32Test.ino:1:
/home/chepecarlos/5.Programas/3.Desarrollo/1.Arduino/arduino-1.8.19/libraries/WiFi/src/WiFi.h:79:21: note: initializing argument 1 of 'int WiFiClass::begin(char*, const char*)'
79 | int begin(char* ssid, const char passphrase);
| ~~~~~~^~~~
TelnetStreamEsp32Test:19:12: error: 'class WiFiClass' has no member named 'waitForConnectResult'
19 | if (WiFi.waitForConnectResult() != WL_CONNECTED) {
| ^~~~~~~~~~~~~~~~~~~~
exit status 1
invalid conversion from 'const char' to 'char*' [-fpermissive]
Este informe podría contener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.
Hi, I use PlatformIO and would like to use Telnetstream.
While compiling I get the the following errors.
Compiling .pio\build\picow\lib430\TelnetStream\TelnetStream.cpp.o
Compiling .pio\build\picow\lib7a1\NetApiHelpers\MACAddress.cpp.o
Indexing .pio\build\picow\lib8be\libUpdater.a
Compiling .pio\build\picow\lib2fe\lwIP_w5100\utility\w5100.cpp.o
Compiling .pio\build\picow\liba70\http-parser\http_parser.c.o
Compiling .pio\build\picow\lib33b\WebServer\HTTPServer.cpp.o
Compiling .pio\build\picow\lib33b\WebServer\Parsing.cpp.o
Compiling .pio\build\picow\lib33b\WebServer\detail\mimetable.cpp.o
Compiling .pio\build\picow\lib549\Wire\Wire.cpp.o
Compiling .pio\build\picow\lib9e3\LEAmDNS\ESP8266mDNS.cpp.o
Compiling .pio\build\picow\lib9e3\LEAmDNS\LEAmDNS.cpp.o
In file included from .pio\libdeps\picow\TelnetStream\src\TelnetPrint.h:4,
from .pio\libdeps\picow\TelnetStream\src\TelnetPrint.cpp:1:
.pio\libdeps\picow\TelnetStream\src\NetTypes.h:78:10: fatal error: NetApiHelpers.h: No such file or directory
***********************************************************************
* Looking for NetApiHelpers.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:NetApiHelpers.h"
* Web > https://registry.platformio.org/search?q=header:NetApiHelpers.h
*
***********************************************************************
78 | #include <NetApiHelpers.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
In file included from .pio\libdeps\picow\TelnetStream\src\TelnetStream.h:22,
from .pio\libdeps\picow\TelnetStream\src\TelnetStream.cpp:1:
.pio\libdeps\picow\TelnetStream\src\NetTypes.h:78:10: fatal error: NetApiHelpers.h: No such file or directory
***********************************************************************
* Looking for NetApiHelpers.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:NetApiHelpers.h"
* Web > https://registry.platformio.org/search?q=header:NetApiHelpers.h
*
***********************************************************************
78 | #include <NetApiHelpers.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
Archiving .pio\build\picow\libccb\libWiFi.a
*** [.pio\build\picow\lib430\TelnetStream\TelnetPrint.cpp.o] Error 1
*** [.pio\build\picow\lib430\TelnetStream\TelnetStream.cpp.o] Error 1
Indexing .pio\build\picow\libccb\libWiFi.a
My platformio.ini:
[env]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
framework = arduino
board_build.core = earlephilhower
build_type = release
debug_tool = picoprobe
board_build.filesystem_size = 1m
[env:pico]
board = rpipico
lib_deps =
bblanchon/ArduinoJson@^7.0.4
jandelgado/JLed@^4.13.1
jandrassy/TelnetStream@^1.3.0
jandrassy/NetApiHelpers@^1.0.1
[env:picow]
board = rpipicow
lib_deps =
bblanchon/ArduinoJson@^7.0.4
jandelgado/JLed@^4.13.1
jandrassy/TelnetStream@^1.3.0
jandrassy/NetApiHelpers@^1.0.1
As you can see I actually also include "NetApiHelpers" but I would not recognise it somehow.
Does anybody have ideas why? Thanks.
Considering that this library has been existent for quite some time now and is pretty stable, I suggest that this be added to Arduino's library manager. In order to do that a tag needs to be created with the version number in library.properties
and an issue needs to be opened at https://github.com/arduino/Arduino/issues with title [Library Manager] TelnetStream Library
and the URL to this library in the issue body.
It would really be nice if there was a
TelnetSerial.connected()
function available
As a "work-around" I have moved
bool disconnected()
from private to public in the .h file.
The log() function of the example I added at the top:
if (TelnetStream.disconnected()) {
Console = &Serial;
} else {
Console = &TelnetStream;
}
Now everything send to log() will be printed to the telnet connection, if available, otherwise it will be printed on the console (Serial).
This code already closes Telnet:
TelnetStream.println("bye bye");
TelnetStream.flush();
// TelnetStream.stop();
break;
At other places in my program every time I flush() Telnet closes.
Is is supposed to work that way?
In my setup i am only sending data via telnet stream, but i do not read data from the stream.
Without reading data, after having 5 connected clients, it is not possible to connect another client, even if the old clients are disconnected.
This is due to the fact, that my client (putty) seems to send some messages on connection/disconnection.
In that case, without ever reading the data from the client, client.avilable()
will always be true, event if client.disconnected()
is also true.
Hence this section of ArduinoWiFiServerEsp.h
will never accept new clients even if the clients are long disconnected.
void acceptClients() {
for (uint8_t i = 0; i < MAX_MONITORED_CLIENTS; i++) {
if (!connectedClients[i]) {
connectedClients[i] = accept();
}
}
}
Use this simple sketch, and connect 5 putty clients. Connecting a 6th client will fail, even if the previous ones are already closed.
Commenting in the last section will fix the issue, as we are reading the data, e.g. flushing the input buffer. Then client.avalibale()
will be false.
#include <Arduino.h>
#include <string>
#include <ESP8266WiFi.h>
#include <TelnetStream.h>
#include "credentials.h"
void setup(void)
{
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID,WIFI_PASS);
Serial.begin(115200);
TelnetStream.begin();
Serial.println("Start Telnet Stream test");
}
void loop(void) {
static unsigned long lastSent = 0;
static unsigned long cnt = 0;
unsigned long now = millis();
if (now-lastSent>1000) {
char msg[20];
sprintf(msg, "Sending message %lu", cnt);
Serial.println(msg);
TelnetStream.println(msg);
cnt++;
lastSent = now;
}
/*Enable this part makes clients disconnect properly
std::string rxMsg;
while (TelnetStream.available()){
rxMsg += char(TelnetStream.read());
}
if (rxMsg.length() > 0)
Serial.printf("Rx Message: %s",rxMsg.c_str());
*/
}
Environment
[env:TelnetLogging2]
platform = [email protected]
board = d1_mini
framework = arduino
lib_deps =
https://github.com/jandrassy/TelnetStream#1.2.4
A possible fix would be to flush the input buffer, as soon as we have a pending connection, which is closed, but still has data available.
diff --git a/src/ArduinoWiFiServerESP.h b/src/ArduinoWiFiServerESP.h
index 9ce5860..b300892 100644
--- a/src/ArduinoWiFiServerESP.h
+++ b/src/ArduinoWiFiServerESP.h
@@ -129,6 +129,11 @@ private:
void acceptClients() {
for (uint8_t i = 0; i < MAX_MONITORED_CLIENTS; i++) {
+ if (connectedClients[i] && !connectedClients[i].connected()) {
+ while (connectedClients[i].available()){
+ Serial.printf("REad bytes from client %i",connectedClients[i].read());
+ }
+ }
if (!connectedClients[i]) {
connectedClients[i] = accept();
}
But as the ArduinoWiFiServer
is now part of the framwork-arudinoespressif8266 it would have to be fixed in serveral places.
Moreover reading the lastWill data of an already disconnected client could be a use case as well, so just throwing away the input buffer seems to be not the best idea, especially in other non telnetStream related applications.
Do you have any better suggestion?
Do you even consider this to be a bug, or is it just in the users responsibility to read the data from the stream as well and live with the pending connections if he/she doesn't do so.
Thanks for your reply,
Best regards
I ran into the same issue as this: #17, so I am currently trying to use the git master version instead of the release.
This does unfortunately not work for me either, I get these errors during compile, even when simply trying to compile the "TelnetStreamEsp8266Test"-example (to make sure that the issue is not related to my coding:
`> Executing task: C:\Users\Northy.platformio\penv\Scripts\platformio.exe run <
Verbose mode can be enabled via -v, --verbose
option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_lite.html
PLATFORM: Espressif 8266 (3.2.0) > WeMos D1 mini Lite
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES:
TelnetStream' c:/users/northy/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\d1_mini_lite\src\main.cpp.o:(.text.setup+0x30): undefined reference to
_ZN17TelnetStreamClass5beginEi'setup': main.cpp:(.text.setup+0xfa): undefined reference to
_ZN17TelnetStreamClass5beginEi'_ZN17TelnetStreamClass4readEv' c:/users/northy/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\d1_mini_lite\src\main.cpp.o:(.text.loop+0xc): undefined reference to
_ZN17TelnetStreamClass4stopEv'_ZN17TelnetStreamClass5flushEv' c:/users/northy/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\d1_mini_lite\src\main.cpp.o:(.text.loop+0x26): undefined reference to
_ZN17TelnetStreamClass4readEv'loop': main.cpp:(.text.loop+0x38): undefined reference to
_ZN17TelnetStreamClass4stopEv'_ZN17TelnetStreamClass5flushEv' c:/users/northy/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: main.cpp:(.text.loop+0x62): undefined reference to
_ZN17TelnetStreamClass4stopEv'Just a heads up, flush() has been removed in ESP32 3.0.0.
https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html
Compiling telnetstream.h fails with:
In file included from c:\Arduino\Code\libraries\NetApiHelpers\src/ArduinoWiFiServer.h:48,
from c:\Arduino\Code\libraries\TelnetStream\src/NetTypes.h:38,
from c:\Arduino\Code\libraries\TelnetStream\src/TelnetStream.h:22,
from C:\Arduino\Code\Human-Precense\LD2410\SensorSetupOTA_MultiWiFi\OTA.h:12,
from C:\Arduino\Code\Human-Precense\LD2410\SensorSetupOTA_MultiWiFi\SensorSetupOTA_MultiWiFi.ino:6:
c:\Arduino\Code\libraries\NetApiHelpers\src/ServerTemplate.h: In instantiation of 'class ServerTemplate<NetworkServer, NetworkClient>':
c:\Users\Robert\Dropbox\Cisco\ESP8266 ESP32\Arduino\Code\libraries\TelnetStream\src/TelnetStream.h:27:13: required from here
c:\Arduino\Code\libraries\NetApiHelpers\src/ServerTemplate.h:116:16: error: type 'Print' is not a base type for type 'ServerTemplate<NetworkServer, NetworkClient>'
116 | using Print::write;
| ^~~~~
c:\Arduino\Code\libraries\NetApiHelpers\src/ServerTemplate.h:70:18: error: 'size_t ServerTemplate<TServer, TClient>::write(uint8_t) [with TServer = NetworkServer; TClient = NetworkClient; size_t = unsigned int; uint8_t = unsigned char]' marked 'override', but does not override
70 | virtual size_t write(uint8_t b) override {
| ^~~~~
c:\Arduino\Code\libraries\NetApiHelpers\src/ServerTemplate.h:74:18: error: 'size_t ServerTemplate<TServer, TClient>::write(const uint8_t*, size_t) [with TServer = NetworkServer; TClient = NetworkClient; size_t = unsigned int; uint8_t = unsigned char]' marked 'override', but does not override
74 | virtual size_t write(const uint8_t *buf, size_t size) override {
| ^~~~~
c:\Arduino\Code\libraries\NetApiHelpers\src/ServerTemplate.h:118:16: error: 'void ServerTemplate<TServer, TClient>::flush() [with TServer = NetworkServer; TClient = NetworkClient]' marked 'override', but does not override
118 | virtual void flush() override {
| ^~~~~
exit status 1
Compilation error: exit status 1
73 de \Spangen
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.