Fix Sonoff Bridge duplicates and check power at startup

5.6.1g
* Add power check at startup (#526)
* Add duplicate check to received RF signal within 2 seconds for Sonoff
Bridge (#810)
This commit is contained in:
arendst 2017-08-29 16:35:45 +02:00
parent 9c3b1852b1
commit 300bb8818f
4 changed files with 35 additions and 13 deletions

View File

@ -1,7 +1,7 @@
## Sonoff-Tasmota ## Sonoff-Tasmota
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE. Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
Current version is **5.6.1f** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. Current version is **5.6.1g** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions ### ATTENTION All versions

View File

@ -1,4 +1,8 @@
/* 5.6.1f /* 5.6.1g
* Add power check at startup (#526)
* Add duplicate check to received RF signal within 2 seconds for Sonoff Bridge (#810)
*
* 5.6.1f
* Fix JSON error (#786) * Fix JSON error (#786)
* Revert changes from 5.6.1e but extent HLW power timer to 10 seconds (#796) * Revert changes from 5.6.1e but extent HLW power timer to 10 seconds (#796)
* *

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)" - Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/ ====================================================*/
#define VERSION 0x05060106 // 5.6.1f #define VERSION 0x05060107 // 5.6.1g
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL}; enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
enum week_t {Last, First, Second, Third, Fourth}; enum week_t {Last, First, Second, Third, Fourth};
@ -2863,6 +2863,14 @@ void setup()
} }
} }
} }
// Issue #526
for (byte i = 0; i < Maxdevice; i++) {
if ((pin[GPIO_REL1 +i] < 99) && (digitalRead(pin[GPIO_REL1 +i]))) {
bitSet(power, i);
}
}
blink_powersave = power; blink_powersave = power;
if (SONOFF_SC == sysCfg.module) { if (SONOFF_SC == sysCfg.module) {

View File

@ -21,9 +21,13 @@
Sonoff RF Bridge 433 Sonoff RF Bridge 433
\*********************************************************************************************/ \*********************************************************************************************/
#define SFB_TIME_AVOID_DUPLICATE 2000 // Milliseconds
uint8_t sfb_rcvflg = 0; uint8_t sfb_rcvflg = 0;
uint8_t sfb_learnKey = 1; uint8_t sfb_learnKey = 1;
uint8_t sfb_learnFlg = 0; uint8_t sfb_learnFlg = 0;
uint32_t sfb_lastrid = 0;
unsigned long sfb_lasttime = 0;
void sb_received() void sb_received()
{ {
@ -68,6 +72,11 @@ void sb_received()
rlo = serialInBuf[3] << 8 | serialInBuf[4]; // Low time in uSec rlo = serialInBuf[3] << 8 | serialInBuf[4]; // Low time in uSec
rhi = serialInBuf[5] << 8 | serialInBuf[6]; // High time in uSec rhi = serialInBuf[5] << 8 | serialInBuf[6]; // High time in uSec
rid = serialInBuf[7] << 16 | serialInBuf[8] << 8 | serialInBuf[9]; rid = serialInBuf[7] << 16 | serialInBuf[8] << 8 | serialInBuf[9];
unsigned long now = millis();
if (!((rid == sfb_lastrid) && (now - sfb_lasttime < SFB_TIME_AVOID_DUPLICATE))) {
sfb_lastrid = rid;
sfb_lasttime = now;
strcpy_P(rfkey, PSTR("\"None\"")); strcpy_P(rfkey, PSTR("\"None\""));
for (i = 1; i <= 16; i++) { for (i = 1; i <= 16; i++) {
if (sysCfg.sfb_code[i][0]) { if (sysCfg.sfb_code[i][0]) {
@ -82,6 +91,7 @@ void sb_received()
rsy, rlo, rhi, rid, rfkey); rsy, rlo, rhi, rid, rfkey);
mqtt_publish_topic_P(6, PSTR("RFRECEIVED"), svalue); mqtt_publish_topic_P(6, PSTR("RFRECEIVED"), svalue);
} }
}
} }
boolean sb_serial() boolean sb_serial()