Use haspDevice for hostname

This commit is contained in:
fvanroie 2021-02-18 19:17:00 +01:00
parent 7857ea03ed
commit 06cba2ea8e

View File

@ -65,14 +65,14 @@
// static StringStream debugStream((String &)debugOutput); // static StringStream debugStream((String &)debugOutput);
// extern char mqttNodeName[16]; // extern char mqttNodeName[16];
const char * syslogAppName = APP_NAME; const char* syslogAppName = APP_NAME;
char debugSyslogHost[32] = SYSLOG_SERVER; char debugSyslogHost[32] = SYSLOG_SERVER;
uint16_t debugSyslogPort = SYSLOG_PORT; uint16_t debugSyslogPort = SYSLOG_PORT;
uint8_t debugSyslogFacility = 0; uint8_t debugSyslogFacility = 0;
uint8_t debugSyslogProtocol = 0; 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; WiFiUDP* syslogClient;
#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
@ -109,7 +109,7 @@ unsigned long debugLastMillis = 0;
uint16_t debugTelePeriod = 300; uint16_t debugTelePeriod = 300;
// Send the HASP header and version to the output device specified // Send the HASP header and version to the output device specified
void debugPrintHaspHeader(Print * output) void debugPrintHaspHeader(Print* output)
{ {
if(debugAnsiCodes) output->print(TERM_COLOR_YELLOW); if(debugAnsiCodes) output->print(TERM_COLOR_YELLOW);
output->println(); output->println();
@ -198,7 +198,7 @@ void debugStop()
} }
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool debugGetConfig(const JsonObject & settings) bool debugGetConfig(const JsonObject& settings)
{ {
bool changed = false; bool changed = false;
@ -234,7 +234,7 @@ bool debugGetConfig(const JsonObject & settings)
* *
* @param[in] settings JsonObject with the config settings. * @param[in] settings JsonObject with the config settings.
**/ **/
bool debugSetConfig(const JsonObject & settings) bool debugSetConfig(const JsonObject& settings)
{ {
configOutput(settings, TAG_DEBG); configOutput(settings, TAG_DEBG);
bool changed = false; bool changed = false;
@ -260,7 +260,7 @@ bool debugSetConfig(const JsonObject & settings)
} }
#endif // HASP_USE_CONFIG #endif // HASP_USE_CONFIG
inline void debugSendAnsiCode(const __FlashStringHelper * code, Print * _logOutput) inline void debugSendAnsiCode(const __FlashStringHelper* code, Print* _logOutput)
{ {
if(debugAnsiCodes) _logOutput->print(code); if(debugAnsiCodes) _logOutput->print(code);
} }
@ -329,11 +329,11 @@ void debugGetHistoryLine(size_t num)
} }
*/ */
static void debugPrintTimestamp(int level, Print * _logOutput) static void debugPrintTimestamp(int level, Print* _logOutput)
{ /* Print Current Time */ { /* Print Current Time */
struct timeval tval; struct timeval tval;
struct tm * timeinfo; struct tm* timeinfo;
int rslt; int rslt;
rslt = gettimeofday(&tval, NULL); rslt = gettimeofday(&tval, NULL);
@ -368,7 +368,7 @@ static void debugPrintTimestamp(int level, Print * _logOutput)
} }
} }
static void debugPrintHaspMemory(int level, Print * _logOutput) static void debugPrintHaspMemory(int level, Print* _logOutput)
{ {
size_t maxfree = haspDevice.get_free_max_block(); size_t maxfree = haspDevice.get_free_max_block();
size_t totalfree = haspDevice.get_free_heap(); size_t totalfree = haspDevice.get_free_heap();
@ -387,7 +387,7 @@ static void debugPrintHaspMemory(int level, Print * _logOutput)
} }
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
static void debugPrintLvglMemory(int level, Print * _logOutput) static void debugPrintLvglMemory(int level, Print* _logOutput)
{ {
lv_mem_monitor_t mem_mon; lv_mem_monitor_t mem_mon;
lv_mem_monitor(&mem_mon); lv_mem_monitor(&mem_mon);
@ -406,7 +406,7 @@ static void debugPrintLvglMemory(int level, Print * _logOutput)
} }
#endif #endif
static void debugPrintPriority(int level, Print * _logOutput) static void debugPrintPriority(int level, Print* _logOutput)
{ {
// if(_logOutput == &syslogClient) { // if(_logOutput == &syslogClient) {
// } // }
@ -436,7 +436,7 @@ static void debugPrintPriority(int level, Print * _logOutput)
} }
} }
static void debugPrintTag(uint8_t tag, Print * _logOutput) static void debugPrintTag(uint8_t tag, Print* _logOutput)
{ {
switch(tag) { switch(tag) {
case TAG_MAIN: case TAG_MAIN:
@ -544,7 +544,7 @@ static void debugPrintTag(uint8_t tag, Print * _logOutput)
} }
} }
void debugPrintPrefix(uint8_t tag, int level, Print * _logOutput) void debugPrintPrefix(uint8_t tag, int level, Print* _logOutput)
{ {
#if HASP_USE_SYSLOG > 0 #if HASP_USE_SYSLOG > 0
@ -562,7 +562,7 @@ void debugPrintPrefix(uint8_t tag, int level, Print * _logOutput)
syslogClient->print(F("1 - ")); syslogClient->print(F("1 - "));
} }
syslogClient->print(mqttGetNodename()); syslogClient->print(haspDevice.get_hostname());
syslogClient->print(F(" ")); syslogClient->print(F(" "));
debugPrintTag(tag, _logOutput); debugPrintTag(tag, _logOutput);
@ -602,7 +602,7 @@ void debugPrintPrefix(uint8_t tag, int level, Print * _logOutput)
_logOutput->print(F(": ")); _logOutput->print(F(": "));
} }
void debugPrintSuffix(uint8_t tag, int level, Print * _logOutput) void debugPrintSuffix(uint8_t tag, int level, Print* _logOutput)
{ {
#if HASP_USE_SYSLOG > 0 #if HASP_USE_SYSLOG > 0
if(_logOutput == syslogClient && syslogClient) { if(_logOutput == syslogClient && syslogClient) {
@ -658,8 +658,7 @@ void debugPreSetup(JsonObject settings)
} }
#if LV_USE_LOG != 0 #if LV_USE_LOG != 0
void debugLvglLogEvent(lv_log_level_t level, const char * file, uint32_t line, const char * funcname, void debugLvglLogEvent(lv_log_level_t level, const char* file, uint32_t line, const char* funcname, const char* descr)
const char * descr)
{ {
/* used for duplicate detection */ /* used for duplicate detection */
static uint32_t lastDbgLine; static uint32_t lastDbgLine;
@ -713,7 +712,7 @@ void printLocalTime()
{ {
char buffer[128]; char buffer[128];
time_t rawtime; time_t rawtime;
struct tm * timeinfo; struct tm* timeinfo;
// if(!time(nullptr)) return; // if(!time(nullptr)) return;
@ -732,8 +731,8 @@ void printLocalTime()
// LwIP v2 is able to list more details about the currently configured SNTP servers // LwIP v2 is able to list more details about the currently configured SNTP servers
for(int i = 0; i < SNTP_MAX_SERVERS; i++) { for(int i = 0; i < SNTP_MAX_SERVERS; i++) {
IPAddress sntp = *sntp_getserver(i); IPAddress sntp = *sntp_getserver(i);
const char * name = sntp_getservername(i); const char* name = sntp_getservername(i);
if(sntp.isSet()) { if(sntp.isSet()) {
Serial.printf("sntp%d: ", i); Serial.printf("sntp%d: ", i);
if(name) { if(name) {