Active Receiver Switching (#936)
* PR #934 * Active Receiver Switching Switching of the active receiver module is available between the RF, RF2, RTL_433 and Pilight Gateway modules, allowing for changing of signal decoders without redploying the openMQTTGateway package. Sending a JSON message to the command topic of the desired receiver will change the active receiver module. Other minor adjustments/improvements 1 - Improved startup serial logging that includes - OpenMQTTGateway Version - OpenMQTTGateway Modules 2 - Trace logging of full Gateway module command topic - Enabled in RF, RF2, PiLight and RTL_433 3 - Updated RTL_433 Documentation to only include enabled ASK/OOK device decoders 4 - Trace logging of MQTT Callback topic * Regression testing * Adding valueAsASubject support to rtl_433_ESP - model and id keys are appended to message topic * Increased memory size for receiver switching in blocking build all Co-authored-by: Northern Man <sgracey@Heisenberg.local>
This commit is contained in:
1 parent
9fb3d90da9
commit
f69906861d
8 files changed
+476
-170
No files matched your search
+49
-23
@@ -70,6 +70,7 @@ void setupRF() {
|
||||
# endif
|
||||
mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT);
|
||||
mySwitch.enableReceive(RF_RECEIVER_GPIO);
|
||||
Log.trace(F("ZgatewayRF command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRF);
|
||||
Log.trace(F("ZgatewayRF setup done" CR));
|
||||
}
|
||||
|
||||
@@ -204,42 +205,67 @@ void MQTTtoRF(char* topicOri, JsonObject& RFdata) { // json object decoding
|
||||
pub(subjectGTWRFtoMQTT, RFdata); // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
|
||||
mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT); // Restore the default value
|
||||
} else {
|
||||
bool success = false;
|
||||
if (RFdata.containsKey("active")) {
|
||||
Log.trace(F("RF active:" CR));
|
||||
activeReceiver = ACTIVE_RF;
|
||||
success = true;
|
||||
}
|
||||
# ifdef ZradioCC1101 // set Receive on and Transmitt off
|
||||
float tempMhz = RFdata["mhz"];
|
||||
if (tempMhz != 0 && validFrequency((int)tempMhz)) {
|
||||
if (RFdata.containsKey("mhz") && validFrequency(tempMhz)) {
|
||||
receiveMhz = tempMhz;
|
||||
Log.notice(F("Receive mhz: %F" CR), receiveMhz);
|
||||
success = true;
|
||||
}
|
||||
# endif
|
||||
if (success) {
|
||||
pub(subjectGTWRFtoMQTT, RFdata); // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
|
||||
} else {
|
||||
# ifndef ARDUINO_AVR_UNO // Space issues with the UNO
|
||||
pub(subjectGTWRFtoMQTT, "{\"Status\": \"Error\"}"); // Fail feedback
|
||||
# endif
|
||||
Log.error(F("MQTTtoRF Fail json" CR));
|
||||
}
|
||||
# else
|
||||
# ifndef ARDUINO_AVR_UNO // Space issues with the UNO
|
||||
pub(subjectGTWRFtoMQTT, "{\"Status\": \"error\"}"); // Fail feedback
|
||||
# endif
|
||||
Log.error(F("MQTTtoRF Fail json" CR));
|
||||
# endif
|
||||
}
|
||||
enableActiveReceiver();
|
||||
}
|
||||
# ifdef ZradioCC1101 // set Receive on and Transmitt off
|
||||
ELECHOUSE_cc1101.SetRx(receiveMhz);
|
||||
mySwitch.disableTransmit();
|
||||
mySwitch.enableReceive(RF_RECEIVER_GPIO);
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef ZradioCC1101
|
||||
bool validFrequency(int mhz) {
|
||||
// CC1101 valid frequencies 300-348 MHZ, 387-464MHZ and 779-928MHZ.
|
||||
if (mhz >= 300 && mhz <= 348)
|
||||
return true;
|
||||
if (mhz >= 387 && mhz <= 464)
|
||||
return true;
|
||||
if (mhz >= 779 && mhz <= 928)
|
||||
return true;
|
||||
return false;
|
||||
int receiveInterupt = -1;
|
||||
|
||||
void disableRFReceive() {
|
||||
Log.trace(F("disableRFReceive %d" CR), receiveInterupt);
|
||||
if (receiveInterupt != -1) {
|
||||
receiveInterupt = -1;
|
||||
mySwitch.disableReceive();
|
||||
}
|
||||
}
|
||||
|
||||
void enableRFReceive() {
|
||||
# ifdef ZradioCC1101
|
||||
Log.notice(F("Switching to RF Receiver: %F" CR), receiveMhz);
|
||||
# else
|
||||
Log.notice(F("Switching to RF Receiver" CR));
|
||||
# endif
|
||||
# ifndef ARDUINO_AVR_UNO // Space issues with the UNO
|
||||
# ifdef ZgatewayPilight
|
||||
disablePilightReceive();
|
||||
# endif
|
||||
# ifdef ZgatewayRTL_433
|
||||
disableRTLreceive();
|
||||
# endif
|
||||
# endif
|
||||
# ifdef ZgatewayRF2
|
||||
disableRF2Receive();
|
||||
# endif
|
||||
|
||||
# ifdef ZradioCC1101 // set Receive on and Transmitt off
|
||||
ELECHOUSE_cc1101.SetRx(receiveMhz);
|
||||
# endif
|
||||
mySwitch.disableTransmit();
|
||||
receiveInterupt = RF_RECEIVER_GPIO;
|
||||
mySwitch.enableReceive(RF_RECEIVER_GPIO);
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user