From 162a4d3ae94914d59cb09aa8e31ae7b4e41c5fb1 Mon Sep 17 00:00:00 2001 From: peshovec Date: Sat, 28 Jun 2025 22:51:15 +0300 Subject: [PATCH] [RF] RF2, Pilight : fixups to RF2 transmit when using CC1100; fixups to Pilight when raw enabled (#2207) --- main/gatewayPilight.cpp | 2 +- main/gatewayRF2.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/main/gatewayPilight.cpp b/main/gatewayPilight.cpp index e459db9..cbd97ae 100644 --- a/main/gatewayPilight.cpp +++ b/main/gatewayPilight.cpp @@ -44,7 +44,7 @@ # include ESPiLight rf(RF_EMITTER_GPIO); // use -1 to disable transmitter - +extern int currentReceiver; # ifdef Pilight_rawEnabled // raw output support bool pilightRawEnabled = 0; diff --git a/main/gatewayRF2.cpp b/main/gatewayRF2.cpp index 0904c8e..2b2832d 100644 --- a/main/gatewayRF2.cpp +++ b/main/gatewayRF2.cpp @@ -42,6 +42,7 @@ sudo mosquitto_pub -t home/commands/MQTTtoRF2/CODE_8233372/UNIT_0/PERIOD_272 -m/ # ifdef ZradioCC1101 # include +extern void initCC1101(); # endif # include @@ -61,8 +62,6 @@ struct RF2rxd { RF2rxd rf2rd; -extern void initCC1101(); - # ifdef ZmqttDiscovery # include "config_mqttDiscovery.h" extern String getUniqueId(String name, String sufix); @@ -146,7 +145,15 @@ void rf2Callback(unsigned int period, unsigned long address, unsigned long group void XtoRF2(const char* topicOri, const char* datacallback) { disableCurrentReceiver(); pinMode(RF_EMITTER_GPIO, OUTPUT); +# ifdef ZradioCC1101 initCC1101(); + int txPower = RF_CC1101_TXPOWER; + ELECHOUSE_cc1101.setPA((int)txPower); + Log.notice(F("[RF] CC1101 TX Power: %d" CR), txPower); + float txFrequency = RFConfig.frequency; + ELECHOUSE_cc1101.SetTx(txFrequency); + Log.notice(F("[RF] Transmit frequency: %F" CR), txFrequency); +# endif // RF DATA ANALYSIS //We look into the subject to see if a special RF protocol is defined @@ -261,7 +268,15 @@ void XtoRF2(const char* topicOri, JsonObject& RF2data) { // json object decoding if (boolSWITCHTYPE != 99) { disableCurrentReceiver(); pinMode(RF_EMITTER_GPIO, OUTPUT); +# ifdef ZradioCC1101 initCC1101(); + int txPower = RF2data["txpower"] | RF_CC1101_TXPOWER; + ELECHOUSE_cc1101.setPA((int)txPower); + Log.notice(F("[RF] CC1101 TX Power: %d" CR), txPower); + float txFrequency = RF2data["frequency"] | RFConfig.frequency; + ELECHOUSE_cc1101.SetTx(txFrequency); + Log.notice(F("[RF] Transmit frequency: %F" CR), txFrequency); +# endif Log.trace(F("MQTTtoRF2 switch type ok" CR)); bool isDimCommand = boolSWITCHTYPE == 2; unsigned long valueCODE = RF2data["address"];