From daccb45180db5ba975f99909455c2819e433e36f Mon Sep 17 00:00:00 2001 From: Charlie Snyder Date: Sat, 20 Jul 2019 15:18:26 -0400 Subject: [PATCH 1/6] Add PlatformIO library support --- library.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 library.json diff --git a/library.json b/library.json new file mode 100644 index 0000000..c65aea8 --- /dev/null +++ b/library.json @@ -0,0 +1,25 @@ +{ + "name": "CSE7766", + "keywords": "cse7766, power, sonoff-s31, sensor", + "description": "Arduino Library for CSE7766 (Used in Sonoff S31", + "repository": + { + "type": "git", + "url": "https://github.com/ingeniuske/CSE7766.git" + }, + "authors": + [ + { + "name": "Ingeniuske", + "email": "ingeniuske@gmail.com", + "url": "https://github.com/ingeniuske/CSE7766", + "maintainer": true + } + ], + "dependencies": + { + }, + "version": "1.0.0", + "frameworks": "arduino", + "platforms": "*" +} From ad90d294f9e61b6ea413f55029318334ceea6af8 Mon Sep 17 00:00:00 2001 From: Charlie Snyder Date: Sat, 20 Jul 2019 15:19:43 -0400 Subject: [PATCH 2/6] Fix typo --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index c65aea8..4fc59ee 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "CSE7766", "keywords": "cse7766, power, sonoff-s31, sensor", - "description": "Arduino Library for CSE7766 (Used in Sonoff S31", + "description": "Arduino Library for CSE7766 (Used in Sonoff S31)", "repository": { "type": "git", From 0cc31c3bb10a18de71c1e6a4099476e5ca933b2c Mon Sep 17 00:00:00 2001 From: dervomsee Date: Fri, 11 Dec 2020 08:04:45 +0100 Subject: [PATCH 3/6] Update CSE7766.cpp compatibility to integrated EspSoftwareSerial --- CSE7766.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSE7766.cpp b/CSE7766.cpp index 04c3748..8770d6b 100644 --- a/CSE7766.cpp +++ b/CSE7766.cpp @@ -131,7 +131,7 @@ if (1 == _pin_rx) { Serial.begin(CSE7766_BAUDRATE); } else { - _serial = new SoftwareSerial(_pin_rx, SW_SERIAL_UNUSED_PIN, _inverted, 32); + _serial = new SoftwareSerial(_pin_rx, -1, _inverted); _serial->enableIntTx(false); _serial->begin(CSE7766_BAUDRATE); } From eb7aaaa6fce6a70a87f976fa4626c4efc632cf54 Mon Sep 17 00:00:00 2001 From: Cornelius Date: Sun, 7 Nov 2021 14:10:09 +0100 Subject: [PATCH 4/6] rename debug.h to avoid conflig with arduino core header files --- CSE7766.h | 2 +- debug.h | 20 -------------------- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 debug.h diff --git a/CSE7766.h b/CSE7766.h index 86ce506..e5b95d2 100644 --- a/CSE7766.h +++ b/CSE7766.h @@ -8,7 +8,7 @@ #define CSE7766_h #include "Arduino.h" -#include "debug.h" +#include "debug_cse.h" #include #ifndef CSE7766_PIN diff --git a/debug.h b/debug.h deleted file mode 100644 index a95409c..0000000 --- a/debug.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - - -// ----------------------------------------------------------------------------- -// Debug -// ----------------------------------------------------------------------------- -void debugSend(const char * format, ...); -// ----------------------------------------------------------------------------- -// Debug -// ----------------------------------------------------------------------------- - -#define DEBUG_SUPPORT 1 - -#if DEBUG_SUPPORT - #define DEBUG_MSG(...) debugSend(__VA_ARGS__) -#endif - -#ifndef DEBUG_MSG - #define DEBUG_MSG(...) -#endif From 012536f5b64ca3df29cc5e11332a962fd129f67d Mon Sep 17 00:00:00 2001 From: Cornelius Date: Sun, 7 Nov 2021 14:11:31 +0100 Subject: [PATCH 5/6] add missing file --- debug_cse.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 debug_cse.h diff --git a/debug_cse.h b/debug_cse.h new file mode 100644 index 0000000..a95409c --- /dev/null +++ b/debug_cse.h @@ -0,0 +1,20 @@ +#pragma once + + +// ----------------------------------------------------------------------------- +// Debug +// ----------------------------------------------------------------------------- +void debugSend(const char * format, ...); +// ----------------------------------------------------------------------------- +// Debug +// ----------------------------------------------------------------------------- + +#define DEBUG_SUPPORT 1 + +#if DEBUG_SUPPORT + #define DEBUG_MSG(...) debugSend(__VA_ARGS__) +#endif + +#ifndef DEBUG_MSG + #define DEBUG_MSG(...) +#endif From 57d2fd8975c8858524479ae34e597423edd47ad2 Mon Sep 17 00:00:00 2001 From: dervomsee Date: Mon, 4 Jul 2022 16:17:44 +0200 Subject: [PATCH 6/6] Update CSE7766.cpp Support esp32 with CSE connected on HW serial 2. --- CSE7766.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/CSE7766.cpp b/CSE7766.cpp index 8770d6b..522358d 100644 --- a/CSE7766.cpp +++ b/CSE7766.cpp @@ -130,7 +130,13 @@ if (1 == _pin_rx) { Serial.begin(CSE7766_BAUDRATE); - } else { + } +#ifdef ESP32 + else if (16== _pin_rx){ + Serial2.begin(CSE7766_BAUDRATE); + } +#endif + else { _serial = new SoftwareSerial(_pin_rx, -1, _inverted); _serial->enableIntTx(false); _serial->begin(CSE7766_BAUDRATE); @@ -308,7 +314,13 @@ bool CSE7766::_serial_available() { if (1 == _pin_rx) { return Serial.available(); - } else { + } +#ifdef ESP32 + else if (16== _pin_rx){ + return Serial2.available(); + } +#endif + else { return _serial->available(); } } @@ -316,7 +328,13 @@ void CSE7766::_serial_flush() { if (1 == _pin_rx) { return Serial.flush(); - } else { + } +#ifdef ESP32 + else if (16== _pin_rx){ + return Serial2.flush(); + } +#endif + else { return _serial->flush(); } } @@ -324,8 +342,13 @@ uint8_t CSE7766::_serial_read() { if (1 == _pin_rx) { return Serial.read(); - } else { + } +#ifdef ESP32 + else if (16== _pin_rx){ + return Serial2.read(); + } +#endif + else { return _serial->read(); } } -