Browse Source

Force RFBridge to send messages even if switch is already in requested state

fastled
Xose Pérez 7 years ago
parent
commit
8d8384f279
2 changed files with 20 additions and 7 deletions
  1. +5
    -0
      code/espurna/relay.ino
  2. +15
    -7
      code/espurna/rfbridge.ino

+ 5
- 0
code/espurna/relay.ino View File

@ -141,6 +141,11 @@ bool relayStatus(unsigned char id, bool status, bool report, bool group_report)
changed = true; changed = true;
} }
// For RFBridge, keep sending the message even if the status is already the required
#if RELAY_PROVIDER == RELAY_PROVIDER_RFBRIDGE
rfbStatus(id, status);
#endif
} else { } else {
unsigned int current_time = millis(); unsigned int current_time = millis();


+ 15
- 7
code/espurna/rfbridge.ino View File

@ -8,6 +8,8 @@ Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com>
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
#include <Ticker.h>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// DEFINITIONS // DEFINITIONS
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -32,6 +34,10 @@ unsigned char _learnId = 0;
bool _learnStatus = true; bool _learnStatus = true;
bool _rfbin = false; bool _rfbin = false;
byte _message_to_send[RF_MESSAGE_SIZE] = {0};
byte _message_count = 0;
Ticker _rfbTicker;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// PRIVATES // PRIVATES
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -96,19 +102,21 @@ void _rfbSend(byte * message) {
Serial.println(); Serial.println();
} }
void _rfbSend() {
if (_message_count) {
_rfbSend(_message_to_send);
if (--_message_count > 0) _rfbTicker.once_ms(RF_SEND_DELAY, _rfbSend);
}
}
void _rfbSend(byte * message, int times) { void _rfbSend(byte * message, int times) {
char buffer[RF_MESSAGE_SIZE]; char buffer[RF_MESSAGE_SIZE];
_rfbToChar(message, buffer); _rfbToChar(message, buffer);
DEBUG_MSG_P(PSTR("[RFBRIDGE] Sending MESSAGE '%s' %d time(s)\n"), buffer, times); DEBUG_MSG_P(PSTR("[RFBRIDGE] Sending MESSAGE '%s' %d time(s)\n"), buffer, times);
for (int i=0; i<times; i++) {
if (i>0) {
unsigned long start = millis();
while (millis() - start < RF_SEND_DELAY) delay(1);
}
_rfbSend(message);
}
_message_count = times;
memcpy(_message_to_send, message, RF_MESSAGE_SIZE);
_rfbSend();
} }


Loading…
Cancel
Save