mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 20:56:37 +00:00
Change ConfigSet parameter from PSTR() to F()
This commit is contained in:
parent
9a751d7d65
commit
9162ee122b
@ -1081,10 +1081,10 @@ bool haspSetConfig(const JsonObject & settings)
|
||||
configOutput(settings);
|
||||
bool changed = false;
|
||||
|
||||
changed |= configSet(haspStartPage, settings[FPSTR(F_CONFIG_STARTPAGE)], PSTR("haspStartPage"));
|
||||
changed |= configSet(haspStartDim, settings[FPSTR(F_CONFIG_STARTDIM)], PSTR("haspStartDim"));
|
||||
changed |= configSet(haspThemeId, settings[FPSTR(F_CONFIG_THEME)], PSTR("haspThemeId"));
|
||||
changed |= configSet(haspThemeHue, settings[FPSTR(F_CONFIG_HUE)], PSTR("haspThemeHue"));
|
||||
changed |= configSet(haspStartPage, settings[FPSTR(F_CONFIG_STARTPAGE)], F("haspStartPage"));
|
||||
changed |= configSet(haspStartDim, settings[FPSTR(F_CONFIG_STARTDIM)], F("haspStartDim"));
|
||||
changed |= configSet(haspThemeId, settings[FPSTR(F_CONFIG_THEME)], F("haspThemeId"));
|
||||
changed |= configSet(haspThemeHue, settings[FPSTR(F_CONFIG_HUE)], F("haspThemeHue"));
|
||||
|
||||
if(!settings[FPSTR(F_CONFIG_PAGES)].isNull()) {
|
||||
changed |= strcmp(haspPagesPath, settings[FPSTR(F_CONFIG_PAGES)]) != 0;
|
||||
|
@ -25,44 +25,44 @@
|
||||
#include "EEPROM.h"
|
||||
#endif
|
||||
|
||||
void confDebugSet(const char * name)
|
||||
void confDebugSet(const __FlashStringHelper * fstr_name)
|
||||
{
|
||||
/*char buffer[128];
|
||||
snprintf(buffer, sizeof(buffer), PSTR(" * %s set"), name);
|
||||
debugPrintln(buffer);*/
|
||||
Log.trace(TAG_CONF, F(" * %s set"), name);
|
||||
Log.trace(TAG_CONF, F(" * %S set"), fstr_name);
|
||||
}
|
||||
|
||||
bool configSet(int8_t & value, const JsonVariant & setting, const char * name)
|
||||
bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name)
|
||||
{
|
||||
if(!setting.isNull()) {
|
||||
int8_t val = setting.as<int8_t>();
|
||||
if(value != val) {
|
||||
confDebugSet(name);
|
||||
confDebugSet(fstr_name);
|
||||
value = val;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool configSet(uint8_t & value, const JsonVariant & setting, const char * name)
|
||||
bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name)
|
||||
{
|
||||
if(!setting.isNull()) {
|
||||
uint8_t val = setting.as<uint8_t>();
|
||||
if(value != val) {
|
||||
confDebugSet(name);
|
||||
confDebugSet(fstr_name);
|
||||
value = val;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool configSet(uint16_t & value, const JsonVariant & setting, const char * name)
|
||||
bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name)
|
||||
{
|
||||
if(!setting.isNull()) {
|
||||
uint16_t val = setting.as<uint16_t>();
|
||||
if(value != val) {
|
||||
confDebugSet(name);
|
||||
confDebugSet(fstr_name);
|
||||
value = val;
|
||||
return true;
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ void configGetConfig(JsonDocument & settings);
|
||||
void configWriteConfig();
|
||||
void configOutput(const JsonObject & settings);
|
||||
|
||||
bool configSet(int8_t & value, const JsonVariant & setting, const char * name);
|
||||
bool configSet(uint8_t & value, const JsonVariant & setting, const char * name);
|
||||
bool configSet(uint16_t & value, const JsonVariant & setting, const char * name);
|
||||
bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
|
||||
bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
|
||||
bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
|
||||
bool configClear();
|
||||
|
||||
#endif
|
@ -95,22 +95,21 @@ bool debugAnsiCodes = true;
|
||||
unsigned long debugLastMillis = 0;
|
||||
uint16_t debugTelePeriod = 300;
|
||||
|
||||
String debugHaspHeader()
|
||||
/* Send the HASP header and version to the output device specified
|
||||
*/
|
||||
void debugHaspHeader(Print * output)
|
||||
{
|
||||
String header((char *)0);
|
||||
header.reserve(256);
|
||||
if(debugAnsiCodes) header += TERM_COLOR_YELLOW;
|
||||
header += F("\r\n"
|
||||
if(debugAnsiCodes) output->println(TERM_COLOR_YELLOW);
|
||||
output->println(F(""
|
||||
" _____ _____ _____ _____\r\n"
|
||||
" | | | _ | __| _ |\r\n"
|
||||
" | | |__ | __|\r\n"
|
||||
" |__|__|__|__|_____|__|\r\n"
|
||||
" Home Automation Switch Plate\r\n");
|
||||
" Home Automation Switch Plate"));
|
||||
char buffer[128];
|
||||
snprintf(buffer, sizeof(buffer), PSTR(" Open Hardware edition v%u.%u.%u\r\n"), HASP_VERSION_MAJOR,
|
||||
HASP_VERSION_MINOR, HASP_VERSION_REVISION);
|
||||
header += buffer;
|
||||
return header;
|
||||
output->println(buffer);
|
||||
}
|
||||
|
||||
void debugStart()
|
||||
@ -204,10 +203,10 @@ bool debugSetConfig(const JsonObject & settings)
|
||||
bool changed = false;
|
||||
|
||||
/* Serial Settings*/
|
||||
changed |= configSet(debugSerialBaud, settings[FPSTR(F_CONFIG_BAUD)], PSTR("debugSerialBaud"));
|
||||
changed |= configSet(debugSerialBaud, settings[FPSTR(F_CONFIG_BAUD)], F("debugSerialBaud"));
|
||||
|
||||
/* Teleperiod Settings*/
|
||||
changed |= configSet(debugTelePeriod, settings[FPSTR(F_DEBUG_TELEPERIOD)], PSTR("debugTelePeriod"));
|
||||
changed |= configSet(debugTelePeriod, settings[FPSTR(F_DEBUG_TELEPERIOD)], F("debugTelePeriod"));
|
||||
|
||||
/* Syslog Settings*/
|
||||
#if HASP_USE_SYSLOG > 0
|
||||
@ -215,9 +214,9 @@ bool debugSetConfig(const JsonObject & settings)
|
||||
changed |= strcmp(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)]) != 0;
|
||||
strncpy(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)], sizeof(debugSyslogHost));
|
||||
}
|
||||
changed |= configSet(debugSyslogPort, settings[FPSTR(F_CONFIG_PORT)], PSTR("debugSyslogPort"));
|
||||
changed |= configSet(debugSyslogProtocol, settings[FPSTR(F_CONFIG_PROTOCOL)], PSTR("debugSyslogProtocol"));
|
||||
changed |= configSet(debugSyslogFacility, settings[FPSTR(F_CONFIG_LOG)], PSTR("debugSyslogFacility"));
|
||||
changed |= configSet(debugSyslogPort, settings[FPSTR(F_CONFIG_PORT)], F("debugSyslogPort"));
|
||||
changed |= configSet(debugSyslogProtocol, settings[FPSTR(F_CONFIG_PROTOCOL)], F("debugSyslogProtocol"));
|
||||
changed |= configSet(debugSyslogFacility, settings[FPSTR(F_CONFIG_LOG)], F("debugSyslogFacility"));
|
||||
#endif
|
||||
|
||||
return changed;
|
||||
@ -507,8 +506,9 @@ void debugPreSetup(JsonObject settings)
|
||||
|
||||
// Print Header
|
||||
Serial.println();
|
||||
Serial.println(debugHaspHeader());
|
||||
Serial.println();
|
||||
debugHaspHeader(&Serial);
|
||||
// Serial.println(debugHaspHeader());
|
||||
// Serial.println();
|
||||
Serial.flush();
|
||||
|
||||
Log.trace(TAG_DEBG, ("Serial started at %u baud"), baudrate);
|
||||
|
@ -791,11 +791,11 @@ bool guiSetConfig(const JsonObject & settings)
|
||||
configOutput(settings);
|
||||
bool changed = false;
|
||||
|
||||
changed |= configSet(guiTickPeriod, settings[FPSTR(F_GUI_TICKPERIOD)], PSTR("guiTickPeriod"));
|
||||
changed |= configSet(guiBacklightPin, settings[FPSTR(F_GUI_BACKLIGHTPIN)], PSTR("guiBacklightPin"));
|
||||
changed |= configSet(guiSleepTime1, settings[FPSTR(F_GUI_IDLEPERIOD1)], PSTR("guiSleepTime1"));
|
||||
changed |= configSet(guiSleepTime2, settings[FPSTR(F_GUI_IDLEPERIOD2)], PSTR("guiSleepTime2"));
|
||||
changed |= configSet(guiRotation, settings[FPSTR(F_GUI_ROTATION)], PSTR("guiRotation"));
|
||||
changed |= configSet(guiTickPeriod, settings[FPSTR(F_GUI_TICKPERIOD)], F("guiTickPeriod"));
|
||||
changed |= configSet(guiBacklightPin, settings[FPSTR(F_GUI_BACKLIGHTPIN)], F("guiBacklightPin"));
|
||||
changed |= configSet(guiSleepTime1, settings[FPSTR(F_GUI_IDLEPERIOD1)], F("guiSleepTime1"));
|
||||
changed |= configSet(guiSleepTime2, settings[FPSTR(F_GUI_IDLEPERIOD2)], F("guiSleepTime2"));
|
||||
changed |= configSet(guiRotation, settings[FPSTR(F_GUI_ROTATION)], F("guiRotation"));
|
||||
|
||||
if(!settings[FPSTR(F_GUI_POINTER)].isNull()) {
|
||||
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) {
|
||||
|
@ -1889,7 +1889,7 @@ bool httpSetConfig(const JsonObject & settings)
|
||||
configOutput(settings);
|
||||
bool changed = false;
|
||||
|
||||
changed |= configSet(httpPort, settings[FPSTR(F_CONFIG_PORT)], PSTR("httpPort"));
|
||||
changed |= configSet(httpPort, settings[FPSTR(F_CONFIG_PORT)], F("httpPort"));
|
||||
|
||||
if(!settings[FPSTR(F_CONFIG_USER)].isNull()) {
|
||||
changed |= strcmp(httpUser, settings[FPSTR(F_CONFIG_USER)]) != 0;
|
||||
|
@ -105,7 +105,7 @@ bool mdnsSetConfig(const JsonObject & settings)
|
||||
configOutput(settings);
|
||||
bool changed = false;
|
||||
|
||||
changed |= configSet(mdnsEnabled, settings[FPSTR(F_CONFIG_ENABLE)], PSTR("mdnsEnabled"));
|
||||
changed |= configSet(mdnsEnabled, settings[FPSTR(F_CONFIG_ENABLE)], F("mdnsEnabled"));
|
||||
|
||||
return changed;
|
||||
}
|
@ -537,7 +537,7 @@ bool mqttSetConfig(const JsonObject & settings)
|
||||
configOutput(settings);
|
||||
bool changed = false;
|
||||
|
||||
changed |= configSet(mqttPort, settings[FPSTR(F_CONFIG_PORT)], PSTR("mqttPort"));
|
||||
changed |= configSet(mqttPort, settings[FPSTR(F_CONFIG_PORT)], F("mqttPort"));
|
||||
|
||||
if(!settings[FPSTR(F_CONFIG_NAME)].isNull()) {
|
||||
changed |= strcmp(mqttNodeName, settings[FPSTR(F_CONFIG_NAME)]) != 0;
|
||||
|
@ -58,7 +58,8 @@ void telnetClientDisconnect()
|
||||
void telnetClientLogon()
|
||||
{
|
||||
telnetClient.println();
|
||||
telnetClient.println(debugHaspHeader().c_str()); // Send version header
|
||||
debugHaspHeader(&telnetClient);
|
||||
// telnetClient.println(debugHaspHeader().c_str()); // Send version header
|
||||
telnetLoginState = TELNET_AUTHENTICATED; // User and Pass are correct
|
||||
telnetLoginAttempt = 0; // Reset attempt counter
|
||||
Log.registerOutput(1, &telnetClient, LOG_LEVEL_VERBOSE, true);
|
||||
@ -132,7 +133,8 @@ static void telnetProcessLine()
|
||||
telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||
telnetLoginAttempt++; // Subsequent attempt
|
||||
telnetClient.println(F("Authorization failed!\r\n"));
|
||||
// Log.warning(TAG_TELN,F("Incorrect login attempt from %s"), telnetClient.remoteIP().toString().c_str());
|
||||
// Log.warning(TAG_TELN,F("Incorrect login attempt from %s"),
|
||||
// telnetClient.remoteIP().toString().c_str());
|
||||
if(telnetLoginAttempt >= 3) {
|
||||
telnetClientDisconnect();
|
||||
} else {
|
||||
@ -300,8 +302,8 @@ bool telnetSetConfig(const JsonObject & settings)
|
||||
configOutput(settings);
|
||||
bool changed = false;
|
||||
|
||||
changed |= configSet(telnetEnabled, settings[FPSTR(F_CONFIG_ENABLE)], PSTR("telnetEnabled"));
|
||||
changed |= configSet(telnetPort, settings[FPSTR(F_CONFIG_PORT)], PSTR("telnetPort"));
|
||||
changed |= configSet(telnetEnabled, settings[FPSTR(F_CONFIG_ENABLE)], F("telnetEnabled"));
|
||||
changed |= configSet(telnetPort, settings[FPSTR(F_CONFIG_PORT)], F("telnetPort"));
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user