From 2a6317374e4546e0bd1a5a43ee8612f3872e0387 Mon Sep 17 00:00:00 2001 From: mvdbro Date: Fri, 11 Aug 2017 20:16:31 +0200 Subject: [PATCH] More RAM savings, added Dallas plugin --- src/ArduinoEasy.ino | 4 +- src/Command.ino | 22 +- src/Misc.ino | 2 +- src/Networking.ino | 2 +- src/WebServer.ino | 12 +- src/_C001.ino | 7 +- src/_P004_Dallas.ino | 471 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 497 insertions(+), 23 deletions(-) create mode 100644 src/_P004_Dallas.ino diff --git a/src/ArduinoEasy.ino b/src/ArduinoEasy.ino index 74f5b5a..e5ba96c 100644 --- a/src/ArduinoEasy.ino +++ b/src/ArduinoEasy.ino @@ -702,8 +702,8 @@ void SensorSendTask(byte TaskIndex) float value = UserVar[varIndex + varNr]; float result = 0; String svalue = String(value); - formula.replace("%pvalue%", spreValue); - formula.replace("%value%", svalue); + formula.replace(F("%pvalue%"), spreValue); + formula.replace(F("%value%"), svalue); byte error = Calculate(formula.c_str(), &result); if (error == 0) UserVar[varIndex + varNr] = result; diff --git a/src/Command.ino b/src/Command.ino index ba2bd53..ab34e52 100644 --- a/src/Command.ino +++ b/src/Command.ino @@ -20,14 +20,6 @@ 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; @@ -175,10 +167,16 @@ void ExecuteCommand(byte source, const char *Line) EthernetClient client; if (client.connect(host.c_str(), port.toInt())) { - client.print(String("GET ") + path + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Connection: close\r\n\r\n"); - + String request = F("GET "); + request += path; + request += F(" HTTP/1.1\r\n"); + request += F("Host: "); + request += host; + request += F("\r\n"); +// request += authHeader; + request += F("Connection: close\r\n\r\n"); + client.print(request); + unsigned long timer = millis() + 200; while (!client.available() && millis() < timer) delay(1); diff --git a/src/Misc.ino b/src/Misc.ino index 1f96926..64f4cf0 100644 --- a/src/Misc.ino +++ b/src/Misc.ino @@ -1555,7 +1555,7 @@ unsigned long getNtpTime() portUDP.endPacket(); uint32_t beginWait = millis(); - while (millis() - beginWait < 1000) { + while (millis() - beginWait < 2000) { int size = portUDP.parsePacket(); if (size >= NTP_PACKET_SIZE) { portUDP.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer diff --git a/src/Networking.ino b/src/Networking.ino index a57d4ed..a48ff2a 100644 --- a/src/Networking.ino +++ b/src/Networking.ino @@ -283,7 +283,7 @@ void sendUDP(byte unit, byte* data, byte size) { if (Nodes[unit].ip[0] == 0) return; - String log = "UDP : Send UDP message to "; + String log = F("UDP : Send UDP message to "); log += unit; addLog(LOG_LEVEL_DEBUG_MORE, log); diff --git a/src/WebServer.ino b/src/WebServer.ino index ec2d747..9a2b6d9 100644 --- a/src/WebServer.ino +++ b/src/WebServer.ino @@ -810,8 +810,11 @@ void handle_devices(EthernetClient client, String &post) { //reply += Settings.Pin_i2c_scl; // todo } if (Device[DeviceIndex].Type == DEVICE_TYPE_ANALOG) - reply += F("ADC (TOUT)"); - + { + reply += F("A"); + reply += Settings.TaskDevicePort[x]; + } + if (Settings.TaskDevicePin1[x] != -1) { reply += F("GPIO-"); @@ -1864,6 +1867,11 @@ bool handle_unknown(EthernetClient client, String path) { boolean handle_custom(EthernetClient client, String path) { //path = path.substring(1); String reply = ""; + client.println(F("HTTP/1.1 200 OK")); + client.println(F("Content-Type: text/html")); + client.println(F("Connection: close")); // the connection will be closed after completion of the response + client.println(); + if (path.startsWith(F("dashboard"))) // for the dashboard page, create a default unit dropdown selector { reply += F("