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:
Northern ManandNorthern Man authored and GitHub committed 2021-05-10 19:36:25 -05:00
1 parent 9fb3d90da9
commit f69906861d
8 files changed
+476 -170

No files matched your search

+41 -7
View File
@@ -531,7 +531,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
// In order to republish this payload, a copy must be made
// as the orignal payload buffer will be overwritten whilst
// constructing the PUBLISH packet.
Log.trace(F("Hey I got a callback " CR));
Log.trace(F("Hey I got a callback %s" CR), topic);
// Allocate the correct amount of memory for the payload copy
byte* p = (byte*)malloc(length + 1);
// Copy the payload to the new buffer
@@ -568,6 +568,7 @@ void setup() {
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
setupM5();
# endif
Log.notice(F("OpenMQTTGateway Version: " OMG_VERSION CR));
# endif
# ifdef ESP32_ETHERNET
@@ -654,14 +655,24 @@ void setup() {
#ifdef ZgatewayRF
setupRF();
modules.add(ZgatewayRF);
# define ACTIVE_RECEIVER ACTIVE_RF
#endif
#ifdef ZgatewayRF2
setupRF2();
modules.add(ZgatewayRF2);
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_RF2
#endif
#ifdef ZgatewayPilight
setupPilight();
modules.add(ZgatewayPilight);
disablePilightReceive();
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_PILIGHT
#endif
#ifdef ZgatewayWeatherStation
setupWeatherStation();
@@ -737,9 +748,27 @@ void setup() {
#ifdef ZgatewayRTL_433
setupRTL_433();
modules.add(ZgatewayRTL_433);
# ifdef ACTIVE_RECEIVER
# undef ACTIVE_RECEIVER
# endif
# define ACTIVE_RECEIVER ACTIVE_RTL
#endif
#if defined(ZgatewayRTL_433) || defined(ZgatewayRF) || defined(ZgatewayPilight) || defined(ZgatewayRF2)
# ifdef DEFAULT_RECEIVER // Allow defining of default receiver as a compiler directive
activeReceiver = DEFAULT_RECEIVER;
# else
activeReceiver = ACTIVE_RECEIVER;
# endif
enableActiveReceiver();
#endif
Log.trace(F("mqtt_max_packet_size: %d" CR), mqtt_max_packet_size);
Log.notice(F("Setup OpenMQTTGateway end" CR));
#ifndef ARDUINO_AVR_UNO // Space issues with the UNO
char jsonChar[100];
modules.printTo((char*)jsonChar, modules.measureLength() + 1);
Log.notice(F("OpenMQTTGateway modules: %s" CR), jsonChar);
#endif
Log.notice(F("************** Setup OpenMQTTGateway end **************" CR));
}
#if defined(ESP8266) || defined(ESP32)
@@ -1410,13 +1439,18 @@ void stateMeasures() {
SYSdata["m5batchargecurrent"] = (float)M5.Axp.GetBatChargeCurrent();
SYSdata["m5apsvoltage"] = (float)M5.Axp.GetAPSVoltage();
# endif
# if defined(ZgatewayRF) || defined(ZgatewayPilight) || defined(ZgatewayRTL_433) || defined(ZgatewayRF2)
SYSdata["actRec"] = (int)activeReceiver;
# endif
# ifdef ZradioCC1101
SYSdata["mhz"] = (int)receiveMhz;
SYSdata["mhz"] = (float)receiveMhz;
# endif
# if defined(ZgatewayRTL_433)
SYSdata["RTLminRssi"] = (int)getRTLMinimumRSSI();
SYSdata["RTLRssi"] = (int)getRTLCurrentRSSI();
SYSdata["RTLCnt"] = (int)getRTLMessageCount();
if (activeReceiver == ACTIVE_RTL) {
SYSdata["RTLminRssi"] = (int)getRTLMinimumRSSI();
SYSdata["RTLRssi"] = (int)getRTLCurrentRSSI();
SYSdata["RTLCnt"] = (int)getRTLMessageCount();
}
# endif
SYSdata.set("modules", modules);
pub(subjectSYStoMQTT, SYSdata);
@@ -1614,4 +1648,4 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
}
#endif
}
}
}