diff --git a/docs/upload/builds.md b/docs/upload/builds.md index 021d2a3d42..bd6c8dd679 100644 --- a/docs/upload/builds.md +++ b/docs/upload/builds.md @@ -29,8 +29,6 @@ lib_deps = ${libraries.arduinolog} build_flags = -w ; supress all warnings - '-DjsonPublishing=true' - '-DjsonReceiving=true' ; '-DLOG_LEVEL=LOG_LEVEL_TRACE' ; Enable trace level logging monitor_speed = 115200 ``` @@ -96,8 +94,8 @@ build_flags = '-DLED_RECEIVE_ON=LOW' ; Comment 2 '-DRF_RECEIVER_GPIO=13' '-DRF_EMITTER_GPIO=15' - '-UsimpleReceiving' ; Disable HA discovery - '-UZmqttDiscovery' + '-DsimpleReceiving=false' + '-UZmqttDiscovery' ; Disable HA discovery monitor_speed = 115200 [env:nodemcuv2-pilight-bme280-ota] @@ -108,7 +106,7 @@ upload_flags = --auth=otapassword --port=8266 ``` -The first new environment we create, `nodemcuv2-pilight-bme280`, inherits the default `nodemcuv2-pilight` environment in `platformio.ini` with the `extends = env:nodemcuv2-pilight` line. In the `lib_deps` section, it imports all the `lib_deps` of `nodemcuv2-pilight` with the `${env:nodemcuv2-pilight.lib_deps}` line, and adds BME280 on top of it. (Since the environment we're extending already has this `lib_deps` attribute, specifying it again would normally replace it completely with our new attribute; instead, to keep its value but simply append to it, we import the original in the beginning of our `lib_deps` attribute.) In the `build_flags` section, it again imports all the `build_flags` of `nodemcuv2-pilight` and many of its own overrides, e.g. changing `Base_Topic` found in `User_config.h` from the default to "rf/" by using the `'-DBase_Topic="rf/"'` line. It also unsets previously set configurations (i.e. `simpleReceiving`) by using `'-UsimpleReceiving'`. This environment will work over serial upload. +The first new environment we create, `nodemcuv2-pilight-bme280`, inherits the default `nodemcuv2-pilight` environment in `platformio.ini` with the `extends = env:nodemcuv2-pilight` line. In the `lib_deps` section, it imports all the `lib_deps` of `nodemcuv2-pilight` with the `${env:nodemcuv2-pilight.lib_deps}` line, and adds BME280 on top of it. (Since the environment we're extending already has this `lib_deps` attribute, specifying it again would normally replace it completely with our new attribute; instead, to keep its value but simply append to it, we import the original in the beginning of our `lib_deps` attribute.) In the `build_flags` section, it again imports all the `build_flags` of `nodemcuv2-pilight` and many of its own overrides, e.g. changing `Base_Topic` found in `User_config.h` from the default to "rf/" by using the `'-DBase_Topic="rf/"'` line. It also unsets previously set configurations (i.e. `mqttDiscovery`) by using `'-UZmqttDiscovery'`. This environment will work over serial upload. The second new environment, `nodemcuv2-pilight-bme280-ota`, inherits everything we specified in the first environment (with the line `extends = env:nodemcuv2-pilight-bme280`), but modifies it to upload over OTA (Wi-Fi). We also specified this as the `default_env` in the beginning of the file, so PlatformIO will choose this environment to build and upload if we don't specify otherwise. @@ -230,14 +228,14 @@ Per default Json reception and Json publication is activated, the previous simpl You can deactivate Json or simple mode following theses instructions: ```cpp -#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) //example home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4 {"rssi":-63,"servicedata":"fe0000000000000000000000000000000000000000"} -//#define simplePublishing true //comment if you don't want to use simple publishing (one topic for one parameter) +#define simplePublishing false //define true if you want to use simple publishing (one topic for one parameter) //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 -#define jsonReceiving true //comment if you don't want to use Json reception analysis +#define simpleReceiving true //define false if you don't want to use old way reception analysis +#define jsonReceiving true //define false if you don't want to use Json reception analysis ``` If you are using platformio you can also comment the definitions above and define your parameters into platformio.ini file by setting the following `build_flags`: diff --git a/main/User_config.h b/main/User_config.h index dddd487bdd..4a44c05f78 100644 --- a/main/User_config.h +++ b/main/User_config.h @@ -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 diff --git a/main/ZactuatorFASTLED.ino b/main/ZactuatorFASTLED.ino index 646ce5a419..b75dabf007 100644 --- a/main/ZactuatorFASTLED.ino +++ b/main/ZactuatorFASTLED.ino @@ -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; diff --git a/main/ZactuatorONOFF.ino b/main/ZactuatorONOFF.ino index f15cd9eaab..b15d4998ce 100644 --- a/main/ZactuatorONOFF.ino +++ b/main/ZactuatorONOFF.ino @@ -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)); diff --git a/main/ZactuatorPWM.ino b/main/ZactuatorPWM.ino index 5064cbbd84..2efd6fcb2e 100644 --- a/main/ZactuatorPWM.ino +++ b/main/ZactuatorPWM.ino @@ -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)); diff --git a/main/ZactuatorSomfy.ino b/main/ZactuatorSomfy.ino index 5b931443e4..6e8b907463 100644 --- a/main/ZactuatorSomfy.ino +++ b/main/ZactuatorSomfy.ino @@ -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 diff --git a/main/Zgateway2G.ino b/main/Zgateway2G.ino index 0f8d8b117e..2adde7c246 100644 --- a/main/Zgateway2G.ino +++ b/main/Zgateway2G.ino @@ -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"]; diff --git a/main/ZgatewayIR.ino b/main/ZgatewayIR.ino index cc1d0f5257..4d140fedc9 100644 --- a/main/ZgatewayIR.ino +++ b/main/ZgatewayIR.ino @@ -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)); diff --git a/main/ZgatewayLORA.ino b/main/ZgatewayLORA.ino index 51565ba1d2..c9c722d7fa 100644 --- a/main/ZgatewayLORA.ino +++ b/main/ZgatewayLORA.ino @@ -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(); diff --git a/main/ZgatewayRF.ino b/main/ZgatewayRF.ino index 468b7f14d8..a73a9cf355 100644 --- a/main/ZgatewayRF.ino +++ b/main/ZgatewayRF.ino @@ -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)); diff --git a/main/ZgatewayRF2.ino b/main/ZgatewayRF2.ino index 519ecc9543..03de901122 100644 --- a/main/ZgatewayRF2.ino +++ b/main/ZgatewayRF2.ino @@ -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)) { diff --git a/main/ZgatewayRFM69.ino b/main/ZgatewayRFM69.ino index 572a4fa41e..cb668ea182 100644 --- a/main/ZgatewayRFM69.ino +++ b/main/ZgatewayRFM69.ino @@ -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"]; diff --git a/main/ZgatewaySRFB.ino b/main/ZgatewaySRFB.ino index b5b700e595..54e27ffe28 100644 --- a/main/ZgatewaySRFB.ino +++ b/main/ZgatewaySRFB.ino @@ -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"]; diff --git a/main/main.ino b/main/main.ino index 63b93e509c..000581f583 100644 --- a/main/main.ino +++ b/main/main.ino @@ -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 diff --git a/platformio.ini b/platformio.ini index a54b92a700..d24efdeb22 100644 --- a/platformio.ini +++ b/platformio.ini @@ -144,8 +144,6 @@ lib_deps = ${libraries.arduinolog} build_flags = -w ; supress all warnings - '-DjsonPublishing=true' - '-DjsonReceiving=true' ; '-DLOG_LEVEL=LOG_LEVEL_TRACE' ; Enable trace level logging monitor_speed = 115200 @@ -159,7 +157,6 @@ lib_deps = ${env.lib_deps} build_flags = ${env.build_flags} - '-DsimpleReceiving=true' '-DZmqttDiscovery="HADiscovery"' '-DTRACE=1' '-DCONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED' @@ -174,7 +171,6 @@ lib_deps = ${libraries.ethernet} build_flags = ${env.build_flags} - '-DsimpleReceiving=true' '-DZmqttDiscovery="HADiscovery"' '-DTRACE=1' @@ -184,6 +180,7 @@ lib_deps = ${libraries.ethernet} build_flags = ${env.build_flags} + '-DsimpleReceiving=false' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ENVIRONMENTS LIST ;