From fb0a05a06b09e81fa75c02cd369a900440fce0cd Mon Sep 17 00:00:00 2001 From: esp8266nu Date: Sat, 22 Aug 2015 07:30:52 +0000 Subject: [PATCH] Fixed a bug in DHT22 device Fixed a bug in setting for default delay Changed debug info Changed device tab, added more pin info and cancel button Fixed syslog loop bug --- Controller.ino | 11 ------- ESPEasy.ino | 14 ++------- Serial.ino | 16 +--------- WebServer.ino | 79 +++++++++++++++++++++++++++++++++++++++++++++-- _ReleaseNotes.ino | 7 +++++ 5 files changed, 87 insertions(+), 40 deletions(-) diff --git a/Controller.ino b/Controller.ino index 78fd69f95..4d3a300f7 100644 --- a/Controller.ino +++ b/Controller.ino @@ -173,17 +173,7 @@ boolean Domoticz_sendData(byte sensorType, int idx, byte varIndex) // Read all the lines of the reply from server and print them to Serial while (client.available()) { - if (Settings.SerialLogLevel >= LOG_LEVEL_DEBUG_MORE) - { - sprintf_P(log,PSTR("C1 WS %u FM %u"),WiFi.status(),FreeMem()); - Serial.println(log); - } String line = client.readStringUntil('\n'); - if (Settings.SerialLogLevel >= LOG_LEVEL_DEBUG_MORE) - { - sprintf_P(log,PSTR("C2 WS %u FM %u"),WiFi.status(),FreeMem()); - Serial.println(log); - } line.toCharArray(log,79); addLog(LOG_LEVEL_DEBUG_MORE,log); if (line.substring(0, 15) == "HTTP/1.1 200 OK") @@ -295,7 +285,6 @@ void syslog(char *message) char str[80]; str[0] = 0; sprintf_P(str, PSTR("<7>ESP Unit: %u : %s"), Settings.Unit, message); - addLog(LOG_LEVEL_DEBUG,str); portTX.write(str); portTX.endPacket(); } diff --git a/ESPEasy.ino b/ESPEasy.ino index 1280c5439..1fbdfb8e9 100644 --- a/ESPEasy.ino +++ b/ESPEasy.ino @@ -61,15 +61,6 @@ #define DEFAULT_PORT 8080 // Enter your Domoticz Server port value #define DEFAULT_DELAY 60 // Enter your Send delay in seconds #define DEFAULT_AP_KEY "configesp" // Enter network WPA key for AP (config) mode -#define DEFAULT_DALLAS_IDX 0 // Enter IDX of your virtual temperature device -#define DEFAULT_DHT_IDX 0 // Enter IDX of your virtual Humidity device -#define DEFAULT_DHT_TYPE 11 // Enter Type of your virtual Humidity device -#define DEFAULT_BMP_IDX 0 // Enter IDX of your virtual Barometric Pressure device -#define DEFAULT_LUX_IDX 0 // Enter IDX of your virtual LUX device -#define DEFAULT_RFID_IDX 0 // Enter IDX of your virtual RFID device -#define DEFAULT_ANALOG_IDX 0 // Enter IDX of your virtual Analog device -#define DEFAULT_PULSE1_IDX 0 // Enter IDX of your virtual Pulse counter -#define DEFAULT_SWITCH1_IDX 0 // Enter IDX of your switch device #define DEFAULT_PROTOCOL 1 // Protocol used for controller communications // 1 = Domoticz HTTP // 2 = Domoticz MQTT @@ -89,7 +80,7 @@ #define ESP_PROJECT_PID 2015050101L #define ESP_EASY #define VERSION 4 -#define BUILD 14 +#define BUILD 15 #define REBOOT_ON_MAX_CONNECTION_FAILURES 30 #define LOG_LEVEL_ERROR 1 @@ -281,7 +272,6 @@ void setup() if (Settings.Protocol == 2) MQTTConnect(); - syslog((char*)"Boot"); sendSysInfoUDP(3); Serial.println(F("INIT : Boot OK")); addLog(LOG_LEVEL_INFO,(char*)"Boot"); @@ -423,7 +413,7 @@ void SensorSend() break; case DEVICE_DHT22: - dht(22, Settings.TaskDevicePin1[x], 2); + dht(22, Settings.TaskDevicePin1[x], x*2+1); if (!isnan(UserVar[(x*2+1) - 1]) && (UserVar[(x*2+2) - 1] > 0)) sendData(2, Settings.TaskDeviceID[x], x*2+1); break; diff --git a/Serial.ino b/Serial.ino index 953295823..037c81320 100644 --- a/Serial.ino +++ b/Serial.ino @@ -395,28 +395,14 @@ void ResetFactory(void) str2ip((char*)DEFAULT_SERVER, Settings.Controller_IP); Settings.ControllerPort = DEFAULT_PORT; Settings.IP_Octet = 0; - //Settings.Delay = DEFAULT_DELAY; - //Settings.Dallas = DEFAULT_DALLAS_IDX; - //Settings.DHT = DEFAULT_DHT_IDX; - //Settings.DHTType = DEFAULT_DHT_TYPE; - //Settings.BMP = DEFAULT_BMP_IDX; - //Settings.LUX = DEFAULT_LUX_IDX; - //Settings.RFID = DEFAULT_RFID_IDX; - //Settings.Analog = DEFAULT_ANALOG_IDX; - //Settings.Pulse1 = DEFAULT_PULSE1_IDX; - //Settings.BoardType = 0; + Settings.Delay = DEFAULT_DELAY; Settings.Pin_i2c_sda = 4; Settings.Pin_i2c_scl = 5; - //Settings.Pin_wired_in_1 = 0; - //Settings.Pin_wired_in_2 = 2; - //Settings.Pin_wired_out_1 = 12; - //Settings.Pin_wired_out_2 = 13; Settings.Syslog_IP[0] = 0; Settings.Syslog_IP[1] = 0; Settings.Syslog_IP[2] = 0; Settings.Syslog_IP[3] = 0; Settings.UDPPort = 0; - Settings.Switch1 = DEFAULT_SWITCH1_IDX; Settings.Protocol = DEFAULT_PROTOCOL; Settings.IP[0] = 0; Settings.IP[1] = 0; diff --git a/WebServer.ino b/WebServer.ino index ac9f7f6d7..05620235a 100644 --- a/WebServer.ino +++ b/WebServer.ino @@ -393,6 +393,10 @@ void handle_devices() { Settings.TaskDevicePin1[index-1] = -1; if (Device[Settings.TaskDeviceNumber[index-1]].Type != DEVICE_TYPE_DUAL) Settings.TaskDevicePin2[index-1] = -1; + + #ifdef ESP_CONNEXIO + createEventlist(); + #endif Save_Settings(); } @@ -415,13 +419,27 @@ void handle_devices() { reply += Settings.TaskDeviceID[x]; reply += F(""); + if(Device[Settings.TaskDeviceNumber[x]].Type == DEVICE_TYPE_I2C) + { + reply += F("GPIO-"); + reply += Settings.Pin_i2c_sda; + } + if(Device[Settings.TaskDeviceNumber[x]].Type == DEVICE_TYPE_ANALOG) + reply += F("ADC (TOUT)"); + if (Settings.TaskDevicePin1[x] != -1) { reply += F("GPIO-"); reply += Settings.TaskDevicePin1[x]; } reply += F(""); - + + if(Device[Settings.TaskDeviceNumber[x]].Type == DEVICE_TYPE_I2C) + { + reply += F("GPIO-"); + reply += Settings.Pin_i2c_scl; + } + if (Settings.TaskDevicePin2[x] != -1) { reply += F("GPIO-"); @@ -479,7 +497,8 @@ void handle_devices() { reply += F("2nd GPIO:"); addPinSelect(false, reply,"taskdevicepin2",Settings.TaskDevicePin2[index-1]); } - reply += F(""); + reply += F("Cancel"); + reply += F(""); reply += F(""); reply += F(""); } @@ -489,6 +508,62 @@ void handle_devices() { } #ifdef ESP_CONNEXIO +void createEventlist() +{ + struct NodoEventStruct TempEvent; + ClearEvent(&TempEvent); + byte x = 1; + while (Eventlist_Write(x++, &TempEvent, &TempEvent)) delay(1); + + char cmd[80]; + sprintf_P(cmd, PSTR("eventlistwrite; boot %u; TimerSet 1,%u"), Settings.Unit, Settings.Delay); + ExecuteLine(cmd, VALUE_SOURCE_SERIAL); + sprintf_P(cmd, PSTR("eventlistwrite; Timer 1; TimerSet 1,%u"), Settings.Delay); + ExecuteLine(cmd, VALUE_SOURCE_SERIAL); + + for (byte x=0; x < TASKS_MAX; x++) + { + if (Settings.TaskDeviceID[x] != 0) + { + switch(Settings.TaskDeviceNumber[x]) + { + case DEVICE_DS18B20: + sprintf_P(cmd, PSTR("DallasRead %u,%u"), Settings.TaskDevicePin1[x], x*2+1); + eventAddTimer(cmd); + eventAddVarSend(x*2+1, 1, Settings.TaskDeviceID[x]); + break; + case DEVICE_DHT11: + sprintf_P(cmd, PSTR("DHTRead %u,%u,11"), Settings.TaskDevicePin1[x], x*2+1); + eventAddTimer(cmd); + eventAddVarSend(x*2+1, 2, Settings.TaskDeviceID[x]); + break; + case DEVICE_DHT22: + sprintf_P(cmd, PSTR("DHTRead %u,%u,22"), Settings.TaskDevicePin1[x], x*2+1); + eventAddTimer(cmd); + eventAddVarSend(x*2+1, 2, Settings.TaskDeviceID[x]); + break; + case DEVICE_BMP085: + sprintf_P(cmd, PSTR("BMP085Read %u"), x*2+1); + eventAddTimer(cmd); + eventAddVarSend(x*2+1, 3, Settings.TaskDeviceID[x]); + break; + case DEVICE_BH1750: + sprintf_P(cmd, PSTR("LuxRead %u"), x*2+1); + eventAddTimer(cmd); + eventAddVarSend(x*2+1, 1, Settings.TaskDeviceID[x]); + break; + case DEVICE_ANALOG: + sprintf_P(cmd, PSTR("VariableWiredAnalog %u"), x*2+1); + eventAddTimer(cmd); + eventAddVarSend(x*2+1, 1, Settings.TaskDeviceID[x]); + break; + } + if (Settings.MessageDelay != 0) + eventAddDelay(); + } + } +} + void eventAddVarSend(byte var, byte sensortype, int idx) { char cmd[80]; diff --git a/_ReleaseNotes.ino b/_ReleaseNotes.ino index 44ccb4aa2..e9c9339a3 100644 --- a/_ReleaseNotes.ino +++ b/_ReleaseNotes.ino @@ -98,4 +98,11 @@ // Redesigned device configuration mechanisme // Changed password timeout to 5 minutes // Added direct GPIO output control without password request + +// R015 22-08-2015 +// Fixed a bug in DHT22 device +// Fixed a bug in setting for default delay +// Changed debug info +// Changed device tab, added more pin info and cancel button +// Fixed syslog loop bug