diff --git a/src/ArduinoEasy.ino b/src/ArduinoEasy.ino index 0cc23d5..74f5b5a 100644 --- a/src/ArduinoEasy.ino +++ b/src/ArduinoEasy.ino @@ -428,14 +428,6 @@ void setup() if (Settings.Build != BUILD) BuildFixes(); - String log = F("\nINIT : Booting Build nr:"); - log += BUILD; - addLog(LOG_LEVEL_INFO, log); - - hardwareInit(); - PluginInit(); - CPluginInit(); - mac[5] = Settings.Unit; // make sure every unit has a unique mac address if (Settings.IP[0] == 0) Ethernet.begin(mac); @@ -445,6 +437,10 @@ void setup() // setup UDP if (Settings.UDPPort != 0) portUDP.begin(Settings.UDPPort); + + hardwareInit(); + PluginInit(); + CPluginInit(); #if FEATURE_MQTT // Setup MQTT Client @@ -453,11 +449,12 @@ void setup() MQTTConnect(); #endif - sendSysInfoUDP(3); - - log = F("INIT : Boot OK"); + String log = F("\nINIT : Booting Build nr:"); + log += BUILD; addLog(LOG_LEVEL_INFO, log); + sendSysInfoUDP(3); + // Setup timers byte bootMode = 0; if (bootMode == 0) @@ -488,6 +485,8 @@ void setup() rulesProcessing(event); } + log = F("INIT : Boot OK"); + addLog(LOG_LEVEL_INFO, log); } else { diff --git a/src/Command.ino b/src/Command.ino index afd4172..ba2bd53 100644 --- a/src/Command.ino +++ b/src/Command.ino @@ -20,6 +20,14 @@ void ExecuteCommand(byte source, const char *Line) // commands for debugging // **************************************** + if (strcasecmp_P(Command, PSTR("Syslog")) == 0) + { + success = true; + String event = Line; + event = event.substring(6); + syslog(event.c_str()); + } + if (strcasecmp_P(Command, PSTR("w5100")) == 0) { success = true; @@ -177,7 +185,7 @@ void ExecuteCommand(byte source, const char *Line) while (client.available()) { String line = client.readStringUntil('\n'); - if (line.substring(0, 15) == "HTTP/1.1 200 OK") + if (line.substring(0, 15) == F("HTTP/1.1 200 OK")) addLog(LOG_LEVEL_DEBUG, line); delay(1); } diff --git a/src/Controller.ino b/src/Controller.ino index 0cec61f..2325d14 100644 --- a/src/Controller.ino +++ b/src/Controller.ino @@ -93,13 +93,13 @@ void MQTTConnect() MQTTclient.setCallback(callback); // MQTT needs a unique clientname to subscribe to broker - String clientid = "ESPClient"; + String clientid = F("ESPClient"); clientid += Settings.Unit; String subscribeTo = ""; String LWTTopic = Settings.MQTTsubscribe; LWTTopic.replace("/#", "/status"); - LWTTopic.replace("%sysname%", Settings.Name); + LWTTopic.replace(F("%sysname%"), Settings.Name); for (byte x = 1; x < 3; x++) { @@ -116,7 +116,7 @@ void MQTTConnect() log = F("MQTT : Connected to broker"); addLog(LOG_LEVEL_INFO, log); subscribeTo = Settings.MQTTsubscribe; - subscribeTo.replace("%sysname%", Settings.Name); + subscribeTo.replace(F("%sysname%"), Settings.Name); MQTTclient.subscribe(subscribeTo.c_str()); log = F("Subscribed to: "); log += subscribeTo; @@ -162,7 +162,7 @@ void MQTTStatus(String& status) { String pubname = Settings.MQTTsubscribe; pubname.replace("/#", "/status"); - pubname.replace("%sysname%", Settings.Name); + pubname.replace(F("%sysname%"), Settings.Name); MQTTclient.publish(pubname.c_str(), status.c_str(),Settings.MQTTRetainFlag); } #endif diff --git a/src/WebServer.ino b/src/WebServer.ino index 9f1ca44..ec2d747 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -202,7 +202,7 @@ void addHeader(boolean showMenu, EthernetClient client) str += F("h1 {font-size:16pt; color:black;}"); str += F("h6 {font-size:10pt; color:black; text-align:center;}"); str += F(".button-menu {background-color:#ffffff; color:blue; margin: 10px; text-decoration:none}"); - str += F(".button-link {padding:5px 15px; background-color:#0077dd; color:#fff; border:solid 1px #fff; text-decoration:none}"); + str += F(".button-link {margin:4px; padding:4px 16px; background-color:#07D; color:#FFF; text-decoration:none; border-radius:4px}"); str += F(".button-menu:hover {background:#ddddff;}"); str += F(".button-link:hover {background:#369;}"); str += F("th {padding:10px; background-color:black; color:#ffffff;}"); @@ -329,7 +329,8 @@ void handle_root(EthernetClient client, String &post) { if (Nodes[x].ip[0] != 0) { char url[80]; - sprintf_P(url, PSTR("%u.%u.%u.%u"), Nodes[x].ip[0], Nodes[x].ip[1], Nodes[x].ip[2], Nodes[x].ip[3], Nodes[x].ip[0], Nodes[x].ip[1], Nodes[x].ip[2], Nodes[x].ip[3]); +// sprintf_P(url, PSTR("%u.%u.%u.%u"), Nodes[x].ip[0], Nodes[x].ip[1], Nodes[x].ip[2], Nodes[x].ip[3], Nodes[x].ip[0], Nodes[x].ip[1], Nodes[x].ip[2], Nodes[x].ip[3]); + sprintf_P(url, PSTR("%u.%u.%u.%u"), Nodes[x].ip[0], Nodes[x].ip[1], Nodes[x].ip[2], Nodes[x].ip[3], Nodes[x].ip[0], Nodes[x].ip[1], Nodes[x].ip[2], Nodes[x].ip[3]); reply += F("