From 78a807e247c05ebf007ffa3c1df5df749a4dce09 Mon Sep 17 00:00:00 2001 From: Markus Bajones Date: Wed, 2 May 2018 13:00:18 +0200 Subject: [PATCH 1/4] Add support for Allnet ESP8266_UP_Relay --- code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 33 +++++++++++++++++++++++++++++++++ code/espurna/migrate.ino | 7 +++++++ code/platformio.ini | 24 ++++++++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index ea6e9c8348..29f6147840 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -78,6 +78,7 @@ //#define GENERIC_ESP01S_DS18B20_V10 //#define HELTEC_TOUCHRELAY //#define ZHILDE_EU44_W +//#define ALLNET_ESP8266_UP //-------------------------------------------------------------------------------- // Features (values below are non-default values) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 37f2c59618..70b7df3398 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -1971,6 +1971,39 @@ #define LED1_PIN 1 #define LED1_PIN_INVERSE 1 + // ----------------------------------------------------------------------------- + // Allnet 4duino ESP8266-UP-Relais + // http://www.allnet.de/de/allnet-brand/produkte/neuheiten/p/allnet-4duino-iot-wlan-relais-unterputz-esp8266-up-relais/ + // ----------------------------------------------------------------------------- + +#elif defined(ALLNET_ESP8266_UP) + + // Info + #define MANUFACTURER "ALLNET" + #define DEVICE "ESP8266_UP_Relais" + + // Relays + #define RELAY1_PIN 14 + #define RELAY1_RESET_PIN 12 + #define RELAY1_TYPE RELAY_TYPE_LATCHED + + // LEDs + #define LED1_PIN 0 + #define LED1_PIN_INVERSE 1 + + // Buttons + #define BUTTON1_PIN 4 + #define BUTTON1_MODE BUTTON_PUSHBUTTON + #define BUTTON1_PRESS BUTTON_MODE_TOGGLE + #define BUTTON1_CLICK BUTTON_MODE_NONE + #define BUTTON1_DBLCLICK BUTTON_MODE_NONE + #define BUTTON1_LNGCLICK BUTTON_MODE_NONE + #define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE + + #define BUTTON2_PIN 5 + #define BUTTON2_MODE BUTTON_PUSHBUTTON + + // ----------------------------------------------------------------------------- // TEST boards (do not use!!) // ----------------------------------------------------------------------------- diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 8bf615a0ae..ae8edd9b72 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -905,6 +905,13 @@ void migrate() { setSetting("relayType", 3, RELAY_TYPE_NORMAL); setSetting("relayType", 4, RELAY_TYPE_NORMAL); + #elif defined(ALLNET_ESP8266_UP) + + setSetting("board", 71); + setSetting("relayGPIO", 0, 14); + setSetting("relayResetGPIO", 1, 12); + setSetting("relayType", 0, RELAY_TYPE_LATCHED); + #else // Allow users to define new settings without migration config diff --git a/code/platformio.ini b/code/platformio.ini index db86f9e328..43d3234c9a 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -2054,3 +2054,27 @@ upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 extra_scripts = ${common.extra_scripts} + +[env:allnet-esp8266-up-relay] +platform = ${common.platform} +framework = arduino +board = esp12e +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DALLNET_ESP8266_UP +monitor_baud = 115200 +extra_scripts = ${common.extra_scripts} + +[env:allnet-esp8266-up-relay-ota] +platform = ${common.platform} +framework = arduino +board = esp12e +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DALLNET_ESP8266_UP +upload_speed = 115200 +upload_port = "${env.ESPURNA_IP}" +upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 +extra_scripts = ${common.extra_scripts} From ed609e622351e0c0bf3bbe6d6d218e3a8c07cafc Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 1 May 2018 18:45:41 +0300 Subject: [PATCH 2/4] Handle C-d in telnet --- code/espurna/telnet.ino | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index fc3912c6ff..996da56783 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -66,6 +66,15 @@ void _telnetData(unsigned char clientId, void *data, size_t len) { // Capture close connection char * p = (char *) data; + + // C-d is sent as two bytes + if (len == 2) { + if ((p[0] == 0xFF) && (p[1] == 0xEC)) { + _telnetClients[clientId]->close(); + return; + } + } + if ((strncmp(p, "close", 5) == 0) || (strncmp(p, "quit", 4) == 0)) { _telnetClients[clientId]->close(); return; From 99311bbe714c14fab0ea97d9fa0309147b7f2cd0 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 2 May 2018 15:39:55 +0300 Subject: [PATCH 3/4] Sometimes telnet spams this sequence --- code/espurna/telnet.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index 996da56783..918f228e6b 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -67,8 +67,8 @@ void _telnetData(unsigned char clientId, void *data, size_t len) { // Capture close connection char * p = (char *) data; - // C-d is sent as two bytes - if (len == 2) { + // C-d is sent as two bytes (sometimes repeating) + if (len >= 2) { if ((p[0] == 0xFF) && (p[1] == 0xEC)) { _telnetClients[clientId]->close(); return; From 5708a23d2f5ae6d5f63e7bdaa04fc29294117d77 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 2 May 2018 15:40:11 +0300 Subject: [PATCH 4/4] Immediatly close connection to avoid watchdog --- code/espurna/telnet.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index 918f228e6b..006d5d216d 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -70,7 +70,7 @@ void _telnetData(unsigned char clientId, void *data, size_t len) { // C-d is sent as two bytes (sometimes repeating) if (len >= 2) { if ((p[0] == 0xFF) && (p[1] == 0xEC)) { - _telnetClients[clientId]->close(); + _telnetClients[clientId]->close(true); return; } }