mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 13:16:45 +00:00
Default to USB Serial console on SC01 Plus #390
This commit is contained in:
parent
3bdf6b872d
commit
ad28bbfc09
@ -17,6 +17,7 @@
|
|||||||
#include "ConsoleInput.h"
|
#include "ConsoleInput.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
//#include "time.h"
|
//#include "time.h"
|
||||||
|
#include <StreamUtils.h>
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <sntp.h> // sntp_servermode_dhcp()
|
#include <sntp.h> // sntp_servermode_dhcp()
|
||||||
@ -71,6 +72,7 @@ uint8_t debugSyslogProtocol = 0;
|
|||||||
|
|
||||||
// A UDP instance to let us send and receive packets over UDP
|
// A UDP instance to let us send and receive packets over UDP
|
||||||
WiFiUDP* syslogClient = NULL;
|
WiFiUDP* syslogClient = NULL;
|
||||||
|
WriteBufferingStream* bufferedSyslogClient = NULL;
|
||||||
#define SYSLOG_PROTO_IETF 0
|
#define SYSLOG_PROTO_IETF 0
|
||||||
|
|
||||||
// Create a new syslog instance with LOG_KERN facility
|
// Create a new syslog instance with LOG_KERN facility
|
||||||
@ -130,7 +132,8 @@ void debugStartSyslog()
|
|||||||
|
|
||||||
if(syslogClient) {
|
if(syslogClient) {
|
||||||
if(syslogClient->beginPacket(debugSyslogHost, debugSyslogPort)) {
|
if(syslogClient->beginPacket(debugSyslogHost, debugSyslogPort)) {
|
||||||
Log.registerOutput(2, syslogClient, HASP_LOG_LEVEL, true);
|
if(!bufferedSyslogClient) bufferedSyslogClient = new WriteBufferingStream(syslogClient, 256);
|
||||||
|
Log.registerOutput(2, bufferedSyslogClient ? bufferedSyslogClient : syslogClient, HASP_LOG_LEVEL, true);
|
||||||
LOG_INFO(TAG_SYSL, F(D_SERVICE_STARTED));
|
LOG_INFO(TAG_SYSL, F(D_SERVICE_STARTED));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -345,6 +348,10 @@ void debugPrintSuffix(uint8_t tag, int level, Print* _logOutput)
|
|||||||
if(syslogClient && _logOutput == syslogClient) {
|
if(syslogClient && _logOutput == syslogClient) {
|
||||||
syslogClient->endPacket();
|
syslogClient->endPacket();
|
||||||
return;
|
return;
|
||||||
|
} else if(bufferedSyslogClient && _logOutput == bufferedSyslogClient) {
|
||||||
|
bufferedSyslogClient.flush();
|
||||||
|
syslogClient->endPacket();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -382,10 +389,10 @@ void debugStartSerial()
|
|||||||
|
|
||||||
HASP_SERIAL.begin(baudrate); /* prepare for possible serial debug */
|
HASP_SERIAL.begin(baudrate); /* prepare for possible serial debug */
|
||||||
delay(10);
|
delay(10);
|
||||||
Log.registerOutput(0, &Serial, HASP_LOG_LEVEL, true); // LOG_LEVEL_VERBOSE
|
Log.registerOutput(0, &HASP_SERIAL, HASP_LOG_LEVEL, true); // LOG_LEVEL_VERBOSE
|
||||||
|
|
||||||
HASP_SERIAL.println();
|
HASP_SERIAL.println();
|
||||||
debugPrintHaspHeader(&Serial);
|
debugPrintHaspHeader(&HASP_SERIAL);
|
||||||
HASP_SERIAL.flush();
|
HASP_SERIAL.flush();
|
||||||
|
|
||||||
LOG_INFO(TAG_DEBG, F(D_SERVICE_STARTED " @ %u bps"), debugSerialBaud);
|
LOG_INFO(TAG_DEBG, F(D_SERVICE_STARTED " @ %u bps"), debugSerialBaud);
|
||||||
|
@ -19,7 +19,7 @@ extern hasp_http_config_t http_config;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create a new Stream that buffers all writes to serialClient
|
// Create a new Stream that buffers all writes to serialClient
|
||||||
HardwareSerial* bufferedSerialClient = (HardwareSerial*)&Serial;
|
HardwareSerial* bufferedSerialClient = (HardwareSerial*)&HASP_SERIAL;
|
||||||
|
|
||||||
uint8_t consoleLoginState = CONSOLE_UNAUTHENTICATED;
|
uint8_t consoleLoginState = CONSOLE_UNAUTHENTICATED;
|
||||||
uint16_t serialPort = 0;
|
uint16_t serialPort = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user