Adding telnet thing for wireless debugging
This commit is contained in:
parent
7a998b9338
commit
70831df21d
@ -48,6 +48,25 @@ String message, webpage;
|
|||||||
ESP8266WebServer server(PORT);
|
ESP8266WebServer server(PORT);
|
||||||
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
|
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
|
||||||
|
|
||||||
|
// in a terminal: telnet esp IP
|
||||||
|
#ifdef DEBUG_TELNET
|
||||||
|
WiFiServer telnetServer(23);
|
||||||
|
WiFiClient telnetClient;
|
||||||
|
|
||||||
|
void handleTelnet(void) {
|
||||||
|
if (telnetServer.hasClient()) {
|
||||||
|
if (!telnetClient || !telnetClient.connected()) {
|
||||||
|
if (telnetClient) {
|
||||||
|
telnetClient.stop();
|
||||||
|
}
|
||||||
|
telnetClient = telnetServer.available();
|
||||||
|
} else {
|
||||||
|
telnetServer.available().stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void configModeCallback (WiFiManager *myWiFiManager) { // AP config mode
|
void configModeCallback (WiFiManager *myWiFiManager) { // AP config mode
|
||||||
display_message("Setup");
|
display_message("Setup");
|
||||||
}
|
}
|
||||||
@ -152,6 +171,11 @@ void loop() {
|
|||||||
yield();
|
yield();
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
yield();
|
yield();
|
||||||
|
|
||||||
|
#ifdef DEBUG_TELNET
|
||||||
|
// Handle Telnet connection for debugging
|
||||||
|
handleTelnet();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void display_message(String message){
|
void display_message(String message){
|
||||||
if (width * message.length() - spacer > matrix.width()) {
|
if (width * message.length() - spacer > matrix.width()) {
|
||||||
|
27
d_helper.cpp
27
d_helper.cpp
@ -2,30 +2,3 @@
|
|||||||
|
|
||||||
#include "d_helper.h"
|
#include "d_helper.h"
|
||||||
|
|
||||||
// in a terminal: telnet esp IP
|
|
||||||
#ifdef DEBUG_TELNET
|
|
||||||
WiFiServer telnetServer(23);
|
|
||||||
WiFiClient telnetClient;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// TELNET
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
/*
|
|
||||||
Function called to handle Telnet clients
|
|
||||||
https://www.youtube.com/watch?v=j9yW10OcahI
|
|
||||||
*/
|
|
||||||
#ifdef DEBUG_TELNET
|
|
||||||
void handleTelnet(void) {
|
|
||||||
if (telnetServer.hasClient()) {
|
|
||||||
if (!telnetClient || !telnetClient.connected()) {
|
|
||||||
if (telnetClient) {
|
|
||||||
telnetClient.stop();
|
|
||||||
}
|
|
||||||
telnetClient = telnetServer.available();
|
|
||||||
} else {
|
|
||||||
telnetServer.available().stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
32
d_helper.h
32
d_helper.h
@ -1,22 +1,22 @@
|
|||||||
#ifndef D_helper_h
|
#ifndef D_helper_h
|
||||||
#define D_helper_h
|
#define D_helper_h
|
||||||
|
|
||||||
void handleTelnet(void);
|
void handleTelnet(void);
|
||||||
|
|
||||||
// ################# Macros for debugging ################
|
// ################# Macros for debugging ################
|
||||||
|
|
||||||
#ifdef DEBUG_TELNET
|
#ifdef DEBUG_TELNET
|
||||||
#define DEBUG_PRINT(x) telnetClient.print(x)
|
#define DEBUG_PRINT(x) telnetClient.print(x)
|
||||||
#define DEBUG_PRINTF(x,y) telnetClient.printf(x,y)
|
#define DEBUG_PRINTF(x,y) telnetClient.printf(x,y)
|
||||||
#define DEBUG_PRINT_WITH_FMT(x, fmt) telnetClient.print(x, fmt)
|
#define DEBUG_PRINT_WITH_FMT(x, fmt) telnetClient.print(x, fmt)
|
||||||
#define DEBUG_PRINTLN(x) telnetClient.println(x)
|
#define DEBUG_PRINTLN(x) telnetClient.println(x)
|
||||||
#define DEBUG_PRINTLN_WITH_FMT(x, fmt) telnetClient.println(x, fmt)
|
#define DEBUG_PRINTLN_WITH_FMT(x, fmt) telnetClient.println(x, fmt)
|
||||||
#else
|
#else
|
||||||
#define DEBUG_PRINT(x) Serial.print(x)
|
#define DEBUG_PRINT(x) Serial.print(x)
|
||||||
#define DEBUG_PRINTF(x,y) Serial.printf(x,y)
|
#define DEBUG_PRINTF(x,y) Serial.printf(x,y)
|
||||||
#define DEBUG_PRINT_WITH_FMT(x, fmt) Serial.print(x, fmt)
|
#define DEBUG_PRINT_WITH_FMT(x, fmt) Serial.print(x, fmt)
|
||||||
#define DEBUG_PRINTLN(x) Serial.println(x)
|
#define DEBUG_PRINTLN(x) Serial.println(x)
|
||||||
#define DEBUG_PRINTLN_WITH_FMT(x, fmt) Serial.println(x, fmt)
|
#define DEBUG_PRINTLN_WITH_FMT(x, fmt) Serial.println(x, fmt)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user