Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JAndrassy/TelnetStream
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.2.6
Choose a base ref
...
head repository: JAndrassy/TelnetStream
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Nov 26, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d63a8ce View commit details

Commits on Jul 20, 2024

  1. Copy the full SHA
    044ef73 View commit details

Commits on Aug 2, 2024

  1. NetTypes - WiFiEspAT v2 support

    and EthernetEspAT support (#elif moved above "has Ethernet.h|)
    JAndrassy committed Aug 2, 2024
    Copy the full SHA
    d59b586 View commit details

Commits on Aug 3, 2024

  1. Copy the full SHA
    ac640b8 View commit details
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,16 @@ TelnetStream.h can be included not only in the ino file, but in cpp files of the

Version 1.2.0 introduced TelnetPrint object, a simpler and smaller alternative to TelnetStream. Basically it is only EthernetServer or WiFiServer instanced for use anywhere in your sketch or libraries.

TelnetStream/TelnetPrint works as it is with esp8266 and esp32 WiFi library, with the Ethernet and EthernetENC, with WiFiNINA, WiFi101, WiFiS3 and WiFiEspAT library. The RP2040 Pico Core networking libraries are supported as well.
TelnetStream/TelnetPrint works as it is with:

* esp8266 and esp32 WiFi library (including the wired network interfaces)
* Ethernet and EthernetENC library
* WiFiNINA, WiFi101 and WiFiEspAT library
* Renesas Core WiFiS3 and WiFiC3 libraries
* WiFi library of the RP2040 Pico Core (including the wired network interfaces)
* WiFi and PortentaEthernet library of the Mbed Core

Version 1.3.0 has NetApiHelpers library as dependency. NetApiHelpers library provides Arduino Server for networking libraries without print-to-all-clients functionality in their Server implementation: ESP8266WiFi, ESP32 WiFi, RP2040 Core and Mbed Core.

The library is in Library Manager. You can install it there.

88 changes: 88 additions & 0 deletions examples/TelnetStreamSerialEthTest/TelnetStreamSerialEthTest.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <EthernetEspAT.h>
#include <TimeLib.h>
#include <TelnetStream.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup() {

Serial.begin(115200);
while (!Serial);

Serial1.begin(115200);
Ethernet.init(Serial1);

if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}

Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}

WiFi.sntp("us.pool.ntp.org");
Serial.println("Waiting for SNTP");
while (!Ethernet.getTime()) {
delay(1000);
Serial.print('.');
}
setTime(Ethernet.getTime());

IPAddress ip = Ethernet.localIP();
Serial.println();
Serial.print("Connect with Telnet client to ");
Serial.println(ip);

TelnetStream.begin();
}

void loop() {

switch (TelnetStream.read()) {
case 'C':
TelnetStream.println("bye bye");
TelnetStream.flush();
TelnetStream.stop();
break;
}

static unsigned long next;
if (millis() - next > 5000) {
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));
TelnetStream.flush();
}
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
#include <TimeLib.h>
#include <TelnetStream.h>

const int8_t TIME_ZONE = 2; // UTC + 2

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

@@ -25,7 +23,7 @@ void setup() {
}
Serial.println();

WiFi.sntp(TIME_ZONE, "us.pool.ntp.org");
WiFi.sntp("us.pool.ntp.org");

Serial.println("Waiting for SNTP");
// while (!WiFi.getTime()) {
@@ -71,4 +69,5 @@ void log() {
TelnetStream.print(timeStr);
TelnetStream.print(" A0: ");
TelnetStream.println(analogRead(A0));
TelnetStream.flush();
}
3 changes: 2 additions & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TelnetStream
version=1.2.6
version=1.3.0
author=Juraj Andrassy
maintainer=Juraj Andrassy <juraj.andrassy@gmail.com>
sentence=Stream implementation over telnet for OTA debuging
@@ -9,3 +9,4 @@ url=https://github.com/jandrassy/TelnetStream
architectures=*
includes=TelnetStream.h,TelnetPrint.h
dot_a_linkage=true
depends=NetApiHelpers
146 changes: 0 additions & 146 deletions src/ArduinoWiFiServerESP.h

This file was deleted.

37 changes: 28 additions & 9 deletions src/NetTypes.h
Original file line number Diff line number Diff line change
@@ -26,16 +26,16 @@ repository https://github.com/jandrassy
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#if (ARDUINO_ESP8266_MAJOR < 3)
#include "ArduinoWiFiServerESP.h"
#else
#include <ArduinoWiFiServer.h> // in ESP8266WiFi library
#include <NetApiHelpers.h>
#endif
#include <ArduinoWiFiServer.h>
#define NetClient WiFiClient
#define NetServer ArduinoWiFiServer

#elif defined(ESP32)
#include <WiFi.h>
#include "ArduinoWiFiServerESP.h"
#include <NetApiHelpers.h>
#include <ArduinoWiFiServer.h>
#define NetClient WiFiClient
#define NetServer ArduinoWiFiServer

@@ -46,6 +46,24 @@ repository https://github.com/jandrassy
#define NetClient EthernetClient
#define NetServer EthernetServerPrint

#elif __has_include(<PortentaEthernet.h>)
#include <PortentaEthernet.h>
#include <NetApiHelpers.h>
#include <ArduinoEthernetServer.h>
#define NetClient EthernetClient
#define NetServer ArduinoEthernetServer

#elif __has_include(<WiFiEspAT.h>)
#include <WiFiEspAT.h>
#define NetClient WiFiClient
#if WIFIESPAT_LIB_VERSION < 2
#define NetServer WiFiServerPrint
#else
#include <NetApiHelpers.h>
#include <ArduinoWiFiServer.h>
#define NetServer ArduinoWiFiServer
#endif

#elif __has_include(<Ethernet.h>)
#include <Ethernet.h>
#define NetClient EthernetClient
@@ -56,14 +74,15 @@ repository https://github.com/jandrassy
#define NetClient WiFiClient
#define NetServer WiFiServer

#elif __has_include(<WiFiEspAT.h>)
#include <WiFiEspAT.h>
#elif __has_include(<WiFiC3.h>)
#include <WiFiC3.h>
#define NetClient WiFiClient
#define NetServer WiFiServerPrint
#define NetServer WiFiServer

#elif defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)
#elif (defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)) || (defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_MBED_NANO))
#include <WiFi.h>
#include <ArduinoWiFiServerESP.h>
#include <NetApiHelpers.h>
#include <ArduinoWiFiServer.h>
#define NetClient WiFiClient
#define NetServer ArduinoWiFiServer