From bf7dcb8eec8c898e869b04e7313e1fcd1073726c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 16 Sep 2018 16:09:00 +0200 Subject: [PATCH] 6.2.1.3 Add SerialSend5 6.2.1.4 20180916 * Add command SerialSend5 to send raw serial data like "A5074100545293" * Update MCP230xx driver * Update Czech translation * Update MP3 driver (#3800) * Add userid/password option to decode-status.py (#3796) * Fix syslog when emulation is selected (#2109, #3784) * Fix Pzem2 compilation error (#3766, #3767) --- sonoff/_changelog.ino | 13 +++++++++++-- sonoff/sonoff.ino | 13 ++++++++----- sonoff/sonoff_version.h | 2 +- sonoff/support.ino | 15 +++++++++++++++ sonoff/user_config.h | 2 +- sonoff/xdrv_06_snfbridge.ino | 19 ++----------------- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index eed6ffcc7..bd4ee9b7c 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,10 +1,19 @@ -/* 6.2.1.3 20180907 +/* 6.2.1.4 20180916 + * Add command SerialSend5 to send raw serial data like "A5074100545293" + * Update MCP230xx driver + * Update Czech translation + * Update MP3 driver (#3800) + * Add userid/password option to decode-status.py (#3796) + * Fix syslog when emulation is selected (#2109, #3784) + * Fix Pzem2 compilation error (#3766, #3767) + * + * 6.2.1.3 20180907 * Change web Configure Module GPIO drop down list order for better readability * Fix showing Period Power in energy threshold messages * Fix ButtonRetain to not use default topic for clearing retain messages (#3737) * Add sleep to Nova Fitness SDS01X sensor (#2841, #3724, #3749) * Add Analog input AD0 enabled to sonoff-sensors.bin (#3756, #3757) - * Add Support to Xiaomi-Phillips Bulbs + * Add Support for Xiaomi-Philips Bulbs (#3787) * * 6.2.1.2 20180906 * Fix KNX PA exception. Regression from 6.2.1 buffer overflow caused by subStr() (#3700, #3710) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index a55e896c4..4903fe80f 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -969,22 +969,25 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.baudrate * 1200); } - else if ((CMND_SERIALSEND == command_code) && (index > 0) && (index <= 4)) { + else if ((CMND_SERIALSEND == command_code) && (index > 0) && (index <= 5)) { SetSeriallog(LOG_LEVEL_NONE); Settings.flag.mqtt_serial = 1; - Settings.flag.mqtt_serial_raw = (4 == index) ? 1 : 0; + Settings.flag.mqtt_serial_raw = (index > 3) ? 1 : 0; if (data_len > 0) { if (1 == index) { - Serial.printf("%s\n", dataBuf); + Serial.printf("%s\n", dataBuf); // "Hello Tiger\n" } else if (2 == index || 4 == index) { for (int i = 0; i < data_len; i++) { - Serial.write(dataBuf[i]); + Serial.write(dataBuf[i]); // "Hello Tiger" or "A0" } } else if (3 == index) { uint16_t dat_len = data_len; - Serial.printf("%s", Unescape(dataBuf, &dat_len)); + Serial.printf("%s", Unescape(dataBuf, &dat_len)); // "Hello\f" + } + else if (5 == index) { + SerialSendRaw(dataBuf, data_len); // "AA004566" } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE); } diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index f068473ab..f5f94dad1 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,7 +20,7 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -#define VERSION 0x06020103 +#define VERSION 0x06020104 #define D_PROGRAMNAME "Sonoff-Tasmota" #define D_AUTHOR "Theo Arends" diff --git a/sonoff/support.ino b/sonoff/support.ino index af93fa148..fb2b5eae3 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -704,6 +704,21 @@ void ClaimSerial() Settings.baudrate = baudrate / 1200; } +void SerialSendRaw(char *codes, int size) +{ + char *p; + char stemp[3]; + uint8_t code; + + while (size > 0) { + snprintf(stemp, sizeof(stemp), codes); + code = strtol(stemp, &p, 16); + Serial.write(code); + size -= 2; + codes += 2; + } +} + uint32_t GetHash(const char *buffer, size_t size) { uint32_t hash = 0; diff --git a/sonoff/user_config.h b/sonoff/user_config.h index a07c87ec3..5a2b909de 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -342,7 +342,7 @@ //#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy meter (+2k code) #define SDM630_SPEED 9600 // SDM630-Modbus RS485 serial speed (default: 9600 baud) //#define USE_MP3_PLAYER // Use of the DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop -// #define MP3_VOLUME 10 // Set the startup volume on init, the range can be 0..30(max) + #define MP3_VOLUME 10 // Set the startup volume on init, the range can be 0..30(max) // Power monitoring sensors ----------------------- #define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code) diff --git a/sonoff/xdrv_06_snfbridge.ino b/sonoff/xdrv_06_snfbridge.ino index b0518f133..379d29455 100644 --- a/sonoff/xdrv_06_snfbridge.ino +++ b/sonoff/xdrv_06_snfbridge.ino @@ -199,21 +199,6 @@ uint8_t SnfBrUpdateInit() /********************************************************************************************/ -void SonoffBridgeSendRaw(char *codes, int size) -{ - char *p; - char stemp[3]; - uint8_t code; - - while (size > 0) { - snprintf(stemp, sizeof(stemp), codes); - code = strtol(stemp, &p, 16); - Serial.write(code); - size -= 2; - codes += 2; - } -} - void SonoffBridgeReceivedRaw() { // Decoding according to https://github.com/Portisch/RF-Bridge-EFM8BB1 @@ -552,11 +537,11 @@ boolean SonoffBridgeCommand() break; case 192: // 0xC0 - Beep char beep[] = "AAC000C055"; - SonoffBridgeSendRaw(beep, sizeof(beep)); + SerialSendRaw(beep, sizeof(beep)); break; } } else { - SonoffBridgeSendRaw(XdrvMailbox.data, XdrvMailbox.data_len); + SerialSendRaw(XdrvMailbox.data, XdrvMailbox.data_len); sonoff_bridge_receive_raw_flag = 1; } }