diff --git a/environments.ini b/environments.ini index bf003a1..fbd04c5 100644 --- a/environments.ini +++ b/environments.ini @@ -1748,4 +1748,4 @@ build_flags = '-DLED_SEND_RECEIVE_ON=0' '-DGateway_Name="OMG_ESP32_BLE"' '-DUSE_BLUFI=1' -custom_description = Regular BLE gateway with adaptive scanning activated, automatically adapts the scan parameters depending on your devices +custom_description = Regular BLE gateway based on esp-idf with adaptive scanning activated, automatically adapts the scan parameters depending on your devices diff --git a/main/ZcommonRF.ino b/main/ZcommonRF.ino index 5fa88cb..3bbdd2b 100644 --- a/main/ZcommonRF.ino +++ b/main/ZcommonRF.ino @@ -71,32 +71,30 @@ bool validFrequency(float mhz) { int currentReceiver = ACTIVE_NONE; # if !defined(ZgatewayRFM69) && !defined(ZactuatorSomfy) -# if defined(ESP8266) || defined(ESP32) // Check if a receiver is available bool validReceiver(int receiver) { switch (receiver) { -# ifdef ZgatewayPilight +# ifdef ZgatewayPilight case ACTIVE_PILIGHT: return true; -# endif -# ifdef ZgatewayRF +# endif +# ifdef ZgatewayRF case ACTIVE_RF: return true; -# endif -# ifdef ZgatewayRTL_433 +# endif +# ifdef ZgatewayRTL_433 case ACTIVE_RTL: return true; -# endif -# ifdef ZgatewayRF2 +# endif +# ifdef ZgatewayRF2 case ACTIVE_RF2: return true; -# endif +# endif default: Log.error(F("ERROR: stored receiver %d not available" CR), receiver); } return false; } -# endif # endif void disableCurrentReceiver() { diff --git a/main/ZgatewayIR.ino b/main/ZgatewayIR.ino index e432c39..60796e9 100644 --- a/main/ZgatewayIR.ino +++ b/main/ZgatewayIR.ino @@ -29,22 +29,16 @@ #ifdef ZgatewayIR -# if defined(ESP8266) || defined(ESP32) -# include // Needed if you want to receive IR commands. -# include -# include // Needed if you want to send IR commands. -# include -# ifdef DumpMode // in dump mode we increase the size of the buffer to catch big codes +# include // Needed if you want to receive IR commands. +# include +# include // Needed if you want to send IR commands. +# include +# ifdef DumpMode // in dump mode we increase the size of the buffer to catch big codes IRrecv irrecv(IR_RECEIVER_GPIO, 1024, 15U, true); -# else -IRrecv irrecv(IR_RECEIVER_GPIO); -# endif -IRsend irsend(IR_EMITTER_GPIO, IR_EMITTER_INVERTED); # else -# include IRrecv irrecv(IR_RECEIVER_GPIO); -IRsend irsend; //connect IR emitter pin to D9 on arduino, you need to comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library IRremote.h so as to free pin D3 for RF RECEIVER PIN # endif +IRsend irsend(IR_EMITTER_GPIO, IR_EMITTER_INVERTED); // IR protocol bits definition for Arduino (for ESP8266 they are defined in IRRemoteESP8266.h) # ifndef NEC_BITS @@ -98,10 +92,8 @@ uint64_t getUInt64fromHex(char const* str) { } void setupIR() { -//IR init parameters -# if defined(ESP8266) || defined(ESP32) + //IR init parameters irsend.begin(); -# endif irrecv.enableIRIn(); // Start the receiver @@ -125,35 +117,24 @@ void IRtoMQTT() { IRdata["value"] = (SIGNAL_SIZE_UL_ULL)(results.value); IRdata["protocol"] = (int)(results.decode_type); IRdata["bits"] = (int)(results.bits); -# if defined(ESP8266) || defined(ESP32) //resultToHexidecimal is only available with IRremoteESP8266 IRdata["hex"] = resultToHexidecimal(&results); IRdata["protocol_name"] = typeToString(results.decode_type, false); -# endif String rawCode = ""; // Dump data for (uint16_t i = 1; i < results.rawlen; i++) { -# if defined(ESP8266) || defined(ESP32) if (i % 100 == 0) yield(); // Preemptive yield every 100th entry to feed the WDT. rawCode = rawCode + (results.rawbuf[i] * RAWTICK); -# else - rawCode = rawCode + (results.rawbuf[i] * USECPERTICK); -# endif if (i < results.rawlen - 1) rawCode = rawCode + ","; // ',' not needed on last one } IRdata["raw"] = rawCode; // if needed we directly resend the raw code # ifdef RawDirectForward -# if defined(ESP8266) || defined(ESP32) uint16_t rawsend[results.rawlen]; for (uint16_t i = 1; i < results.rawlen; i++) { if (i % 100 == 0) yield(); // Preemptive yield every 100th entry to feed the WDT. -# else - unsigned int rawsend[results.rawlen]; - for (int i = 1; i < results.rawlen; i++) { -# endif rawsend[i] = results.rawbuf[i]; } irsend.sendRaw(rawsend, results.rawlen, RawFrequency); @@ -232,12 +213,8 @@ void MQTTtoIR(char* topicOri, JsonObject& IRdata) { # ifdef IR_RAW if (strcmp(protocol_name, "Raw") == 0) { // sending Raw data Log.trace(F("Raw" CR)); -//buffer allocation from char datacallback -# if defined(ESP8266) || defined(ESP32) + //buffer allocation from char datacallback uint16_t Raw[count + 1]; -# else - unsigned int Raw[count + 1]; -# endif String value = ""; int j = 0; for (int i = 0; i < s; i++) { @@ -262,12 +239,7 @@ void MQTTtoIR(char* topicOri, JsonObject& IRdata) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = NEC_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendNEC(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendNEC(data, valueBITS); -# endif signalSent = true; } if (signalSent) { // 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 @@ -300,12 +272,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = WHYNTER_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendWhynter(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendWhynter(data, valueBITS); -# endif return true; } # endif @@ -314,28 +281,16 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = LG_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendLG(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendLG(data, valueBITS); -# endif return true; } # endif # ifdef IR_SONY if (strcmp(protocol_name, "SONY") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); -# if defined(ESP8266) || defined(ESP32) if (valueBITS == 0) valueBITS = SONY_20_BITS; irsend.sendSony(data, valueBITS, valueRPT); -# else - if (valueBITS == 0) - valueBITS = SONY_12_BITS; - for (int i = 0; i <= valueRPT; i++) - irsend.sendSony(data, valueBITS); -# endif return true; } # endif @@ -344,12 +299,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = DISH_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendDISH(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendDISH(data, valueBITS); -# endif return true; } # endif @@ -358,12 +308,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = RC5_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendRC5(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendRC5(data, valueBITS); -# endif return true; } # endif @@ -372,12 +317,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = RC6_MODE0_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendRC6(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendRC6(data, valueBITS); -# endif return true; } # endif @@ -386,12 +326,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = SHARP_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendSharpRaw(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendSharpRaw(data, valueBITS); -# endif return true; } # endif @@ -400,12 +335,7 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = SAMSUNG_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendSAMSUNG(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendSAMSUNG(data, valueBITS); -# endif return true; } # endif @@ -414,32 +344,21 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = JVC_BITS; -# if defined(ESP8266) || defined(ESP32) irsend.sendJVC(data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendJVC(data, valueBITS); -# endif return true; } # endif # ifdef IR_PANASONIC if (strcmp(protocol_name, "PANASONIC") == 0) { -# if defined(ESP8266) || defined(ESP32) Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = PANASONIC_BITS; irsend.sendPanasonic(PanasonicAddress, data, valueBITS, valueRPT); -# else - for (int i = 0; i <= valueRPT; i++) - irsend.sendPanasonic(PanasonicAddress, data); -# endif return true; } # endif -# if defined(ESP8266) || defined(ESP32) -# ifdef IR_COOLIX +# ifdef IR_COOLIX if (strcmp(protocol_name, "COOLIX") == 0) { Log.trace(F("Sending %s:" CR), protocol_name); Log.notice(F("Sending IR signal with %s" CR), protocol_name); @@ -450,8 +369,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendCOOLIX(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_RCMM +# endif +# ifdef IR_RCMM if (strcmp(protocol_name, "RCMM") == 0) { Log.trace(F("Sending %s:" CR), protocol_name); Log.notice(F("Sending IR signal with %s" CR), protocol_name); @@ -460,8 +379,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendRCMM(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DENON +# endif +# ifdef IR_DENON if (strcmp(protocol_name, "DENON") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -469,8 +388,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDenon(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_GICABLE +# endif +# ifdef IR_GICABLE if (strcmp(protocol_name, "GICABLE") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -480,8 +399,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendGICable(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SHERWOOD +# endif +# ifdef IR_SHERWOOD if (strcmp(protocol_name, "SHERWOOD") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -491,8 +410,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSherwood(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHI +# endif +# ifdef IR_MITSUBISHI if (strcmp(protocol_name, "MITSUBISHI") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -502,8 +421,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishi(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_NIKAI +# endif +# ifdef IR_NIKAI if (strcmp(protocol_name, "NIKAI") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -511,8 +430,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendNikai(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MIDEA +# endif +# ifdef IR_MIDEA if (strcmp(protocol_name, "MIDEA") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -522,8 +441,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMidea(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MAGIQUEST +# endif +# ifdef IR_MAGIQUEST if (strcmp(protocol_name, "MAGIQUEST") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -531,8 +450,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMagiQuest(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_LASERTAG +# endif +# ifdef IR_LASERTAG if (strcmp(protocol_name, "LASERTAG") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -542,8 +461,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendLasertag(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_CARRIER_AC +# endif +# ifdef IR_CARRIER_AC if (strcmp(protocol_name, "CARRIER_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -553,8 +472,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendCarrierAC(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHI2 +# endif +# ifdef IR_MITSUBISHI2 if (strcmp(protocol_name, "MITSUBISHI2") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -564,8 +483,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishi2(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_AIWA_RC_T501 +# endif +# ifdef IR_AIWA_RC_T501 if (strcmp(protocol_name, "AIWA_RC_T501") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -575,8 +494,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendAiwaRCT501(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN +# endif +# ifdef IR_DAIKIN if (strcmp(protocol_name, "DAIKIN") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -586,8 +505,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_KELVINATOR +# endif +# ifdef IR_KELVINATOR if (strcmp(protocol_name, "KELVINATOR") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -597,8 +516,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendKelvinator(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHI_AC +# endif +# ifdef IR_MITSUBISHI_AC if (strcmp(protocol_name, "MITSUBISHI_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -608,8 +527,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishiAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SANYO +# endif +# ifdef IR_SANYO if (strcmp(protocol_name, "SANYOLC7461") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -617,8 +536,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSanyoLC7461(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_GREE +# endif +# ifdef IR_GREE if (strcmp(protocol_name, "GREE") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -628,8 +547,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendGree(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_ARGO +# endif +# ifdef IR_ARGO if (strcmp(protocol_name, "ARGO") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -639,8 +558,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendArgo(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TROTEC +# endif +# ifdef IR_TROTEC if (strcmp(protocol_name, "TROTEC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -650,8 +569,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTrotec(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TOSHIBA_AC +# endif +# ifdef IR_TOSHIBA_AC if (strcmp(protocol_name, "TOSHIBA_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -661,16 +580,16 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendToshibaAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_FUJITSU_AC +# endif +# ifdef IR_FUJITSU_AC if (strcmp(protocol_name, "FUJITSU_AC") == 0) { if (valueRPT == repeatIRwNumber) valueRPT = std::max(valueRPT, kFujitsuAcMinRepeat); irsend.sendFujitsuAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HAIER_AC +# endif +# ifdef IR_HAIER_AC if (strcmp(protocol_name, "HAIER_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -680,8 +599,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHaierAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC +# endif +# ifdef IR_HITACHI_AC if (strcmp(protocol_name, "HITACHI_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -691,8 +610,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC1 +# endif +# ifdef IR_HITACHI_AC1 if (strcmp(protocol_name, "HITACHI_AC1") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -702,8 +621,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAC1(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC2 +# endif +# ifdef IR_HITACHI_AC2 if (strcmp(protocol_name, "HITACHI_AC2") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -713,8 +632,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAC2(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HAIER_AC_YRW02 +# endif +# ifdef IR_HAIER_AC_YRW02 if (strcmp(protocol_name, "HAIER_AC_YRW02") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -724,8 +643,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHaierACYRW02(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_WHIRLPOOL_AC +# endif +# ifdef IR_WHIRLPOOL_AC if (strcmp(protocol_name, "WHIRLPOOL_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -735,8 +654,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendWhirlpoolAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SAMSUNG_AC +# endif +# ifdef IR_SAMSUNG_AC if (strcmp(protocol_name, "SAMSUNG_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -746,8 +665,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSamsungAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_LUTRON +# endif +# ifdef IR_LUTRON if (strcmp(protocol_name, "LUTRON") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -755,8 +674,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendLutron(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_ELECTRA_AC +# endif +# ifdef IR_ELECTRA_AC if (strcmp(protocol_name, "ELECTRA_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -764,8 +683,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendElectraAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_PANASONIC_AC +# endif +# ifdef IR_PANASONIC_AC if (strcmp(protocol_name, "PANASONIC_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -775,8 +694,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendPanasonicAC(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_PIONEER +# endif +# ifdef IR_PIONEER if (strcmp(protocol_name, "PIONEER") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -784,8 +703,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendPioneer(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_LG2 +# endif +# ifdef IR_LG2 if (strcmp(protocol_name, "LG2") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -793,14 +712,14 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendLG2(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MWM +# endif +# ifdef IR_MWM if (strcmp(protocol_name, "MWM") == 0) { irsend.sendMWM(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN2 +# endif +# ifdef IR_DAIKIN2 if (strcmp(protocol_name, "DAIKIN2") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -810,8 +729,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin2(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_VESTEL_AC +# endif +# ifdef IR_VESTEL_AC if (strcmp(protocol_name, "VESTEL_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -819,8 +738,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendVestelAc(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SAMSUNG36 +# endif +# ifdef IR_SAMSUNG36 if (strcmp(protocol_name, "SAMSUNG36") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -828,8 +747,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSamsung36(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TCL112AC +# endif +# ifdef IR_TCL112AC if (strcmp(protocol_name, "TCL112AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -839,8 +758,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTcl112Ac(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TECO +# endif +# ifdef IR_TECO if (strcmp(protocol_name, "TECO") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -848,8 +767,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTeco(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_LEGOPF +# endif +# ifdef IR_LEGOPF if (strcmp(protocol_name, "LEGOPF") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -859,8 +778,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendLegoPf(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHIHEAVY88 +# endif +# ifdef IR_MITSUBISHIHEAVY88 if (strcmp(protocol_name, "MITSUBISHIHEAVY88") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -870,8 +789,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishiHeavy88(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHIHEAVY152 +# endif +# ifdef IR_MITSUBISHIHEAVY152 if (strcmp(protocol_name, "MITSUBISHIHEAVY152") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -881,8 +800,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishiHeavy152(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN216 +# endif +# ifdef IR_DAIKIN216 if (strcmp(protocol_name, "DAIKIN216") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -892,8 +811,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin216(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SHARP_AC +# endif +# ifdef IR_SHARP_AC if (strcmp(protocol_name, "SHARP_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -903,8 +822,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSharpAc(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_GOODWEATHER +# endif +# ifdef IR_GOODWEATHER if (strcmp(protocol_name, "GOODWEATHER_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -914,8 +833,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendGoodweather(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_INAX +# endif +# ifdef IR_INAX if (strcmp(protocol_name, "INAX") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -925,8 +844,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendInax(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN160 +# endif +# ifdef IR_DAIKIN160 if (strcmp(protocol_name, "DAIKIN160") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -936,8 +855,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin160(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_NEOCLIMA +# endif +# ifdef IR_NEOCLIMA if (strcmp(protocol_name, "NEOCLIMA") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -947,8 +866,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendNeoclima(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN176 +# endif +# ifdef IR_DAIKIN176 if (strcmp(protocol_name, "DAIKIN176") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -958,8 +877,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin176(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN128 +# endif +# ifdef IR_DAIKIN128 if (strcmp(protocol_name, "DAIKIN128") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -969,8 +888,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin128(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_AMCOR +# endif +# ifdef IR_AMCOR if (strcmp(protocol_name, "AMCOR") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -980,8 +899,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendAmcor(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN152 +# endif +# ifdef IR_DAIKIN152 if (strcmp(protocol_name, "DAIKIN152") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -991,8 +910,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin152(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHI136 +# endif +# ifdef IR_MITSUBISHI136 if (strcmp(protocol_name, "MITSUBISHI136") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1002,8 +921,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishi136(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MITSUBISHI112 +# endif +# ifdef IR_MITSUBISHI112 if (strcmp(protocol_name, "MITSUBISHI112") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1013,8 +932,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMitsubishi112(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC424 +# endif +# ifdef IR_HITACHI_AC424 if (strcmp(protocol_name, "HITACHI_AC424") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1024,8 +943,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAc424(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SONY_38K +# endif +# ifdef IR_SONY_38K if (strcmp(protocol_name, "SONY_38K") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1035,8 +954,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSony38(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_EPSON +# endif +# ifdef IR_EPSON if (strcmp(protocol_name, "EPSON") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1046,8 +965,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendEpson(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SYMPHONY +# endif +# ifdef IR_SYMPHONY if (strcmp(protocol_name, "SYMPHONY") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1057,8 +976,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSymphony(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC3 +# endif +# ifdef IR_HITACHI_AC3 if (strcmp(protocol_name, "HITACHI_AC3") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1068,8 +987,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAc3(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DAIKIN64 +# endif +# ifdef IR_DAIKIN64 if (strcmp(protocol_name, "DAIKIN64") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1079,8 +998,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDaikin64(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_AIRWELL +# endif +# ifdef IR_AIRWELL if (strcmp(protocol_name, "AIRWELL") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1090,8 +1009,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendAirwell(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DELONGHI_AC +# endif +# ifdef IR_DELONGHI_AC if (strcmp(protocol_name, "DELONGHI_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1101,8 +1020,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDelonghiAc(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_DOSHISHA +# endif +# ifdef IR_DOSHISHA if (strcmp(protocol_name, "DOSHISHA") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1110,8 +1029,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendDoshisha(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_CARRIER_AC40 +# endif +# ifdef IR_CARRIER_AC40 if (strcmp(protocol_name, "CARRIER_AC40") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1121,8 +1040,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendCarrierAC40(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_CARRIER_AC64 +# endif +# ifdef IR_CARRIER_AC64 if (strcmp(protocol_name, "CARRIER_AC64") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1132,8 +1051,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendCarrierAC64(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC344 +# endif +# ifdef IR_HITACHI_AC344 if (strcmp(protocol_name, "HITACHI_AC344") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1141,8 +1060,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAc344(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_CORONA_AC +# endif +# ifdef IR_CORONA_AC if (strcmp(protocol_name, "CORONA_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1150,8 +1069,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendCoronaAc(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MIDEA24 +# endif +# ifdef IR_MIDEA24 if (strcmp(protocol_name, "MIDEA24") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1161,8 +1080,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMidea24(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_ZEPEAL +# endif +# ifdef IR_ZEPEAL if (strcmp(protocol_name, "ZEPEAL") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1172,8 +1091,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendZepeal(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SANYO_AC +# endif +# ifdef IR_SANYO_AC if (strcmp(protocol_name, "SANYO_AC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1181,8 +1100,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSanyoAc(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_VOLTAS +# endif +# ifdef IR_VOLTAS if (strcmp(protocol_name, "VOLTAS") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1190,8 +1109,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendVoltas(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_METZ +# endif +# ifdef IR_METZ if (strcmp(protocol_name, "METZ") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1201,8 +1120,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMetz(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TRANSCOLD +# endif +# ifdef IR_TRANSCOLD if (strcmp(protocol_name, "TRANSCOLD") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1212,8 +1131,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTranscold(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TECHNIBEL_AC +# endif +# ifdef IR_TECHNIBEL_AC if (strcmp(protocol_name, "TECHNIBELAC") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1223,8 +1142,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTechnibelAc(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MIRAGE +# endif +# ifdef IR_MIRAGE if (strcmp(protocol_name, "MIRAGE") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1234,8 +1153,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMirage(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_ELITESCREENS +# endif +# ifdef IR_ELITESCREENS if (strcmp(protocol_name, "ELITESCREENS") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1245,8 +1164,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendElitescreens(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_PANASONIC_AC32 +# endif +# ifdef IR_PANASONIC_AC32 if (strcmp(protocol_name, "PANASONIC_AC32") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1254,8 +1173,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendPanasonicAC32(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_MILESTAG2 +# endif +# ifdef IR_MILESTAG2 if (strcmp(protocol_name, "MILESTAG2") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueRPT == repeatIRwNumber) @@ -1265,8 +1184,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendMilestag2(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_ECOCLIM +# endif +# ifdef IR_ECOCLIM if (strcmp(protocol_name, "ECOCLIM") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1274,8 +1193,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendEcoclim(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_XMP +# endif +# ifdef IR_XMP if (strcmp(protocol_name, "XMP") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1283,8 +1202,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendXmp(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_KELON168 +# endif +# ifdef IR_KELON168 if (strcmp(protocol_name, "KELON168") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1292,8 +1211,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendKelon168(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TEKNOPOINT +# endif +# ifdef IR_TEKNOPOINT if (strcmp(protocol_name, "TEKNOPOINT") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1301,8 +1220,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTeknopoint(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HAIER_AC176 +# endif +# ifdef IR_HAIER_AC176 if (strcmp(protocol_name, "HAIER_AC176") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1310,8 +1229,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHaierAC176(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_BOSE +# endif +# ifdef IR_BOSE if (strcmp(protocol_name, "BOSE") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1319,8 +1238,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendBose(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_SANYO_AC88 +# endif +# ifdef IR_SANYO_AC88 if (strcmp(protocol_name, "SANYO_AC88") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1328,8 +1247,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendSanyoAc88(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_TROTEC_3550 +# endif +# ifdef IR_TROTEC_3550 if (strcmp(protocol_name, "TROTEC_3550") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1337,8 +1256,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendTrotec3550(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_ARRIS +# endif +# ifdef IR_ARRIS if (strcmp(protocol_name, "ARRIS") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1346,8 +1265,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendArris(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_RHOSS +# endif +# ifdef IR_RHOSS if (strcmp(protocol_name, "RHOSS") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1355,8 +1274,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendRhoss(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_AIRTON +# endif +# ifdef IR_AIRTON if (strcmp(protocol_name, "AIRTON") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1364,8 +1283,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendAirton(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_COOLIX48 +# endif +# ifdef IR_COOLIX48 if (strcmp(protocol_name, "COOLIX48") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1373,8 +1292,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendCoolix48(data, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC264 +# endif +# ifdef IR_HITACHI_AC264 if (strcmp(protocol_name, "HITACHI_AC264") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1382,8 +1301,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAc264(dataarray, valueBITS, valueRPT); return true; } -# endif -# ifdef IR_HITACHI_AC296 +# endif +# ifdef IR_HITACHI_AC296 if (strcmp(protocol_name, "HITACHI_AC296") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) @@ -1391,9 +1310,8 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data, irsend.sendHitachiAc296(dataarray, valueBITS, valueRPT); return true; } -# endif +# endif Log.warning(F("Unknown IR protocol" CR)); return false; -# endif } #endif diff --git a/main/ZgatewayRFM69.ino b/main/ZgatewayRFM69.ino index b190014..c616310 100644 --- a/main/ZgatewayRFM69.ino +++ b/main/ZgatewayRFM69.ino @@ -66,7 +66,6 @@ uint32_t gc_checksum() { return checksum; } -# if defined(ESP8266) || defined(ESP32) void eeprom_setup() { EEPROM.begin(4096); pGC = (struct _GLOBAL_CONFIG*)EEPROM.getDataPtr(); @@ -84,14 +83,11 @@ void eeprom_setup() { EEPROM.commit(); } } -# endif RFM69 radio; void setupRFM69(void) { -# if defined(ESP8266) || defined(ESP32) eeprom_setup(); -# endif int freq; static const char PROGMEM JSONtemplate[] = R"({"msgType":"config","freq":%d,"rfm69hcw":%d,"netid":%d,"power":%d})"; diff --git a/main/ZgatewayWeatherStation.ino b/main/ZgatewayWeatherStation.ino index 911267e..e1fa031 100644 --- a/main/ZgatewayWeatherStation.ino +++ b/main/ZgatewayWeatherStation.ino @@ -30,12 +30,7 @@ WeatherStationDataRx wsdr(RF_WS_RECEIVER_GPIO, true); void PairedDeviceAdded(byte newID) { -# if defined(ESP8266) || defined(ESP32) Serial.printf("ZgatewayWeatherStation: New device paired %d\r\n", newID); -# else - Serial.print("ZgatewayWeatherStation: New device paired "); - Serial.println(newID, DEC); -# endif StaticJsonDocument RFdataBuffer; JsonObject RFdata = RFdataBuffer.to(); RFdata["sensor"] = newID; diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index ff8805e..6b76684 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -480,7 +480,6 @@ void pubMqttDiscovery() { "", "", "", "", false, // device name, device manufacturer, device model, device ID, retain stateClassMeasurement //State Class ); -# if defined(ESP8266) || defined(ESP32) createDiscovery("sensor", //set Type subjectSYStoMQTT, "SYS: Free memory", (char*)getUniqueId("freemem", "").c_str(), //set state_topic,name,uniqueId will_Topic, "data_size", "{{ value_json.freemem }}", //set availability_topic,device_class,value_template, @@ -519,7 +518,7 @@ void pubMqttDiscovery() { stateClassNone, //State Class "false", "true" //state_off, state_on ); -# ifdef RGB_INDICATORS +# ifdef RGB_INDICATORS createDiscovery("number", //set Type subjectSYStoMQTT, "SYS: LED Brightness", (char*)getUniqueId("rgbb", "").c_str(), //set state_topic,name,uniqueId will_Topic, "", "{{ (value_json.rgbb/2.55) | round(0) }}", //set availability_topic,device_class,value_template, @@ -529,9 +528,9 @@ void pubMqttDiscovery() { "", "", "", "", false, // device name, device manufacturer, device model, device ID, retain, stateClassNone //State Class ); -# endif +# endif -# ifdef ZdisplaySSD1306 +# ifdef ZdisplaySSD1306 createDiscovery("switch", //set Type subjectSSD1306toMQTT, "SSD1306: Control", (char*)getUniqueId("onstate", "").c_str(), //set state_topic,name,uniqueId will_Topic, "", "{{ value_json.onstate }}", //set availability_topic,device_class,value_template, @@ -561,9 +560,9 @@ void pubMqttDiscovery() { "", "", "", "", false, // device name, device manufacturer, device model, device ID, retain stateClassNone //State Class ); -# endif +# endif -# ifndef ESP32_ETHERNET +# ifndef ESP32_ETHERNET createDiscovery("sensor", //set Type subjectSYStoMQTT, "SYS: RSSI", (char*)getUniqueId("rssi", "").c_str(), //set state_topic,name,uniqueId will_Topic, "signal_strength", "{{ value_json.rssi }}", //set availability_topic,device_class,value_template, @@ -573,7 +572,6 @@ void pubMqttDiscovery() { "", "", "", "", false, // device name, device manufacturer, device model, device ID, retain stateClassNone //State Class ); -# endif # endif # if defined(ESP32) && !defined(NO_INT_TEMP_READING) createDiscovery("sensor", //set Type diff --git a/main/ZsensorBME280.ino b/main/ZsensorBME280.ino index e61bc78..8379157 100644 --- a/main/ZsensorBME280.ino +++ b/main/ZsensorBME280.ino @@ -49,12 +49,8 @@ BME280 mySensor; void setupZsensorBME280() { -# if defined(ESP8266) || defined(ESP32) // Allow custom pins on ESP Platforms Wire.begin(BME280_PIN_SDA, BME280_PIN_SCL); -# else - Wire.begin(); -# endif mySensor.settings.commInterface = I2C_MODE; mySensor.settings.I2CAddress = BME280_i2c_addr; diff --git a/main/ZsensorGPIOInput.ino b/main/ZsensorGPIOInput.ino index 7795626..5e57776 100644 --- a/main/ZsensorGPIOInput.ino +++ b/main/ZsensorGPIOInput.ino @@ -57,9 +57,7 @@ void MeasureGPIOInput() { if ((millis() - lastDebounceTime) > GPIOInputDebounceDelay) { // whatever the reading is at, it's been there for longer than the debounce // delay, so take it as the actual current state: -# if defined(ESP8266) || defined(ESP32) yield(); -# endif # if defined(TRIGGER_GPIO) && INPUT_GPIO == TRIGGER_GPIO && !defined(ESPWifiManualSetup) if (reading == LOW) { if (resetTime == 0) { diff --git a/main/ZsensorGPIOKeyCode.ino b/main/ZsensorGPIOKeyCode.ino index 06c1723..ce42ad6 100644 --- a/main/ZsensorGPIOKeyCode.ino +++ b/main/ZsensorGPIOKeyCode.ino @@ -49,9 +49,7 @@ void MeasureGPIOKeyCode() { { // whatever the reading is at, it's been there for longer than the debounce // delay, so take it as the actual current state: -# if defined(ESP8266) || defined(ESP32) yield(); -# endif // if the Input state has changed: if (latch > 0 && lastLatchStateGPIOKeyCode != latch) { int reading = digitalRead(GPIOKeyCode_D0_GPIO) | (digitalRead(GPIOKeyCode_D1_GPIO) << 1) | (digitalRead(GPIOKeyCode_D2_GPIO) << 2); diff --git a/main/ZsensorHCSR501.ino b/main/ZsensorHCSR501.ino index 77f299d..bbd41a2 100644 --- a/main/ZsensorHCSR501.ino +++ b/main/ZsensorHCSR501.ino @@ -45,9 +45,7 @@ void MeasureHCSR501() { JsonObject HCSR501data = HCSR501dataBuffer.to(); static int pirState = LOW; int PresenceValue = digitalRead(HCSR501_GPIO); -# if defined(ESP8266) || defined(ESP32) yield(); -# endif if (PresenceValue == HIGH) { if (pirState == LOW) { //turned on diff --git a/main/main.ino b/main/main.ino index 24b706f..925bb55 100644 --- a/main/main.ino +++ b/main/main.ino @@ -245,7 +245,6 @@ int failure_number_mqtt = 0; // number of failure connecting to MQTT unsigned long timer_led_measures = 0; static void* eClient = nullptr; static unsigned long last_ota_activity_millis = 0; -#if defined(ESP8266) || defined(ESP32) // Global struct to store live SYS configuration data SYSConfig_s SYSConfig; @@ -255,7 +254,6 @@ static bool mqtt_cert_validate = MQTT_CERT_VALIDATE_DEFAULT; static uint8_t mqtt_ss_index = MQTT_SECURE_SELF_SIGNED_INDEX_DEFAULT; static String mqtt_cert = ""; static String ota_server_cert = ""; -#endif #ifdef ESP32 # include @@ -546,14 +544,11 @@ void pub(const char* topicori, const char* payload, bool retainFlag) { void pub(const char* topicori, JsonObject& data) { String dataAsString = ""; bool ret = sensor_Retain; - -#if defined(ESP8266) || defined(ESP32) -# if message_UTCtimestamp == true +#if message_UTCtimestamp == true data["UTCtime"] = UTCtimestamp(); -# endif -# if message_unixtimestamp == true +#endif +#if message_unixtimestamp == true data["unixtime"] = unixtimestamp(); -# endif #endif if (data.containsKey("retain") && data["retain"].is()) { ret = data["retain"]; @@ -760,26 +755,20 @@ bool cmpToMainTopic(const char* topicOri, const char* toAdd) { } void delayWithOTA(long waitMillis) { -#if defined(ESP8266) || defined(ESP32) long waitStep = 100; for (long waitedMillis = 0; waitedMillis < waitMillis; waitedMillis += waitStep) { -# ifndef ESPWifiManualSetup -# if defined(ESP8266) || defined(ESP32) +#ifndef ESPWifiManualSetup checkButton(); // check if a reset of wifi/mqtt settings is asked -# endif -# endif +#endif ArduinoOTA.handle(); -# if defined(ZwebUI) && defined(ESP32) +#if defined(ZwebUI) && defined(ESP32) WebUILoop(); -# endif -# ifdef ESP32 +#endif +#ifdef ESP32 //esp_task_wdt_reset(); -# endif +#endif delay(waitStep); } -#else - delay(waitMillis); -#endif } void SYSConfig_init() { @@ -831,9 +820,7 @@ void SYSConfig_load() {} void connectMQTT() { #ifndef ESPWifiManualSetup -# if defined(ESP8266) || defined(ESP32) checkButton(); // check if a reset of wifi/mqtt settings is asked -# endif #endif Log.warning(F("MQTT connection..." CR)); @@ -898,9 +885,7 @@ void connectMQTT() { // ... We consider that OTA might be still active, and we sleep for a while, and giving // OTA chance to proceed (ArduinoOTA.handle()) Log.warning(F("OTA might be still active (activity %d ms ago)" CR), millis_since_last_ota); -#if defined(ESP8266) || defined(ESP32) ArduinoOTA.handle(); -#endif delay(100); } ESPRestart(1); @@ -1035,15 +1020,14 @@ void setup() { SetupIndicatorInfo(); SetupIndicators(); // For RGB Leds -#if defined(ESP8266) || defined(ESP32) -# ifdef ESP8266 -# ifndef ZgatewaySRFB // if we are not in sonoff rf bridge case we apply the ESP8266 GPIO optimization +#ifdef ESP8266 +# ifndef ZgatewaySRFB // if we are not in sonoff rf bridge case we apply the ESP8266 GPIO optimization Serial.end(); Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY); // enable on ESP8266 to free some pin -# endif -# elif ESP32 +# endif +#elif ESP32 xQueueMutex = xSemaphoreCreateMutex(); -# if DEFAULT_LOW_POWER_MODE != -1 // don't check preferences value if low power mode is not activated +# if DEFAULT_LOW_POWER_MODE != -1 // don't check preferences value if low power mode is not activated preferences.begin(Gateway_Short_Name, false); if (preferences.isKey("lowpowermode")) { lowpowermode = preferences.getUInt("lowpowermode", DEFAULT_LOW_POWER_MODE); @@ -1051,15 +1035,15 @@ void setup() { Log.notice(F("No lowpowermode config to load" CR)); } preferences.end(); -# endif -# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK) || defined(ZboardM5TOUGH) +# endif +# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK) || defined(ZboardM5TOUGH) setupM5(); -# endif -# if defined(ZdisplaySSD1306) +# endif +# if defined(ZdisplaySSD1306) setupSSD1306(); modules.add(ZdisplaySSD1306); -# endif # endif +#endif Log.notice(F("OpenMQTTGateway Version: " OMG_VERSION CR)); @@ -1067,82 +1051,74 @@ void setup() { * Deep-sleep for the ESP8266 & ESP32 we need some form of indicator that we have posted the measurements and am ready to deep sleep. * When woken set back to false. */ -# if defined(DEEP_SLEEP_IN_US) || defined(ESP32_EXT0_WAKE_PIN) +#if defined(DEEP_SLEEP_IN_US) || defined(ESP32_EXT0_WAKE_PIN) ready_to_sleep = false; -# endif +#endif -# ifdef DEEP_SLEEP_IN_US -# ifdef ESP8266 +#ifdef DEEP_SLEEP_IN_US +# ifdef ESP8266 Log.notice(F("Setting wake pin for deep sleep." CR)); pinMode(ESP8266_DEEP_SLEEP_WAKE_PIN, WAKEUP_PULLUP); -# endif -# ifdef ESP32 +# endif +# ifdef ESP32 Log.notice(F("Setting duration for deep sleep." CR)); if (esp_sleep_enable_timer_wakeup(DEEP_SLEEP_IN_US) != ESP_OK) { Log.error(F("Failed to set deep sleep duration." CR)); } -# endif # endif +#endif -# ifdef ESP32_EXT0_WAKE_PIN +#ifdef ESP32_EXT0_WAKE_PIN Log.notice(F("Setting EXT0 Wakeup for deep sleep." CR)); if (esp_sleep_enable_ext0_wakeup(ESP32_EXT0_WAKE_PIN, ESP32_EXT0_WAKE_PIN_STATE) != ESP_OK) { Log.error(F("Failed to set deep sleep EXT0 Wakeup." CR)); } -# endif -# ifdef ESP32 +#endif +#ifdef ESP32 //esp_task_wdt_init(GeneralTimeOut, true); //enable panic so ESP32 restarts -# endif +#endif /* The 2 modules below are not connection dependent so start them before the connectivity functions Note that the ONOFF module need to start after the RN8209 so that the overCurrent function is launched after the setup of the sensor */ -# ifdef ZsensorRN8209 +#ifdef ZsensorRN8209 setupRN8209(); modules.add(ZsensorRN8209); -# endif -# ifdef ZactuatorONOFF +#endif +#ifdef ZactuatorONOFF setupONOFF(); modules.add(ZactuatorONOFF); -# endif +#endif -# if defined(ESPWifiManualSetup) +#if defined(ESPWifiManualSetup) setup_wifi(); -# else +#else if (loadConfigFromFlash()) { Log.notice(F("Config loaded from flash" CR)); -# ifdef ESP32_ETHERNET +# ifdef ESP32_ETHERNET setup_ethernet_esp32(); -# endif +# endif if (!failSafeMode && !ethConnected) setupwifi(false); } else { -# ifdef ESP32_ETHERNET +# ifdef ESP32_ETHERNET setup_ethernet_esp32(); -# endif +# endif Log.notice(F("No config in flash, launching wifi manager" CR)); // In failSafeMode we don't want to setup wifi manager as it has already been done before if (!failSafeMode) setupwifi(false); } -# endif +#endif Log.trace(F("OpenMQTTGateway mac: %s" CR), WiFi.macAddress().c_str()); Log.trace(F("OpenMQTTGateway ip: %s" CR), WiFi.localIP().toString().c_str()); setOTA(); -#else // In case of arduino platform - - //Launch serial for debugging purposes - Serial.begin(SERIAL_BAUD); - //Begining ethernet connection in case of Arduino + W5100 - setup_ethernet(); -#endif #if defined(ZwebUI) && defined(ESP32) WebUISetup(); modules.add(ZwebUI); #endif -#if defined(ESP8266) || defined(ESP32) if (mqtt_secure) { eClient = new WiFiClientSecure; if (mqtt_cert_validate) { @@ -1154,12 +1130,9 @@ void setup() { } else { eClient = new WiFiClient; } -#else - eClient = new EthernetClient; -#endif client.setClient(*(Client*)eClient); -#if defined(MDNS_SD) && (defined(ESP8266) || defined(ESP32)) +#if defined(MDNS_SD) Log.trace(F("Connecting to MQTT by mDNS without MQTT hostname" CR)); connectMQTTmdns(); #else @@ -1336,28 +1309,27 @@ void setup() { Log.notice(F("************** Setup OpenMQTTGateway end **************" CR)); } -#if defined(ESP8266) || defined(ESP32) // Bypass for ESP not reconnecting automaticaly the second time https://github.com/espressif/arduino-esp32/issues/2501 bool wifi_reconnect_bypass() { -# if defined(ESP32) && defined(USE_BLUFI) +#if defined(ESP32) && defined(USE_BLUFI) extern bool omg_blufi_ble_connected; if (omg_blufi_ble_connected) { Log.notice(F("BLUFI is connected, bypassing wifi reconnect" CR)); return true; } -# endif +#endif uint8_t wifi_autoreconnect_cnt = 0; -# ifdef ESP32 +#ifdef ESP32 while (WiFi.status() != WL_CONNECTED && wifi_autoreconnect_cnt < maxConnectionRetryNetwork) { -# else +#else while (WiFi.waitForConnectResult() != WL_CONNECTED && wifi_autoreconnect_cnt < maxConnectionRetryNetwork) { -# endif +#endif Log.notice(F("Attempting Wifi connection with saved AP: %d" CR), wifi_autoreconnect_cnt); WiFi.begin(); -# if (defined(ESP8266) || defined(ESP32)) && (defined(WifiGMode) || defined(WifiPower)) +#if defined(WifiGMode) || defined(WifiPower) setESPWifiProtocolTxPower(); -# endif +#endif delay(1000); wifi_autoreconnect_cnt++; } @@ -1383,12 +1355,12 @@ void setOTA() { ErrorIndicatorON(); SendReceiveIndicatorON(); last_ota_activity_millis = millis(); -# ifdef ESP32 +#ifdef ESP32 ProcessLock = true; -# ifdef ZgatewayBT +# ifdef ZgatewayBT stopProcessing(); -# endif # endif +#endif lpDisplayPrint("OTA in progress"); }); ArduinoOTA.onEnd([]() { @@ -1401,9 +1373,9 @@ void setOTA() { }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { Log.trace(F("Progress: %u%%\r" CR), (progress / (total / 100))); -# ifdef ESP32 +#ifdef ESP32 //esp_task_wdt_reset(); -# endif +#endif last_ota_activity_millis = millis(); }); ArduinoOTA.onError([](ota_error_t error) { @@ -1429,25 +1401,25 @@ void setOTA() { void setupTLS(bool self_signed, uint8_t index) { configTime(0, 0, NTP_SERVER); WiFiClientSecure* sClient = (WiFiClientSecure*)eClient; -# if MQTT_SECURE_SELF_SIGNED +#if MQTT_SECURE_SELF_SIGNED if (self_signed) { Log.notice(F("Using self signed cert index %u" CR), index); -# if defined(ESP32) +# if defined(ESP32) sClient->setCACert(certs_array[index].server_cert); -# if AWS_IOT +# if AWS_IOT if (strcmp(mqtt_port, "443") == 0) { sClient->setAlpnProtocols(alpnProtocols); } -# endif -# if MQTT_SECURE_SELF_SIGNED_CLIENT +# endif +# if MQTT_SECURE_SELF_SIGNED_CLIENT sClient->setCertificate(certs_array[index].client_cert); sClient->setPrivateKey(certs_array[index].client_key); -# endif -# elif defined(ESP8266) +# endif +# elif defined(ESP8266) caCert.append(certs_array[index].server_cert); sClient->setTrustAnchors(&caCert); sClient->setBufferSizes(512, 512); -# if MQTT_SECURE_SELF_SIGNED_CLIENT +# if MQTT_SECURE_SELF_SIGNED_CLIENT if (pClCert != nullptr) { delete pClCert; } @@ -1457,32 +1429,27 @@ void setupTLS(bool self_signed, uint8_t index) { pClCert = new X509List(certs_array[index].client_cert); pClKey = new PrivateKey(certs_array[index].client_key); sClient->setClientRSACert(pClCert, pClKey); -# endif # endif - } else # endif + } else +#endif { if (mqtt_cert.length() > 0) { -# if defined(ESP32) +#if defined(ESP32) sClient->setCACert(mqtt_cert.c_str()); } else { sClient->setCACert(certificate); } -# elif defined(ESP8266) +#elif defined(ESP8266) caCert.append(mqtt_cert.c_str()); } else { caCert.append(certificate); } sClient->setTrustAnchors(&caCert); sClient->setBufferSizes(512, 512); -# endif +#endif } } -#else -bool wifi_reconnect_bypass() { - return true; -} -#endif /* Reboot for Reason Codes @@ -1495,7 +1462,6 @@ bool wifi_reconnect_bypass() { 7 - Parameters changed 8 - not enough memory to pursue */ -#if defined(ESP8266) || defined(ESP32) void ESPRestart(byte reason) { delay(1000); StaticJsonDocument<128> jsonBuffer; @@ -1505,15 +1471,12 @@ void ESPRestart(byte reason) { jsondata["uptime"] = uptime(); pub(subjectLOGtoMQTT, jsondata); Log.warning(F("Rebooting for reason code %d" CR), reason); -# if defined(ESP32) +#if defined(ESP32) ESP.restart(); -# elif defined(ESP8266) +#elif defined(ESP8266) ESP.reset(); -# endif -} -#else -void ESPRestart(byte reason) {} #endif +} #if defined(ESPWifiManualSetup) void setup_wifi() { @@ -1568,7 +1531,7 @@ void setup_wifi() { displayPrint("Wifi connected"); } -#elif defined(ESP8266) || defined(ESP32) +#else WiFiManager wifiManager; @@ -1983,33 +1946,9 @@ void WiFiEvent(WiFiEvent_t event) { } } # endif -#else // Arduino case -void setup_ethernet() { -# ifdef NetworkAdvancedSetup - IPAddress ip_adress; - IPAddress gateway_adress; - IPAddress subnet_adress; - IPAddress dns_adress; - ip.fromString(NET_IP); - gateway.fromString(NET_GW); - subnet.fromString(NET_MASK); - Dns.fromString(NET_DNS); - - Log.trace(F("Adv eth cfg" CR)); - Ethernet.begin(mac, ip, Dns, gateway, subnet); -# else - Log.trace(F("Spl eth cfg" CR)); - Ethernet.begin(mac, ip); -# endif - if (Ethernet.hardwareStatus() == EthernetNoHardware) { - Log.error(F("Ethernet shield was not found." CR)); - } else { - Log.trace(F("ip: %s " CR), Ethernet.localIP()); - } -} #endif -#if defined(MDNS_SD) && (defined(ESP8266) || defined(ESP32)) +#if defined(MDNS_SD) void connectMQTTmdns() { Log.trace(F("Browsing for MQTT service" CR)); int n = MDNS.queryService("mqtt", "tcp"); @@ -2033,9 +1972,7 @@ void connectMQTTmdns() { void loop() { #ifndef ESPWifiManualSetup -# if defined(ESP8266) || defined(ESP32) checkButton(); // check if a reset of wifi/mqtt settings is asked -# endif #endif #ifdef ESP32 @@ -2051,15 +1988,11 @@ void loop() { SendReceiveIndicatorOFF(); } -#if defined(ESP8266) || defined(ESP32) if (ethConnected || WiFi.status() == WL_CONNECTED) { if (ethConnected && WiFi.status() == WL_CONNECTED) { WiFi.disconnect(); // we disconnect the wifi as we are connected to ethernet } ArduinoOTA.handle(); -#else - if ((Ethernet.hardwareStatus() != EthernetW5100 && Ethernet.linkStatus() == LinkON) || (Ethernet.hardwareStatus() == EthernetW5100)) { //we are able to detect disconnection only on w5200 and w5500 -#endif failure_number_ntwk = 0; #if defined(ZwebUI) && defined(ESP32) WebUILoop(); @@ -2105,10 +2038,8 @@ void loop() { #endif } if (now > (timer_sys_checks + (TimeBetweenCheckingSYS * 1000)) || !timer_sys_checks) { -#if defined(ESP8266) || defined(ESP32) -# if message_UTCtimestamp || message_unixtimestamp +#if message_UTCtimestamp || message_unixtimestamp syncNTP(); -# endif #endif if (!timer_sys_checks) { // Update check at start up only #if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE) @@ -2324,7 +2255,6 @@ float intTemperatureRead() { } #endif -#if defined(ESP8266) || defined(ESP32) void syncNTP() { configTime(0, 0, NTP_SERVER); time_t now = time(nullptr); @@ -2359,21 +2289,19 @@ String UTCtimestamp() { void eraseAndRestart() { Log.trace(F("Formatting requested, result: %d" CR), SPIFFS.format()); -# if defined(ESP8266) +#if defined(ESP8266) WiFi.disconnect(true); -# ifndef ESPWifiManualSetup +# ifndef ESPWifiManualSetup wifiManager.resetSettings(); -# endif +# endif delay(5000); ESP.reset(); -# else +#else //esp_task_wdt_delete(NULL); nvs_flash_erase(); ESP.restart(); -# endif -} - #endif +} String stateMeasures() { StaticJsonDocument SYSdata; @@ -2388,41 +2316,40 @@ String stateMeasures() { SYSdata["disc"] = SYSConfig.discovery; SYSdata["ohdisc"] = SYSConfig.ohdiscovery; #endif -#if defined(ESP8266) || defined(ESP32) SYSdata["env"] = ENV_NAME; uint32_t freeMem; uint32_t minFreeMem; freeMem = ESP.getFreeHeap(); -# ifdef ZgatewayRTL_433 +#ifdef ZgatewayRTL_433 // Some RTL_433 decoders have memory leak, this is a temporary workaround if (freeMem < MinimumMemory) { Log.error(F("Not enough memory %d, restarting" CR), freeMem); ESPRestart(8); } -# endif +#endif SYSdata["freemem"] = freeMem; SYSdata["mqttp"] = mqtt_port; SYSdata["mqtts"] = mqtt_secure; SYSdata["msgprc"] = queueLengthSum; SYSdata["msgblck"] = blockedMessages; SYSdata["maxq"] = maxQueueLength; -# ifdef ESP32 +#ifdef ESP32 minFreeMem = ESP.getMinFreeHeap(); SYSdata["minmem"] = minFreeMem; -# ifndef NO_INT_TEMP_READING +# ifndef NO_INT_TEMP_READING SYSdata["tempc"] = round2(intTemperatureRead()); -# endif - SYSdata["freestck"] = uxTaskGetStackHighWaterMark(NULL); # endif + SYSdata["freestck"] = uxTaskGetStackHighWaterMark(NULL); +#endif SYSdata["eth"] = ethConnected; if (ethConnected) { -# ifdef ESP32_ETHERNET +#ifdef ESP32_ETHERNET SYSdata["mac"] = (char*)ETH.macAddress().c_str(); SYSdata["ip"] = ip2CharArray(ETH.localIP()); ETH.fullDuplex() ? SYSdata["fd"] = (bool)"true" : SYSdata["fd"] = (bool)"false"; SYSdata["linkspeed"] = (int)ETH.linkSpeed(); -# endif +#endif } else { SYSdata["rssi"] = (long)WiFi.RSSI(); SYSdata["SSID"] = (char*)WiFi.SSID().c_str(); @@ -2431,7 +2358,6 @@ String stateMeasures() { SYSdata["mac"] = (char*)WiFi.macAddress().c_str(); } -#endif #ifdef ZgatewayBT # ifdef ESP32 SYSdata["lowpowermode"] = (int)lowpowermode; @@ -2860,50 +2786,49 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding if (cmpToMainTopic(topicOri, subjectMQTTtoSYSset)) { bool restartESP = false; Log.trace(F("MQTTtoSYS json" CR)); -#if defined(ESP8266) || defined(ESP32) if (SYSdata.containsKey("cmd")) { const char* cmd = SYSdata["cmd"]; Log.notice(F("Command: %s" CR), cmd); if (strstr(cmd, restartCmd) != NULL) { //restart ESPRestart(5); } else if (strstr(cmd, eraseCmd) != NULL) { //erase and restart -# ifndef ESPWifiManualSetup +#ifndef ESPWifiManualSetup setupwifi(true); -# endif +#endif } else if (strstr(cmd, statusCmd) != NULL) { //erase and restart stateMeasures(); } } -# ifdef RGB_INDICATORS +#ifdef RGB_INDICATORS if (SYSdata.containsKey("rgbb") && SYSdata["rgbb"].is()) { if (SYSdata["rgbb"] >= 0 && SYSdata["rgbb"] <= 255) { SYSConfig.rgbbrightness = round2(SYSdata["rgbb"]); leds.setBrightness(SYSConfig.rgbbrightness); leds.show(); -# ifdef ZactuatorONOFF +# ifdef ZactuatorONOFF updatePowerIndicator(); -# endif +# endif Log.notice(F("RGB brightness: %d" CR), SYSConfig.rgbbrightness); stateMeasures(); } else { Log.error(F("RGB brightness value invalid - ignoring command" CR)); } } -# endif -# ifdef ZmqttDiscovery +#endif +#ifdef ZmqttDiscovery if (SYSdata.containsKey("ohdisc") && SYSdata["ohdisc"].is()) { SYSConfig.ohdiscovery = SYSdata["ohdisc"]; Log.notice(F("OpenHAB discovery: %T" CR), SYSConfig.ohdiscovery); stateMeasures(); } -# endif +#endif if (SYSdata.containsKey("wifi_ssid") && SYSdata.containsKey("wifi_pass")) { -# ifdef ESP32 +#ifdef ESP32 ProcessLock = true; -# ifdef ZgatewayBT +# ifdef ZgatewayBT stopProcessing(); -# endif # endif +#endif String prev_ssid = WiFi.SSID(); String prev_pass = WiFi.psk(); client.disconnect(); @@ -2911,18 +2836,18 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding Log.warning(F("Attempting connection to new AP %s" CR), (const char*)SYSdata["wifi_ssid"]); WiFi.begin((const char*)SYSdata["wifi_ssid"], (const char*)SYSdata["wifi_pass"]); -# if (defined(ESP8266) || defined(ESP32)) && (defined(WifiGMode) || defined(WifiPower)) +#if defined(WifiGMode) || defined(WifiPower) setESPWifiProtocolTxPower(); -# endif +#endif WiFi.waitForConnectResult(WiFi_TimeOut * 1000); if (WiFi.status() != WL_CONNECTED) { Log.error(F("Failed to connect to new AP; falling back" CR)); WiFi.disconnect(true); WiFi.begin(prev_ssid.c_str(), prev_pass.c_str()); -# if (defined(ESP8266) || defined(ESP32)) && (defined(WifiGMode) || defined(WifiPower)) +#if defined(WifiGMode) || defined(WifiPower) setESPWifiProtocolTxPower(); -# endif +#endif } restartESP = true; } @@ -2940,13 +2865,13 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding strncpy(ota_pass, SYSdata["gw_pass"], parameters_size); restartESP = true; } -# ifndef ESPWifiManualSetup +#ifndef ESPWifiManualSetup saveConfig(); -# endif +#endif disconnectClient = true; // trigger reconnect in loop using the new topic/name } -# ifdef MQTTsetMQTT +#ifdef MQTTsetMQTT if (SYSdata.containsKey("mqtt_user") && SYSdata.containsKey("mqtt_pass")) { bool update_server = false; bool secure_connect = SYSdata["mqtt_secure"].as(); @@ -2959,7 +2884,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding Log.error(F("mqtt_server provided without mqtt_secure defined - ignoring command" CR)); return; } -# if MQTT_SECURE_SELF_SIGNED +# if MQTT_SECURE_SELF_SIGNED if (use_ss_cert) { cert_index = SYSdata["mqtt_cert_index"].as(); if (cert_index >= sizeof(certs_array) / sizeof(ss_certs)) { @@ -2967,14 +2892,14 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding return; } } -# endif +# endif -# ifdef ESP32 +# ifdef ESP32 ProcessLock = true; -# ifdef ZgatewayBT +# ifdef ZgatewayBT stopProcessing(); -# endif # endif +# endif disconnectClient = false; client.disconnect(); update_server = true; @@ -2996,12 +2921,12 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding client.setServer(SYSdata["mqtt_server"].as(), SYSdata["mqtt_port"].as()); } else { -# ifdef ESP32 +# ifdef ESP32 ProcessLock = true; -# ifdef ZgatewayBT +# ifdef ZgatewayBT stopProcessing(); -# endif # endif +# endif disconnectClient = false; client.disconnect(); } @@ -3023,9 +2948,9 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding delete prev_client; } } -# ifndef ESPWifiManualSetup +# ifndef ESPWifiManualSetup saveConfig(); -# endif +# endif } else { if (update_server) { if (prev_client != nullptr) { @@ -3045,12 +2970,11 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding } restartESP = true; } -# endif +#endif if (disconnectClient) { client.disconnect(); } -#endif #ifdef ZmqttDiscovery if (SYSdata.containsKey("disc")) { @@ -3116,4 +3040,4 @@ String toString(uint32_t input) { return result; } -#endif +#endif \ No newline at end of file