diff --git a/README.md b/README.md index 361b8f7f..ea71bce3 100644 --- a/README.md +++ b/README.md @@ -240,8 +240,8 @@ Here is the list of supported hardware. For more information please refer to the |**Maxcio W-US002S**|**HEYGO HY02**|**YiDian XS-SSA05**| |![WiOn 50055](images/devices/wion-50055.jpg)|![LINGAN SWA1](images/devices/lingan-swa1.jpg)|![HomeCube 16A](images/devices/homecube-16a.jpg)| |**WiOn 50055**|**LINGAN SWA1**|**HomeCube 16A**| -|![WorkChoice EcoPlug](images/devices/workchoice-ecoplug.jpg)|![Bestek MRJ1011](images/devices/bestek-mrj1011.jpg)|| -|**WorkChoice EcoPlug**|**Bestek MRJ1011**|| +|![WorkChoice EcoPlug](images/devices/workchoice-ecoplug.jpg)|![Bestek MRJ1011](images/devices/bestek-mrj1011.jpg)|![Tonbux XS-SSA01](images/devices/tonbux-xs-ssa01.jpg)| +|**WorkChoice EcoPlug**|**Bestek MRJ1011**|**Tonbux XS-SSA01**| |![Tonbux PowerStrip02](images/devices/tonbux-powerstrip02.jpg)|![ForNorm Power Strip](images/devices/fornorm-power-strip.jpg)|![Zhilde ZLD-EU55-W](images/devices/zhilde-zld-eu55-w.jpg)| |**Tonbux PowerStrip02**|**Fornorm Power Strip**|**Zhilde ZLD-EU55-W**| |![Itead Sonoff Touch](images/devices/itead-sonoff-touch.jpg)|![Itead Sonoff T1](images/devices/itead-sonoff-t1.jpg)|![YJZK switch](images/devices/yjzk-2gang-switch.jpg)| diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index fe4b081a..9d88cc5a 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -72,6 +72,7 @@ //#define MAXCIO_WUS002S //#define YIDIAN_XSSSA05 //#define TONBUX_XSSSA06 +//#define TONBUX_XSSSA01 //#define GREEN_ESP8266RELAY //#define IKE_ESPIKE //#define ARNIEX_SWIFITCH diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 6068a274..ee048c94 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -1920,6 +1920,29 @@ #define HLW8012_CURRENT_R 0.002 // Current resistor #define HLW8012_VOLTAGE_R_UP ( 2 * 1000000 ) // Upstream voltage resistor +// ----------------------------------------------------------------------------- +// Maxcio W-DE004 +// ----------------------------------------------------------------------------- + +#elif defined(MAXCIO_WDE004) + + // Info + #define MANUFACTURER "MAXCIO" + #define DEVICE "WDE004" + + // Buttons + #define BUTTON1_PIN 1 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 14 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 1 + // ----------------------------------------------------------------------------- // YiDian XS-SSA05 // ----------------------------------------------------------------------------- @@ -1962,6 +1985,29 @@ #define HLW8012_POWER_RATIO 3414290 #define HLW8012_INTERRUPT_ON FALLING +// ----------------------------------------------------------------------------- +// TONBUX XS-SSA01 +// ----------------------------------------------------------------------------- + +#elif defined(TONBUX_XSSSA01) + + // Info + #define MANUFACTURER "TONBUX" + #define DEVICE "XSSSA01" + + // Buttons + #define BUTTON1_PIN 4 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 14 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 0 + // ----------------------------------------------------------------------------- // TONBUX XS-SSA06 // ----------------------------------------------------------------------------- diff --git a/code/espurna/ir.ino b/code/espurna/ir.ino index a61c8fc3..22f17bfa 100644 --- a/code/espurna/ir.ino +++ b/code/espurna/ir.ino @@ -43,8 +43,6 @@ Raw messages: Payload: 1000,1000,1000,1000,1000 | IR codes | - * To support long codes (Air Conditioneer) increase MQTT packet size -DMQTT_MAX_PACKET_SIZE=1200 - -------------------------------------------------------------------------------- */ @@ -91,7 +89,6 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload } if (type == MQTT_MESSAGE_EVENT) { - String t = mqttMagnitude((char *) topic); // Match topic @@ -110,7 +107,7 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload _ir_repeat_size = 1; // count & validate repeat-string - for(int i = col+1; i < len; i++) { + for(unsigned int i = col+1; i < len; i++) { if (i < len-1) { if ( payload[i] == ',' && isDigit(payload[i+1]) && i>0 ) { //validate string _ir_repeat_size++; @@ -129,7 +126,7 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload } // end of counting & validating repeat code // count & validate main code string - for(int i = 0; i < len; i++) { + for(unsigned int i = 0; i < len; i++) { if (i0 ) { //validate string count++; @@ -149,7 +146,7 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload int j = 0; // for populating values of array from comma separated string // populating main code array from part of MQTT string - for (int i = 0; i < len; i++) { + for (unsigned int i = 0; i < len; i++) { if (payload[i] != ',') { value = value + data[i]; } @@ -173,14 +170,6 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload DEBUG_MSG_P(PSTR("[IR] Raw IR output %d codes, repeat %d times on %d(k)Hz freq.\n"), count, _ir_repeat, _ir_freq); - /* - DEBUG_MSG_P(PSTR("[IR] main codes: ")); - for(int i = 0; i < count; i++) { - DEBUG_MSG_P(PSTR("%d,"),_ir_raw[i]); - } - DEBUG_MSG_P(PSTR("\n")); - */ - #if defined(IR_RX_PIN) _ir_receiver.disableIRIn(); #endif @@ -203,7 +192,7 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload len = data.length(); //redifining length to full lenght // populating repeat code array from part of MQTT string - for (int i = col+1; i < len; i++) { + for (unsigned int i = col+1; i < len; i++) { value = value + data[i]; if ((payload[i] == ',') || (i == len - 1)) { _ir_raw[j]= value.toInt(); @@ -211,7 +200,6 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload j++; } } - } else { // if repeat code not specified (col<=2) repeat with current main code _ir_repeat_size = count; } @@ -223,7 +211,7 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload if (col > 0) { _ir_type = data.toInt(); - _ir_code = data.substring(col+1).toInt(); + _ir_code = strtoul(data.substring(col+1).c_str(), NULL, 10); col = data.indexOf(":", col+1); if (col > 0) { @@ -234,9 +222,7 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload } else { _ir_repeat = IR_REPEAT; } - } - } if (_ir_repeat > 0) { @@ -364,12 +350,9 @@ void _irRXLoop() { if (millis() - last_time < IR_DEBOUNCE) return; last_time = millis(); - // Check code - if (_ir_results.value < 1) return; - if (_ir_results.decode_type < 1) return; - if (_ir_results.bits < 1) return; - #if IR_USE_RAW + // Check code + if (_ir_results.rawlen < 1) return; char * payload; String value = ""; for (int i = 1; i < _ir_results.rawlen; i++) { @@ -378,6 +361,10 @@ void _irRXLoop() { } payload = const_cast(value.c_str()); #else + // Check code + if (_ir_results.value < 1) return; + if (_ir_results.decode_type < 1) return; + if (_ir_results.bits < 1) return; char payload[32]; snprintf_P(payload, sizeof(payload), PSTR("%u:%lu:%u"), _ir_results.decode_type, (unsigned long) _ir_results.value, _ir_results.bits); #endif diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 4e45cfec..008a943f 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -1223,6 +1223,16 @@ void migrate() { setSetting("ledGPIO", 1, 15); setSetting("ledLogic", 1, 0); + #elif defined(TONBUX_XSSSA01) + + setSetting("board", 92); + setSetting("ledGPIO", 0, 13); + setSetting("ledLogic", 0, 0); + setSetting("btnGPIO", 0, 13); + setSetting("btnRelay", 0, 0); + setSetting("relayGPIO", 0, 5); + setSetting("relayType", 0, RELAY_TYPE_NORMAL); + #else // Allow users to define new settings without migration config diff --git a/code/platformio.ini b/code/platformio.ini index 9d81cf13..265d4b4e 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -2010,6 +2010,30 @@ upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} extra_scripts = ${common.extra_scripts} +[env:maxcio-wde004] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DMAXCIO_WDE004 +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + +[env:maxcio-wde004-ota] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DMAXCIO_WDE004 +upload_speed = ${common.upload_speed} +upload_port = ${common.upload_port} +upload_flags = ${common.upload_flags} +extra_scripts = ${common.extra_scripts} + [env:yidian-xsssa05] platform = ${common.platform} framework = ${common.framework} @@ -2034,6 +2058,31 @@ upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} extra_scripts = ${common.extra_scripts} +[env:tonbux-xsssa01] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_4m1m} -DTONBUX_XSSSA01 +upload_speed = ${common.upload_speed_fast} +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + +[env:tonbux-xsssa01-ota] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_4m1m} -DTONBUX_XSSSA01 +upload_speed = ${common.upload_speed} +upload_port = ${common.upload_port} +upload_flags = ${common.upload_flags} +extra_scripts = ${common.extra_scripts} + [env:tonbux-xsssa06] platform = ${common.platform} framework = ${common.framework} diff --git a/images/devices/tonbux-xs-ssa01.jpg b/images/devices/tonbux-xs-ssa01.jpg new file mode 100644 index 00000000..a11fbf22 Binary files /dev/null and b/images/devices/tonbux-xs-ssa01.jpg differ