mirror of https://github.com/arendst/Tasmota.git
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:
parent
9c3b1852b1
commit
300bb8818f
|
@ -1,7 +1,7 @@
|
|||
## 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.
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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)
|
||||
* Revert changes from 5.6.1e but extent HLW power timer to 10 seconds (#796)
|
||||
*
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
- 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 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;
|
||||
|
||||
if (SONOFF_SC == sysCfg.module) {
|
||||
|
|
|
@ -21,9 +21,13 @@
|
|||
Sonoff RF Bridge 433
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define SFB_TIME_AVOID_DUPLICATE 2000 // Milliseconds
|
||||
|
||||
uint8_t sfb_rcvflg = 0;
|
||||
uint8_t sfb_learnKey = 1;
|
||||
uint8_t sfb_learnFlg = 0;
|
||||
uint32_t sfb_lastrid = 0;
|
||||
unsigned long sfb_lasttime = 0;
|
||||
|
||||
void sb_received()
|
||||
{
|
||||
|
@ -68,19 +72,25 @@ void sb_received()
|
|||
rlo = serialInBuf[3] << 8 | serialInBuf[4]; // Low time in uSec
|
||||
rhi = serialInBuf[5] << 8 | serialInBuf[6]; // High time in uSec
|
||||
rid = serialInBuf[7] << 16 | serialInBuf[8] << 8 | serialInBuf[9];
|
||||
strcpy_P(rfkey, PSTR("\"None\""));
|
||||
for (i = 1; i <= 16; i++) {
|
||||
if (sysCfg.sfb_code[i][0]) {
|
||||
sid = sysCfg.sfb_code[i][6] << 16 | sysCfg.sfb_code[i][7] << 8 | sysCfg.sfb_code[i][8];
|
||||
if (sid == rid) {
|
||||
snprintf_P(rfkey, sizeof(rfkey), PSTR("%d"), i);
|
||||
break;
|
||||
|
||||
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\""));
|
||||
for (i = 1; i <= 16; i++) {
|
||||
if (sysCfg.sfb_code[i][0]) {
|
||||
sid = sysCfg.sfb_code[i][6] << 16 | sysCfg.sfb_code[i][7] << 8 | sysCfg.sfb_code[i][8];
|
||||
if (sid == rid) {
|
||||
snprintf_P(rfkey, sizeof(rfkey), PSTR("%d"), i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"RfReceived\":{\"Sync\":%d, \"Low\":%d, \"High\":%d, \"Data\":\"%06X\", \"RfKey\":%s}}"),
|
||||
rsy, rlo, rhi, rid, rfkey);
|
||||
mqtt_publish_topic_P(6, PSTR("RFRECEIVED"), svalue);
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"RfReceived\":{\"Sync\":%d, \"Low\":%d, \"High\":%d, \"Data\":\"%06X\", \"RfKey\":%s}}"),
|
||||
rsy, rlo, rhi, rid, rfkey);
|
||||
mqtt_publish_topic_P(6, PSTR("RFRECEIVED"), svalue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue