From de3ea252e58a3ef94467bad45796cb34591d02aa Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Thu, 12 Sep 2024 17:44:20 +0200 Subject: [PATCH 01/11] Added protected _newLineCharacter member --- src/ESPTelnet.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ESPTelnet.h b/src/ESPTelnet.h index 8bab293..88b585e 100755 --- a/src/ESPTelnet.h +++ b/src/ESPTelnet.h @@ -65,8 +65,12 @@ class ESPTelnet : public ESPTelnetBase { bool isLineModeSet(); void setLineMode(bool value = true); - protected: + bool getNewLineCharacter(); + void setNewLineCharacter(char value = '\n'); + + protected: bool _lineMode = true; + char _newLineCharacter = '\n'; void handleInput(); }; From 1197b1458643f5b52af277b0d1e0e72e32753b6f Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Thu, 12 Sep 2024 17:46:08 +0200 Subject: [PATCH 02/11] Added functions and removed hardcoded '\n' --- src/ESPTelnet.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ESPTelnet.cpp b/src/ESPTelnet.cpp index 69a8d76..d2f70e7 100755 --- a/src/ESPTelnet.cpp +++ b/src/ESPTelnet.cpp @@ -8,7 +8,7 @@ void ESPTelnet::handleInput() { char c = client.read(); // collect string if (_lineMode) { - if (c != '\n') { + if (c != _newLineCharacter) { if (c >= 32 && c < 127) { input += c; } @@ -81,4 +81,16 @@ void ESPTelnet::setLineMode(bool value /* = true */) { _lineMode = value; } -///////////////////////////////////////////////////////////////// \ No newline at end of file +///////////////////////////////////////////////////////////////// + +bool ESPTelnet::getNewLineCharacter() { + return _newLineCharacter; +} + +///////////////////////////////////////////////////////////////// + +void ESPTelnet::setNewLineCharacter(char value /* = '\n' */) { + _newLineCharacter = value; +} + +///////////////////////////////////////////////////////////////// From 4760333ab030fa613400848230c102ee5c714bfa Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Fri, 13 Sep 2024 11:57:26 +0200 Subject: [PATCH 03/11] Update README.md with setNewLineCharacter information --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 14def02..10355fc 100755 --- a/README.md +++ b/README.md @@ -45,9 +45,10 @@ If you find this library helpful please consider giving it a ⭐️ at [GitHub]( ### Output and Input -* Via `print()` and `println()` you can output text on the telnet server. +* Via `print()`, `printf()` and `println()` you can output text on the telnet server. * To receive and parse input from the telnet client you can add a handler via `onInputReceived()`. * By default, the library waits for a newline character from the client, and sends data to the callback handler one line at a time. This behaviour can be deactivated by calling `setlineMode(false)`. +* A default newline character `'\n'` is used to determine the end of a line. This can be overridden by by calling `setNewLineCharacter('\r')` where `'\r'` can be swapped with any character. ### Using stream functions @@ -193,6 +194,11 @@ These are the constructors and the member functions the library provides: Open the Arduino IDE choose "Sketch > Include Library" and search for "ESPTelnet". Or download the [ZIP archive](https://github.com/lennarthennigs/ESPTelnet/zipball/master), and choose "Sketch > Include Library > Add .ZIP Library..." and select the downloaded file. +The "ESPTelnet" library is also available on the PlatformIO registry and can be included by adding the following line to the leb_deps option of the platformio.ini file: +``` + lennarthennigs/ESP Telnet@^2.2.2 +``` + ## License MIT License From 4c2a6546db550888cc891a3f3df0e3c0f4c89e22 Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Mon, 16 Sep 2024 10:32:40 +0200 Subject: [PATCH 04/11] NewLine -> Newline --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10355fc..707b2a2 100755 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ If you find this library helpful please consider giving it a ⭐️ at [GitHub]( * Via `print()`, `printf()` and `println()` you can output text on the telnet server. * To receive and parse input from the telnet client you can add a handler via `onInputReceived()`. * By default, the library waits for a newline character from the client, and sends data to the callback handler one line at a time. This behaviour can be deactivated by calling `setlineMode(false)`. -* A default newline character `'\n'` is used to determine the end of a line. This can be overridden by by calling `setNewLineCharacter('\r')` where `'\r'` can be swapped with any character. +* A default newline character `'\n'` is used to determine the end of a line. This can be overridden by by calling `setNewlineCharacter('\r')` where `'\r'` can be swapped with any character. ### Using stream functions From f2ea1ff59134254326f6084870071a089b072202 Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Mon, 16 Sep 2024 10:34:15 +0200 Subject: [PATCH 05/11] Update ESPTelnet.h NewLine -> Newline --- src/ESPTelnet.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ESPTelnet.h b/src/ESPTelnet.h index 88b585e..49adfe8 100755 --- a/src/ESPTelnet.h +++ b/src/ESPTelnet.h @@ -65,12 +65,12 @@ class ESPTelnet : public ESPTelnetBase { bool isLineModeSet(); void setLineMode(bool value = true); - bool getNewLineCharacter(); - void setNewLineCharacter(char value = '\n'); + bool getNewlineCharacter(); + void setNewlineCharacter(char value = '\n'); protected: bool _lineMode = true; - char _newLineCharacter = '\n'; + char _newlineCharacter = '\n'; void handleInput(); }; From 7d9dfaba757d6f7338b703b9f27a8280aa7b6b83 Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Mon, 16 Sep 2024 10:35:34 +0200 Subject: [PATCH 06/11] Update ESPTelnet.cpp NewLine -> Newline --- src/ESPTelnet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ESPTelnet.cpp b/src/ESPTelnet.cpp index d2f70e7..0ae3483 100755 --- a/src/ESPTelnet.cpp +++ b/src/ESPTelnet.cpp @@ -83,13 +83,13 @@ void ESPTelnet::setLineMode(bool value /* = true */) { ///////////////////////////////////////////////////////////////// -bool ESPTelnet::getNewLineCharacter() { +char ESPTelnet::getNewlineCharacter() { return _newLineCharacter; } ///////////////////////////////////////////////////////////////// -void ESPTelnet::setNewLineCharacter(char value /* = '\n' */) { +void ESPTelnet::setNewlineCharacter(char value /* = '\n' */) { _newLineCharacter = value; } From 492180eb9c20ab615ac43fbcb426c66bc93cc69e Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Mon, 16 Sep 2024 10:36:17 +0200 Subject: [PATCH 07/11] Update ESPTelnet.h bool -> char return type --- src/ESPTelnet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ESPTelnet.h b/src/ESPTelnet.h index 49adfe8..a59b1b3 100755 --- a/src/ESPTelnet.h +++ b/src/ESPTelnet.h @@ -65,7 +65,7 @@ class ESPTelnet : public ESPTelnetBase { bool isLineModeSet(); void setLineMode(bool value = true); - bool getNewlineCharacter(); + char getNewlineCharacter(); void setNewlineCharacter(char value = '\n'); protected: From 15115e62ab4a2d0ec43d156880fda3bb397a6b7e Mon Sep 17 00:00:00 2001 From: Roy van Lierop Date: Mon, 16 Sep 2024 10:39:36 +0200 Subject: [PATCH 08/11] Update ESPTelnet.cpp NewLine -> Newline --- src/ESPTelnet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ESPTelnet.cpp b/src/ESPTelnet.cpp index 0ae3483..c7f2907 100755 --- a/src/ESPTelnet.cpp +++ b/src/ESPTelnet.cpp @@ -8,7 +8,7 @@ void ESPTelnet::handleInput() { char c = client.read(); // collect string if (_lineMode) { - if (c != _newLineCharacter) { + if (c != _newlineCharacter) { if (c >= 32 && c < 127) { input += c; } @@ -84,13 +84,13 @@ void ESPTelnet::setLineMode(bool value /* = true */) { ///////////////////////////////////////////////////////////////// char ESPTelnet::getNewlineCharacter() { - return _newLineCharacter; + return _newlineCharacter; } ///////////////////////////////////////////////////////////////// void ESPTelnet::setNewlineCharacter(char value /* = '\n' */) { - _newLineCharacter = value; + _newlineCharacter = value; } ///////////////////////////////////////////////////////////////// From 00ea08aac2470c1c82b8317f232d6f0e6b9749a9 Mon Sep 17 00:00:00 2001 From: Lennart Hennigs Date: Thu, 3 Oct 2024 09:04:46 +0200 Subject: [PATCH 09/11] updated --- CHANGELOG.md | 2 ++ keywords.txt | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5335d34..5022c8a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased (but available on Github) +- Added option to change the newLine character via `getNewlineCharacter()` and `setNewlineCharacter()` as suggest by [Roy](https://github.com/FunDeckHermit) in [#69](https://github.com/LennartHennigs/ESPTelnet/pull/69) + **Note:** Unreleased changes are checked in but not part of an official release (available through the Arduino IDE or PlatfomIO) yet. This allows you to test WiP features and give feedback to them. ## [2.2.1] – 2024-02-17 diff --git a/keywords.txt b/keywords.txt index 89eb47a..06c35e1 100755 --- a/keywords.txt +++ b/keywords.txt @@ -25,4 +25,6 @@ flush KEYWORD2 write KEYWORD2 printf KEYWORD2 getTimeoutInterval KEYWORD2 -setTimeoutInterval KEYWORD2 \ No newline at end of file +setTimeoutInterval KEYWORD2 +getNewlineCharacter KEYWORD2 +setNewlineCharacter KEYWORD2 \ No newline at end of file From 22961142a544251aef72477b7ea1e3348b8f5cd7 Mon Sep 17 00:00:00 2001 From: Lennart Hennigs Date: Thu, 3 Oct 2024 09:05:41 +0200 Subject: [PATCH 10/11] added newline functions to class def --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 707b2a2..d24a62d 100755 --- a/README.md +++ b/README.md @@ -149,6 +149,12 @@ These are the constructors and the member functions the library provides: void setKeepAliveInterval(int ms); int getKeepAliveInterval(); + bool isLineModeSet(); + void setLineMode(bool value = true); + + char getNewlineCharacter(); + void setNewlineCharacter(char value = '\n'); + void onConnect(CallbackFunction f); void onConnectionAttempt(CallbackFunction f); void onReconnect(CallbackFunction f); @@ -195,7 +201,8 @@ Open the Arduino IDE choose "Sketch > Include Library" and search for "ESPTelnet Or download the [ZIP archive](https://github.com/lennarthennigs/ESPTelnet/zipball/master), and choose "Sketch > Include Library > Add .ZIP Library..." and select the downloaded file. The "ESPTelnet" library is also available on the PlatformIO registry and can be included by adding the following line to the leb_deps option of the platformio.ini file: -``` + +``` json lennarthennigs/ESP Telnet@^2.2.2 ``` From fbeef52008450f6abf91e8021c418546bea08fb1 Mon Sep 17 00:00:00 2001 From: Lennart Hennigs Date: Thu, 3 Oct 2024 09:06:58 +0200 Subject: [PATCH 11/11] updated --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5022c8a..7637eee 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased (but available on Github) -- Added option to change the newLine character via `getNewlineCharacter()` and `setNewlineCharacter()` as suggest by [Roy](https://github.com/FunDeckHermit) in [#69](https://github.com/LennartHennigs/ESPTelnet/pull/69) +- Added option to change the newLine character via `getNewlineCharacter()` and `setNewlineCharacter()` as suggest by [Roy](https://github.com/FunDeckHermit) in [#69](https://github.com/LennartHennigs/ESPTelnet/pull/69) **Note:** Unreleased changes are checked in but not part of an official release (available through the Arduino IDE or PlatfomIO) yet. This allows you to test WiP features and give feedback to them.