Publishing/receiving inconsistencies fix (#1229)
* Publishing/receiving inconsistencies * General platformio.ini changes General platformio.ini changes to allow for publishing/receiving settings to be defined in User_cofig.h instead of them only working if defined in the environments. Kept separate so far for discussion.
This commit is contained in:
1 parent
3bd1d31fcc
commit
a388f14e75
15 files changed
+39
-40
No files matched your search
+8
-4
@@ -353,18 +353,22 @@ int lowpowermode = DEFAULT_LOW_POWER_MODE;
|
||||
#endif
|
||||
|
||||
#ifndef jsonPublishing
|
||||
# define jsonPublishing true //comment if you don't want to use Json publishing (one topic for all the parameters)
|
||||
# define jsonPublishing true //define false if you don't want to use Json publishing (one topic for all the parameters)
|
||||
#endif
|
||||
//example home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4 {"rssi":-63,"servicedata":"fe0000000000000000000000000000000000000000"}
|
||||
#ifndef jsonReceiving
|
||||
# define jsonReceiving true //comment if you don't want to use Json reception analysis
|
||||
# define jsonReceiving true //define false if you don't want to use Json reception analysis
|
||||
#endif
|
||||
|
||||
//#define simplePublishing true //comment if you don't want to use simple publishing (one topic for one parameter)
|
||||
#ifndef simplePublishing
|
||||
# define simplePublishing false //define true if you want to use simple publishing (one topic for one parameter)
|
||||
#endif
|
||||
//example
|
||||
// home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4/rssi -63.0
|
||||
// home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4/servicedata fe0000000000000000000000000000000000000000
|
||||
//#define simpleReceiving true //comment if you don't want to use old way reception analysis
|
||||
#ifndef simpleReceiving
|
||||
# define simpleReceiving true //define false if you don't want to use old way reception analysis
|
||||
#endif
|
||||
|
||||
/*-------------DEFINE YOUR OTA PARAMETERS BELOW----------------*/
|
||||
#ifndef ota_hostname
|
||||
|
||||
@@ -97,7 +97,7 @@ void FASTLEDLoop() {
|
||||
boolean FASTLEDtoMQTT() {
|
||||
return false;
|
||||
}
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoFASTLED(char* topicOri, JsonObject& jsonData) {
|
||||
currentLEDState = GENERAL;
|
||||
//trc(topicOri);
|
||||
@@ -121,7 +121,7 @@ void MQTTtoFASTLED(char* topicOri, JsonObject& jsonData) {
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoFASTLED(char* topicOri, char* datacallback) {
|
||||
Log.trace(F("MQTTtoFASTLED: " CR));
|
||||
currentLEDState = GENERAL;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#ifdef ZactuatorONOFF
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoONOFF)) {
|
||||
Log.trace(F("MQTTtoONOFF json data analysis" CR));
|
||||
@@ -70,7 +70,7 @@ void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) {
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoONOFF(char* topicOri, char* datacallback) {
|
||||
if ((cmpToMainTopic(topicOri, subjectMQTTtoONOFF))) {
|
||||
Log.trace(F("MQTTtoONOFF" CR));
|
||||
|
||||
@@ -195,7 +195,7 @@ boolean PWMtoMQTT() {
|
||||
return false;
|
||||
}
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoPWM(char* topicOri, JsonObject& jsonData) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoPWMset)) {
|
||||
Log.trace(F("MQTTtoPWM JSON analysis" CR));
|
||||
|
||||
@@ -51,7 +51,7 @@ void setupSomfy() {
|
||||
Log.trace(F("ZactuatorSomfy setup done " CR));
|
||||
}
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoSomfy(char* topicOri, JsonObject& jsonData) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoSomfy)) {
|
||||
# ifdef ZradioCC1101
|
||||
|
||||
+2
-2
@@ -95,7 +95,7 @@ bool _2GtoMQTT() {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTto2G(char* topicOri, char* datacallback) {
|
||||
String data = datacallback;
|
||||
String topic = topicOri;
|
||||
@@ -126,7 +126,7 @@ void MQTTto2G(char* topicOri, char* datacallback) {
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTto2G(char* topicOri, JsonObject& SMSdata) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTto2G)) {
|
||||
const char* sms = SMSdata["message"];
|
||||
|
||||
+1
-1
@@ -181,7 +181,7 @@ void IRtoMQTT() {
|
||||
|
||||
bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, const char* hex, unsigned int valueBITS, uint16_t valueRPT);
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoIR(char* topicOri, JsonObject& IRdata) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoIR)) {
|
||||
Log.trace(F("MQTTtoIR json" CR));
|
||||
|
||||
@@ -81,7 +81,7 @@ void LORAtoMQTT() {
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoLORA(char* topicOri, JsonObject& LORAdata) { // json object decoding
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoLORA)) {
|
||||
Log.trace(F("MQTTtoLORA json" CR));
|
||||
@@ -115,7 +115,7 @@ void MQTTtoLORA(char* topicOri, JsonObject& LORAdata) { // json object decoding
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoLORA(char* topicOri, char* LORAdata) { // json object decoding
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoLORA)) {
|
||||
LoRa.beginPacket();
|
||||
|
||||
+2
-2
@@ -173,7 +173,7 @@ void RFtoMQTT() {
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoRF(char* topicOri, char* datacallback) {
|
||||
# ifdef ZradioCC1101 // set Receive off and Transmitt on
|
||||
ELECHOUSE_cc1101.SetTx(receiveMhz);
|
||||
@@ -235,7 +235,7 @@ void MQTTtoRF(char* topicOri, char* datacallback) {
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoRF(char* topicOri, JsonObject& RFdata) { // json object decoding
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRF)) {
|
||||
Log.trace(F("MQTTtoRF json" CR));
|
||||
|
||||
@@ -148,7 +148,7 @@ void rf2Callback(unsigned int period, unsigned long address, unsigned long group
|
||||
rf2rd.hasNewData = true;
|
||||
}
|
||||
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoRF2(char* topicOri, char* datacallback) {
|
||||
# ifdef ZradioCC1101
|
||||
NewRemoteReceiver::disable();
|
||||
@@ -258,7 +258,7 @@ void MQTTtoRF2(char* topicOri, char* datacallback) {
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoRF2(char* topicOri, JsonObject& RF2data) { // json object decoding
|
||||
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRF2)) {
|
||||
|
||||
@@ -175,7 +175,7 @@ bool RFM69toMQTT(void) {
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoRFM69(char* topicOri, char* datacallback) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRFM69)) {
|
||||
Log.trace(F("MQTTtoRFM69 data analysis" CR));
|
||||
@@ -204,7 +204,7 @@ void MQTTtoRFM69(char* topicOri, char* datacallback) {
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoRFM69(char* topicOri, JsonObject& RFM69data) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRFM69)) {
|
||||
const char* data = RFM69data["data"];
|
||||
|
||||
@@ -166,7 +166,7 @@ bool _rfbToChar(byte* in, char* out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
# ifdef simpleReceiving
|
||||
# if simpleReceiving
|
||||
void MQTTtoSRFB(char* topicOri, char* datacallback) {
|
||||
// RF DATA ANALYSIS
|
||||
String topic = topicOri;
|
||||
@@ -262,7 +262,7 @@ void MQTTtoSRFB(char* topicOri, char* datacallback) {
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# ifdef jsonReceiving
|
||||
# if jsonReceiving
|
||||
void MQTTtoSRFB(char* topicOri, JsonObject& SRFBdata) {
|
||||
// RF DATA ANALYSIS
|
||||
const char* raw = SRFBdata["raw"];
|
||||
|
||||
+4
-4
@@ -328,12 +328,12 @@ void pub(const char* topicori, JsonObject& data) {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef jsonPublishing
|
||||
#if jsonPublishing
|
||||
Log.trace(F("jsonPubl - ON" CR));
|
||||
pubMQTT(topic, dataAsString.c_str());
|
||||
#endif
|
||||
|
||||
#ifdef simplePublishing
|
||||
#if simplePublishing
|
||||
Log.trace(F("simplePub - ON" CR));
|
||||
// Loop through all the key-value pairs in obj
|
||||
for (JsonPair p : data) {
|
||||
@@ -1696,7 +1696,7 @@ void receivingMQTT(char* topicOri, char* datacallback) {
|
||||
#ifdef ZgatewayRTL_433 // ZgatewayRTL_433 is only defined with json publishing due to its numerous parameters
|
||||
MQTTtoRTL_433(topicOri, jsondata);
|
||||
#endif
|
||||
#ifdef jsonReceiving
|
||||
#if jsonReceiving
|
||||
# ifdef ZgatewayLORA
|
||||
MQTTtoLORA(topicOri, jsondata);
|
||||
# endif
|
||||
@@ -1747,7 +1747,7 @@ void receivingMQTT(char* topicOri, char* datacallback) {
|
||||
|
||||
MQTTtoSYS(topicOri, jsondata);
|
||||
} else { // not a json object --> simple decoding
|
||||
#ifdef simpleReceiving
|
||||
#if simpleReceiving
|
||||
# ifdef ZgatewayLORA
|
||||
MQTTtoLORA(topicOri, datacallback);
|
||||
# endif
|
||||
|
||||
Reference in new issue
Block a user