[RTL_433][BREAKING] Beta support for FSK modulation, webUI frequency and active receiver change (#1812)

* [FSK] Add Lilygo Heltec environment with FSK modulation

Enable RTL_433 frequency and active receiver change with WebUI
Add FSK environment for Heltec and Lilygo
This commit is contained in:
Florian authored and GitHub committed 2023-12-01 13:16:03 -06:00
1 parent eb5b8fa291
commit 7db2e93c28
15 files changed
+742 -559

No files matched your search

+21 -67
View File
@@ -112,21 +112,6 @@ void pilightRawCallback(const uint16_t* pulses, size_t length) {
}
# endif
void setupPilight() {
# ifdef ZradioCC1101 //receiving with CC1101
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
# endif
rf.setCallback(pilightCallback);
rf.initReceiver(RF_RECEIVER_GPIO);
pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayPilight command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoPilight);
Log.trace(F("ZgatewayPilight setup done " CR));
}
void savePilightConfig() {
Log.trace(F("saving Pilight config" CR));
DynamicJsonDocument json(4096);
@@ -211,10 +196,19 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
}
} else if (cmpToMainTopic(topicOri, subjectMQTTtoPilight)) {
const char* message = Pilightdata["message"];
Log.notice(F("MQTTtoPilight message: %s" CR), message);
const char* protocol = Pilightdata["protocol"];
Log.notice(F("MQTTtoPilight protocol: %s" CR), protocol);
const char* raw = Pilightdata["raw"];
float tempMhz = Pilightdata["mhz"];
float txFrequency = Pilightdata["frequency"] | RFConfig.frequency;
bool success = false;
disableCurrentReceiver();
initCC1101();
# ifdef ZradioCC1101 // set Receive off and Transmitt on
ELECHOUSE_cc1101.SetTx(txFrequency);
Log.notice(F("Transmit frequency: %F" CR), txFrequency);
# endif
pinMode(RF_EMITTER_GPIO, OUTPUT);
if (raw) {
uint16_t codes[MAXPULSESTREAMLENGTH];
int repeats = rf.stringToRepeats(raw);
@@ -231,13 +225,6 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
}
int msgLength = rf.stringToPulseTrain(raw, codes, MAXPULSESTREAMLENGTH);
if (msgLength > 0) {
# ifdef ZradioCC1101
disableActiveReceiver();
ELECHOUSE_cc1101.Init();
pinMode(RF_EMITTER_GPIO, OUTPUT);
ELECHOUSE_cc1101.SetTx(receiveMhz); // set Transmit on
rf.disableReceiver();
# endif
rf.sendPulseTrain(codes, msgLength, repeats);
Log.notice(F("MQTTtoPilight raw ok" CR));
success = true;
@@ -262,18 +249,11 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
}
if (message && protocol) {
Log.trace(F("MQTTtoPilight msg & protocol ok" CR));
# ifdef ZradioCC1101
disableActiveReceiver();
ELECHOUSE_cc1101.Init();
pinMode(RF_EMITTER_GPIO, OUTPUT);
ELECHOUSE_cc1101.SetTx(receiveMhz); // set Transmit on
rf.disableReceiver();
# endif
int msgLength = rf.send(protocol, message);
if (msgLength > 0) {
Log.trace(F("Adv data MQTTtoPilight push state via PilighttoMQTT" CR));
Pilightdata["origin"] = subjectGTWPilighttoMQTT;
handleJsonEnqueue(Pilightdata);
// Acknowledgement
pub(subjectGTWPilighttoMQTT, message);
success = true;
} else {
switch (msgLength) {
@@ -294,26 +274,11 @@ void MQTTtoPilight(char* topicOri, JsonObject& Pilightdata) {
}
}
}
if (Pilightdata.containsKey("active")) {
Log.trace(F("PiLight active:" CR));
activeReceiver = ACTIVE_PILIGHT; // Enable PILIGHT gateway
success = true;
}
# ifdef ZradioCC1101
if (Pilightdata.containsKey("mhz") && validFrequency(tempMhz)) {
receiveMhz = tempMhz;
Log.notice(F("PiLight Receive mhz: %F" CR), receiveMhz);
success = true;
}
# endif
if (success) {
// 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
pub(subjectGTWPilighttoMQTT, Pilightdata);
} else {
if (!success) {
pub(subjectGTWPilighttoMQTT, "{\"Status\": \"Error\"}"); // Fail feedback
Log.error(F("MQTTtoPilight Fail json" CR));
}
enableActiveReceiver(false);
enableActiveReceiver();
}
}
@@ -324,25 +289,13 @@ extern void disablePilightReceive() {
};
extern void enablePilightReceive() {
# ifdef ZradioCC1101
Log.notice(F("Switching to Pilight Receiver: %F" CR), receiveMhz);
# else
Log.notice(F("Switching to Pilight Receiver" CR));
# endif
# ifdef ZgatewayRF
disableRFReceive();
# endif
# ifdef ZgatewayRF2
disableRF2Receive();
# endif
# ifdef ZgatewayRTL_433
disableRTLreceive();
# endif
Log.notice(F("Switching to Pilight Receiver: %F" CR), RFConfig.frequency);
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayPilight command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoPilight);
initCC1101();
# ifdef ZradioCC1101
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.SetRx(receiveMhz); // set Receive on
# endif
rf.setCallback(pilightCallback);
# ifdef Pilight_rawEnabled
if (pilightRawEnabled) {
@@ -353,5 +306,6 @@ extern void enablePilightReceive() {
pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
rf.enableReceiver();
loadPilightConfig();
Log.trace(F("ZgatewayPilight setup done " CR));
};
#endif