[SYS] Remove unnecessaries ESP8266 ESP32 macros (#1931)
This commit is contained in:
1 parent
2065d57e11
commit
2645928dbd
11 files changed
+7
-188
No files matched your search
+1
-1
@@ -1748,4 +1748,4 @@ build_flags =
|
|||||||
'-DLED_SEND_RECEIVE_ON=0'
|
'-DLED_SEND_RECEIVE_ON=0'
|
||||||
'-DGateway_Name="OMG_ESP32_BLE"'
|
'-DGateway_Name="OMG_ESP32_BLE"'
|
||||||
'-DUSE_BLUFI=1'
|
'-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
|
||||||
@@ -71,7 +71,6 @@ bool validFrequency(float mhz) {
|
|||||||
int currentReceiver = ACTIVE_NONE;
|
int currentReceiver = ACTIVE_NONE;
|
||||||
|
|
||||||
# if !defined(ZgatewayRFM69) && !defined(ZactuatorSomfy)
|
# if !defined(ZgatewayRFM69) && !defined(ZactuatorSomfy)
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
// Check if a receiver is available
|
// Check if a receiver is available
|
||||||
bool validReceiver(int receiver) {
|
bool validReceiver(int receiver) {
|
||||||
switch (receiver) {
|
switch (receiver) {
|
||||||
@@ -97,7 +96,6 @@ bool validReceiver(int receiver) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# endif
|
|
||||||
|
|
||||||
void disableCurrentReceiver() {
|
void disableCurrentReceiver() {
|
||||||
Log.trace(F("disableCurrentReceiver: %d" CR), currentReceiver);
|
Log.trace(F("disableCurrentReceiver: %d" CR), currentReceiver);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#ifdef ZgatewayIR
|
#ifdef ZgatewayIR
|
||||||
|
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
# include <IRrecv.h> // Needed if you want to receive IR commands.
|
# include <IRrecv.h> // Needed if you want to receive IR commands.
|
||||||
# include <IRremoteESP8266.h>
|
# include <IRremoteESP8266.h>
|
||||||
# include <IRsend.h> // Needed if you want to send IR commands.
|
# include <IRsend.h> // Needed if you want to send IR commands.
|
||||||
@@ -40,11 +39,6 @@ IRrecv irrecv(IR_RECEIVER_GPIO, 1024, 15U, true);
|
|||||||
IRrecv irrecv(IR_RECEIVER_GPIO);
|
IRrecv irrecv(IR_RECEIVER_GPIO);
|
||||||
# endif
|
# endif
|
||||||
IRsend irsend(IR_EMITTER_GPIO, IR_EMITTER_INVERTED);
|
IRsend irsend(IR_EMITTER_GPIO, IR_EMITTER_INVERTED);
|
||||||
# else
|
|
||||||
# include <IRremote.h>
|
|
||||||
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
|
|
||||||
|
|
||||||
// IR protocol bits definition for Arduino (for ESP8266 they are defined in IRRemoteESP8266.h)
|
// IR protocol bits definition for Arduino (for ESP8266 they are defined in IRRemoteESP8266.h)
|
||||||
# ifndef NEC_BITS
|
# ifndef NEC_BITS
|
||||||
@@ -99,9 +93,7 @@ uint64_t getUInt64fromHex(char const* str) {
|
|||||||
|
|
||||||
void setupIR() {
|
void setupIR() {
|
||||||
//IR init parameters
|
//IR init parameters
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.begin();
|
irsend.begin();
|
||||||
# endif
|
|
||||||
|
|
||||||
irrecv.enableIRIn(); // Start the receiver
|
irrecv.enableIRIn(); // Start the receiver
|
||||||
|
|
||||||
@@ -125,35 +117,24 @@ void IRtoMQTT() {
|
|||||||
IRdata["value"] = (SIGNAL_SIZE_UL_ULL)(results.value);
|
IRdata["value"] = (SIGNAL_SIZE_UL_ULL)(results.value);
|
||||||
IRdata["protocol"] = (int)(results.decode_type);
|
IRdata["protocol"] = (int)(results.decode_type);
|
||||||
IRdata["bits"] = (int)(results.bits);
|
IRdata["bits"] = (int)(results.bits);
|
||||||
# if defined(ESP8266) || defined(ESP32) //resultToHexidecimal is only available with IRremoteESP8266
|
|
||||||
IRdata["hex"] = resultToHexidecimal(&results);
|
IRdata["hex"] = resultToHexidecimal(&results);
|
||||||
IRdata["protocol_name"] = typeToString(results.decode_type, false);
|
IRdata["protocol_name"] = typeToString(results.decode_type, false);
|
||||||
# endif
|
|
||||||
String rawCode = "";
|
String rawCode = "";
|
||||||
// Dump data
|
// Dump data
|
||||||
for (uint16_t i = 1; i < results.rawlen; i++) {
|
for (uint16_t i = 1; i < results.rawlen; i++) {
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
if (i % 100 == 0)
|
if (i % 100 == 0)
|
||||||
yield(); // Preemptive yield every 100th entry to feed the WDT.
|
yield(); // Preemptive yield every 100th entry to feed the WDT.
|
||||||
rawCode = rawCode + (results.rawbuf[i] * RAWTICK);
|
rawCode = rawCode + (results.rawbuf[i] * RAWTICK);
|
||||||
# else
|
|
||||||
rawCode = rawCode + (results.rawbuf[i] * USECPERTICK);
|
|
||||||
# endif
|
|
||||||
if (i < results.rawlen - 1)
|
if (i < results.rawlen - 1)
|
||||||
rawCode = rawCode + ","; // ',' not needed on last one
|
rawCode = rawCode + ","; // ',' not needed on last one
|
||||||
}
|
}
|
||||||
IRdata["raw"] = rawCode;
|
IRdata["raw"] = rawCode;
|
||||||
// if needed we directly resend the raw code
|
// if needed we directly resend the raw code
|
||||||
# ifdef RawDirectForward
|
# ifdef RawDirectForward
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
uint16_t rawsend[results.rawlen];
|
uint16_t rawsend[results.rawlen];
|
||||||
for (uint16_t i = 1; i < results.rawlen; i++) {
|
for (uint16_t i = 1; i < results.rawlen; i++) {
|
||||||
if (i % 100 == 0)
|
if (i % 100 == 0)
|
||||||
yield(); // Preemptive yield every 100th entry to feed the WDT.
|
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];
|
rawsend[i] = results.rawbuf[i];
|
||||||
}
|
}
|
||||||
irsend.sendRaw(rawsend, results.rawlen, RawFrequency);
|
irsend.sendRaw(rawsend, results.rawlen, RawFrequency);
|
||||||
@@ -233,11 +214,7 @@ void MQTTtoIR(char* topicOri, JsonObject& IRdata) {
|
|||||||
if (strcmp(protocol_name, "Raw") == 0) { // sending Raw data
|
if (strcmp(protocol_name, "Raw") == 0) { // sending Raw data
|
||||||
Log.trace(F("Raw" CR));
|
Log.trace(F("Raw" CR));
|
||||||
//buffer allocation from char datacallback
|
//buffer allocation from char datacallback
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
uint16_t Raw[count + 1];
|
uint16_t Raw[count + 1];
|
||||||
# else
|
|
||||||
unsigned int Raw[count + 1];
|
|
||||||
# endif
|
|
||||||
String value = "";
|
String value = "";
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < s; i++) {
|
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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = NEC_BITS;
|
valueBITS = NEC_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendNEC(data, valueBITS, valueRPT);
|
irsend.sendNEC(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendNEC(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
signalSent = true;
|
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
|
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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = WHYNTER_BITS;
|
valueBITS = WHYNTER_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendWhynter(data, valueBITS, valueRPT);
|
irsend.sendWhynter(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendWhynter(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# 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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = LG_BITS;
|
valueBITS = LG_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendLG(data, valueBITS, valueRPT);
|
irsend.sendLG(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendLG(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# ifdef IR_SONY
|
# ifdef IR_SONY
|
||||||
if (strcmp(protocol_name, "SONY") == 0) {
|
if (strcmp(protocol_name, "SONY") == 0) {
|
||||||
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = SONY_20_BITS;
|
valueBITS = SONY_20_BITS;
|
||||||
irsend.sendSony(data, valueBITS, valueRPT);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# 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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = DISH_BITS;
|
valueBITS = DISH_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendDISH(data, valueBITS, valueRPT);
|
irsend.sendDISH(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendDISH(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# 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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = RC5_BITS;
|
valueBITS = RC5_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendRC5(data, valueBITS, valueRPT);
|
irsend.sendRC5(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendRC5(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# 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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = RC6_MODE0_BITS;
|
valueBITS = RC6_MODE0_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendRC6(data, valueBITS, valueRPT);
|
irsend.sendRC6(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendRC6(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# 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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = SHARP_BITS;
|
valueBITS = SHARP_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendSharpRaw(data, valueBITS, valueRPT);
|
irsend.sendSharpRaw(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendSharpRaw(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# 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);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = SAMSUNG_BITS;
|
valueBITS = SAMSUNG_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendSAMSUNG(data, valueBITS, valueRPT);
|
irsend.sendSAMSUNG(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendSAMSUNG(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@@ -414,31 +344,20 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data,
|
|||||||
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = JVC_BITS;
|
valueBITS = JVC_BITS;
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
irsend.sendJVC(data, valueBITS, valueRPT);
|
irsend.sendJVC(data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendJVC(data, valueBITS);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# ifdef IR_PANASONIC
|
# ifdef IR_PANASONIC
|
||||||
if (strcmp(protocol_name, "PANASONIC") == 0) {
|
if (strcmp(protocol_name, "PANASONIC") == 0) {
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
Log.notice(F("Sending IR signal with %s" CR), protocol_name);
|
||||||
if (valueBITS == 0)
|
if (valueBITS == 0)
|
||||||
valueBITS = PANASONIC_BITS;
|
valueBITS = PANASONIC_BITS;
|
||||||
irsend.sendPanasonic(PanasonicAddress, data, valueBITS, valueRPT);
|
irsend.sendPanasonic(PanasonicAddress, data, valueBITS, valueRPT);
|
||||||
# else
|
|
||||||
for (int i = 0; i <= valueRPT; i++)
|
|
||||||
irsend.sendPanasonic(PanasonicAddress, data);
|
|
||||||
# endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
# ifdef IR_COOLIX
|
# ifdef IR_COOLIX
|
||||||
if (strcmp(protocol_name, "COOLIX") == 0) {
|
if (strcmp(protocol_name, "COOLIX") == 0) {
|
||||||
Log.trace(F("Sending %s:" CR), protocol_name);
|
Log.trace(F("Sending %s:" CR), protocol_name);
|
||||||
@@ -1394,6 +1313,5 @@ bool sendIdentifiedProtocol(const char* protocol_name, SIGNAL_SIZE_UL_ULL data,
|
|||||||
# endif
|
# endif
|
||||||
Log.warning(F("Unknown IR protocol" CR));
|
Log.warning(F("Unknown IR protocol" CR));
|
||||||
return false;
|
return false;
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -66,7 +66,6 @@ uint32_t gc_checksum() {
|
|||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
void eeprom_setup() {
|
void eeprom_setup() {
|
||||||
EEPROM.begin(4096);
|
EEPROM.begin(4096);
|
||||||
pGC = (struct _GLOBAL_CONFIG*)EEPROM.getDataPtr();
|
pGC = (struct _GLOBAL_CONFIG*)EEPROM.getDataPtr();
|
||||||
@@ -84,14 +83,11 @@ void eeprom_setup() {
|
|||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
RFM69 radio;
|
RFM69 radio;
|
||||||
|
|
||||||
void setupRFM69(void) {
|
void setupRFM69(void) {
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
eeprom_setup();
|
eeprom_setup();
|
||||||
# endif
|
|
||||||
int freq;
|
int freq;
|
||||||
static const char PROGMEM JSONtemplate[] =
|
static const char PROGMEM JSONtemplate[] =
|
||||||
R"({"msgType":"config","freq":%d,"rfm69hcw":%d,"netid":%d,"power":%d})";
|
R"({"msgType":"config","freq":%d,"rfm69hcw":%d,"netid":%d,"power":%d})";
|
||||||
|
|||||||
@@ -30,12 +30,7 @@
|
|||||||
WeatherStationDataRx wsdr(RF_WS_RECEIVER_GPIO, true);
|
WeatherStationDataRx wsdr(RF_WS_RECEIVER_GPIO, true);
|
||||||
|
|
||||||
void PairedDeviceAdded(byte newID) {
|
void PairedDeviceAdded(byte newID) {
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
Serial.printf("ZgatewayWeatherStation: New device paired %d\r\n", newID);
|
Serial.printf("ZgatewayWeatherStation: New device paired %d\r\n", newID);
|
||||||
# else
|
|
||||||
Serial.print("ZgatewayWeatherStation: New device paired ");
|
|
||||||
Serial.println(newID, DEC);
|
|
||||||
# endif
|
|
||||||
StaticJsonDocument<JSON_MSG_BUFFER> RFdataBuffer;
|
StaticJsonDocument<JSON_MSG_BUFFER> RFdataBuffer;
|
||||||
JsonObject RFdata = RFdataBuffer.to<JsonObject>();
|
JsonObject RFdata = RFdataBuffer.to<JsonObject>();
|
||||||
RFdata["sensor"] = newID;
|
RFdata["sensor"] = newID;
|
||||||
|
|||||||
@@ -480,7 +480,6 @@ void pubMqttDiscovery() {
|
|||||||
"", "", "", "", false, // device name, device manufacturer, device model, device ID, retain
|
"", "", "", "", false, // device name, device manufacturer, device model, device ID, retain
|
||||||
stateClassMeasurement //State Class
|
stateClassMeasurement //State Class
|
||||||
);
|
);
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Free memory", (char*)getUniqueId("freemem", "").c_str(), //set state_topic,name,uniqueId
|
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,
|
will_Topic, "data_size", "{{ value_json.freemem }}", //set availability_topic,device_class,value_template,
|
||||||
@@ -574,7 +573,6 @@ void pubMqttDiscovery() {
|
|||||||
stateClassNone //State Class
|
stateClassNone //State Class
|
||||||
);
|
);
|
||||||
# endif
|
# endif
|
||||||
# endif
|
|
||||||
# if defined(ESP32) && !defined(NO_INT_TEMP_READING)
|
# if defined(ESP32) && !defined(NO_INT_TEMP_READING)
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Internal temperature", (char*)getUniqueId("tempc", "").c_str(), //set state_topic,name,uniqueId
|
subjectSYStoMQTT, "SYS: Internal temperature", (char*)getUniqueId("tempc", "").c_str(), //set state_topic,name,uniqueId
|
||||||
|
|||||||
@@ -49,12 +49,8 @@
|
|||||||
BME280 mySensor;
|
BME280 mySensor;
|
||||||
|
|
||||||
void setupZsensorBME280() {
|
void setupZsensorBME280() {
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
// Allow custom pins on ESP Platforms
|
// Allow custom pins on ESP Platforms
|
||||||
Wire.begin(BME280_PIN_SDA, BME280_PIN_SCL);
|
Wire.begin(BME280_PIN_SDA, BME280_PIN_SCL);
|
||||||
# else
|
|
||||||
Wire.begin();
|
|
||||||
# endif
|
|
||||||
|
|
||||||
mySensor.settings.commInterface = I2C_MODE;
|
mySensor.settings.commInterface = I2C_MODE;
|
||||||
mySensor.settings.I2CAddress = BME280_i2c_addr;
|
mySensor.settings.I2CAddress = BME280_i2c_addr;
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ void MeasureGPIOInput() {
|
|||||||
if ((millis() - lastDebounceTime) > GPIOInputDebounceDelay) {
|
if ((millis() - lastDebounceTime) > GPIOInputDebounceDelay) {
|
||||||
// whatever the reading is at, it's been there for longer than the debounce
|
// whatever the reading is at, it's been there for longer than the debounce
|
||||||
// delay, so take it as the actual current state:
|
// delay, so take it as the actual current state:
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
yield();
|
yield();
|
||||||
# endif
|
|
||||||
# if defined(TRIGGER_GPIO) && INPUT_GPIO == TRIGGER_GPIO && !defined(ESPWifiManualSetup)
|
# if defined(TRIGGER_GPIO) && INPUT_GPIO == TRIGGER_GPIO && !defined(ESPWifiManualSetup)
|
||||||
if (reading == LOW) {
|
if (reading == LOW) {
|
||||||
if (resetTime == 0) {
|
if (resetTime == 0) {
|
||||||
|
|||||||
@@ -49,9 +49,7 @@ void MeasureGPIOKeyCode() {
|
|||||||
{
|
{
|
||||||
// whatever the reading is at, it's been there for longer than the debounce
|
// whatever the reading is at, it's been there for longer than the debounce
|
||||||
// delay, so take it as the actual current state:
|
// delay, so take it as the actual current state:
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
yield();
|
yield();
|
||||||
# endif
|
|
||||||
// if the Input state has changed:
|
// if the Input state has changed:
|
||||||
if (latch > 0 && lastLatchStateGPIOKeyCode != latch) {
|
if (latch > 0 && lastLatchStateGPIOKeyCode != latch) {
|
||||||
int reading = digitalRead(GPIOKeyCode_D0_GPIO) | (digitalRead(GPIOKeyCode_D1_GPIO) << 1) | (digitalRead(GPIOKeyCode_D2_GPIO) << 2);
|
int reading = digitalRead(GPIOKeyCode_D0_GPIO) | (digitalRead(GPIOKeyCode_D1_GPIO) << 1) | (digitalRead(GPIOKeyCode_D2_GPIO) << 2);
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ void MeasureHCSR501() {
|
|||||||
JsonObject HCSR501data = HCSR501dataBuffer.to<JsonObject>();
|
JsonObject HCSR501data = HCSR501dataBuffer.to<JsonObject>();
|
||||||
static int pirState = LOW;
|
static int pirState = LOW;
|
||||||
int PresenceValue = digitalRead(HCSR501_GPIO);
|
int PresenceValue = digitalRead(HCSR501_GPIO);
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
yield();
|
yield();
|
||||||
# endif
|
|
||||||
if (PresenceValue == HIGH) {
|
if (PresenceValue == HIGH) {
|
||||||
if (pirState == LOW) {
|
if (pirState == LOW) {
|
||||||
//turned on
|
//turned on
|
||||||
|
|||||||
+6
-82
@@ -245,7 +245,6 @@ int failure_number_mqtt = 0; // number of failure connecting to MQTT
|
|||||||
unsigned long timer_led_measures = 0;
|
unsigned long timer_led_measures = 0;
|
||||||
static void* eClient = nullptr;
|
static void* eClient = nullptr;
|
||||||
static unsigned long last_ota_activity_millis = 0;
|
static unsigned long last_ota_activity_millis = 0;
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
// Global struct to store live SYS configuration data
|
// Global struct to store live SYS configuration data
|
||||||
SYSConfig_s SYSConfig;
|
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 uint8_t mqtt_ss_index = MQTT_SECURE_SELF_SIGNED_INDEX_DEFAULT;
|
||||||
static String mqtt_cert = "";
|
static String mqtt_cert = "";
|
||||||
static String ota_server_cert = "";
|
static String ota_server_cert = "";
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
# include <ArduinoOTA.h>
|
# include <ArduinoOTA.h>
|
||||||
@@ -546,14 +544,11 @@ void pub(const char* topicori, const char* payload, bool retainFlag) {
|
|||||||
void pub(const char* topicori, JsonObject& data) {
|
void pub(const char* topicori, JsonObject& data) {
|
||||||
String dataAsString = "";
|
String dataAsString = "";
|
||||||
bool ret = sensor_Retain;
|
bool ret = sensor_Retain;
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
#if message_UTCtimestamp == true
|
#if message_UTCtimestamp == true
|
||||||
data["UTCtime"] = UTCtimestamp();
|
data["UTCtime"] = UTCtimestamp();
|
||||||
#endif
|
#endif
|
||||||
#if message_unixtimestamp == true
|
#if message_unixtimestamp == true
|
||||||
data["unixtime"] = unixtimestamp();
|
data["unixtime"] = unixtimestamp();
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
if (data.containsKey("retain") && data["retain"].is<bool>()) {
|
if (data.containsKey("retain") && data["retain"].is<bool>()) {
|
||||||
ret = data["retain"];
|
ret = data["retain"];
|
||||||
@@ -760,13 +755,10 @@ bool cmpToMainTopic(const char* topicOri, const char* toAdd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void delayWithOTA(long waitMillis) {
|
void delayWithOTA(long waitMillis) {
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
long waitStep = 100;
|
long waitStep = 100;
|
||||||
for (long waitedMillis = 0; waitedMillis < waitMillis; waitedMillis += waitStep) {
|
for (long waitedMillis = 0; waitedMillis < waitMillis; waitedMillis += waitStep) {
|
||||||
#ifndef ESPWifiManualSetup
|
#ifndef ESPWifiManualSetup
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
#if defined(ZwebUI) && defined(ESP32)
|
#if defined(ZwebUI) && defined(ESP32)
|
||||||
@@ -777,9 +769,6 @@ void delayWithOTA(long waitMillis) {
|
|||||||
#endif
|
#endif
|
||||||
delay(waitStep);
|
delay(waitStep);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
delay(waitMillis);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SYSConfig_init() {
|
void SYSConfig_init() {
|
||||||
@@ -831,9 +820,7 @@ void SYSConfig_load() {}
|
|||||||
|
|
||||||
void connectMQTT() {
|
void connectMQTT() {
|
||||||
#ifndef ESPWifiManualSetup
|
#ifndef ESPWifiManualSetup
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Log.warning(F("MQTT connection..." CR));
|
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
|
// ... We consider that OTA might be still active, and we sleep for a while, and giving
|
||||||
// OTA chance to proceed (ArduinoOTA.handle())
|
// OTA chance to proceed (ArduinoOTA.handle())
|
||||||
Log.warning(F("OTA might be still active (activity %d ms ago)" CR), millis_since_last_ota);
|
Log.warning(F("OTA might be still active (activity %d ms ago)" CR), millis_since_last_ota);
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
#endif
|
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
ESPRestart(1);
|
ESPRestart(1);
|
||||||
@@ -1035,7 +1020,6 @@ void setup() {
|
|||||||
SetupIndicatorInfo();
|
SetupIndicatorInfo();
|
||||||
SetupIndicators(); // For RGB Leds
|
SetupIndicators(); // For RGB Leds
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
# ifndef ZgatewaySRFB // if we are not in sonoff rf bridge case we apply the ESP8266 GPIO optimization
|
# ifndef ZgatewaySRFB // if we are not in sonoff rf bridge case we apply the ESP8266 GPIO optimization
|
||||||
Serial.end();
|
Serial.end();
|
||||||
@@ -1129,20 +1113,12 @@ void setup() {
|
|||||||
Log.trace(F("OpenMQTTGateway ip: %s" CR), WiFi.localIP().toString().c_str());
|
Log.trace(F("OpenMQTTGateway ip: %s" CR), WiFi.localIP().toString().c_str());
|
||||||
|
|
||||||
setOTA();
|
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)
|
#if defined(ZwebUI) && defined(ESP32)
|
||||||
WebUISetup();
|
WebUISetup();
|
||||||
modules.add(ZwebUI);
|
modules.add(ZwebUI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
if (mqtt_secure) {
|
if (mqtt_secure) {
|
||||||
eClient = new WiFiClientSecure;
|
eClient = new WiFiClientSecure;
|
||||||
if (mqtt_cert_validate) {
|
if (mqtt_cert_validate) {
|
||||||
@@ -1154,12 +1130,9 @@ void setup() {
|
|||||||
} else {
|
} else {
|
||||||
eClient = new WiFiClient;
|
eClient = new WiFiClient;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
eClient = new EthernetClient;
|
|
||||||
#endif
|
|
||||||
client.setClient(*(Client*)eClient);
|
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));
|
Log.trace(F("Connecting to MQTT by mDNS without MQTT hostname" CR));
|
||||||
connectMQTTmdns();
|
connectMQTTmdns();
|
||||||
#else
|
#else
|
||||||
@@ -1336,7 +1309,6 @@ void setup() {
|
|||||||
Log.notice(F("************** Setup OpenMQTTGateway end **************" CR));
|
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
|
// Bypass for ESP not reconnecting automaticaly the second time https://github.com/espressif/arduino-esp32/issues/2501
|
||||||
bool wifi_reconnect_bypass() {
|
bool wifi_reconnect_bypass() {
|
||||||
#if defined(ESP32) && defined(USE_BLUFI)
|
#if defined(ESP32) && defined(USE_BLUFI)
|
||||||
@@ -1355,7 +1327,7 @@ bool wifi_reconnect_bypass() {
|
|||||||
Log.notice(F("Attempting Wifi connection with saved AP: %d" CR), wifi_autoreconnect_cnt);
|
Log.notice(F("Attempting Wifi connection with saved AP: %d" CR), wifi_autoreconnect_cnt);
|
||||||
|
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
# if (defined(ESP8266) || defined(ESP32)) && (defined(WifiGMode) || defined(WifiPower))
|
#if defined(WifiGMode) || defined(WifiPower)
|
||||||
setESPWifiProtocolTxPower();
|
setESPWifiProtocolTxPower();
|
||||||
#endif
|
#endif
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@@ -1478,11 +1450,6 @@ void setupTLS(bool self_signed, uint8_t index) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
bool wifi_reconnect_bypass() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reboot for Reason Codes
|
Reboot for Reason Codes
|
||||||
@@ -1495,7 +1462,6 @@ bool wifi_reconnect_bypass() {
|
|||||||
7 - Parameters changed
|
7 - Parameters changed
|
||||||
8 - not enough memory to pursue
|
8 - not enough memory to pursue
|
||||||
*/
|
*/
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
void ESPRestart(byte reason) {
|
void ESPRestart(byte reason) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
StaticJsonDocument<128> jsonBuffer;
|
StaticJsonDocument<128> jsonBuffer;
|
||||||
@@ -1511,9 +1477,6 @@ void ESPRestart(byte reason) {
|
|||||||
ESP.reset();
|
ESP.reset();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void ESPRestart(byte reason) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ESPWifiManualSetup)
|
#if defined(ESPWifiManualSetup)
|
||||||
void setup_wifi() {
|
void setup_wifi() {
|
||||||
@@ -1568,7 +1531,7 @@ void setup_wifi() {
|
|||||||
displayPrint("Wifi connected");
|
displayPrint("Wifi connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(ESP8266) || defined(ESP32)
|
#else
|
||||||
|
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
|
|
||||||
@@ -1983,33 +1946,9 @@ void WiFiEvent(WiFiEvent_t event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# 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
|
#endif
|
||||||
|
|
||||||
#if defined(MDNS_SD) && (defined(ESP8266) || defined(ESP32))
|
#if defined(MDNS_SD)
|
||||||
void connectMQTTmdns() {
|
void connectMQTTmdns() {
|
||||||
Log.trace(F("Browsing for MQTT service" CR));
|
Log.trace(F("Browsing for MQTT service" CR));
|
||||||
int n = MDNS.queryService("mqtt", "tcp");
|
int n = MDNS.queryService("mqtt", "tcp");
|
||||||
@@ -2033,10 +1972,8 @@ void connectMQTTmdns() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
#ifndef ESPWifiManualSetup
|
#ifndef ESPWifiManualSetup
|
||||||
# if defined(ESP8266) || defined(ESP32)
|
|
||||||
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
//esp_task_wdt_reset();
|
//esp_task_wdt_reset();
|
||||||
@@ -2051,15 +1988,11 @@ void loop() {
|
|||||||
SendReceiveIndicatorOFF();
|
SendReceiveIndicatorOFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
if (ethConnected || WiFi.status() == WL_CONNECTED) {
|
if (ethConnected || WiFi.status() == WL_CONNECTED) {
|
||||||
if (ethConnected && WiFi.status() == WL_CONNECTED) {
|
if (ethConnected && WiFi.status() == WL_CONNECTED) {
|
||||||
WiFi.disconnect(); // we disconnect the wifi as we are connected to ethernet
|
WiFi.disconnect(); // we disconnect the wifi as we are connected to ethernet
|
||||||
}
|
}
|
||||||
ArduinoOTA.handle();
|
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;
|
failure_number_ntwk = 0;
|
||||||
#if defined(ZwebUI) && defined(ESP32)
|
#if defined(ZwebUI) && defined(ESP32)
|
||||||
WebUILoop();
|
WebUILoop();
|
||||||
@@ -2105,10 +2038,8 @@ void loop() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (now > (timer_sys_checks + (TimeBetweenCheckingSYS * 1000)) || !timer_sys_checks) {
|
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();
|
syncNTP();
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
if (!timer_sys_checks) { // Update check at start up only
|
if (!timer_sys_checks) { // Update check at start up only
|
||||||
#if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
|
#if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
|
||||||
@@ -2324,7 +2255,6 @@ float intTemperatureRead() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
void syncNTP() {
|
void syncNTP() {
|
||||||
configTime(0, 0, NTP_SERVER);
|
configTime(0, 0, NTP_SERVER);
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
@@ -2373,8 +2303,6 @@ void eraseAndRestart() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
String stateMeasures() {
|
String stateMeasures() {
|
||||||
StaticJsonDocument<JSON_MSG_BUFFER> SYSdata;
|
StaticJsonDocument<JSON_MSG_BUFFER> SYSdata;
|
||||||
|
|
||||||
@@ -2388,7 +2316,6 @@ String stateMeasures() {
|
|||||||
SYSdata["disc"] = SYSConfig.discovery;
|
SYSdata["disc"] = SYSConfig.discovery;
|
||||||
SYSdata["ohdisc"] = SYSConfig.ohdiscovery;
|
SYSdata["ohdisc"] = SYSConfig.ohdiscovery;
|
||||||
#endif
|
#endif
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
SYSdata["env"] = ENV_NAME;
|
SYSdata["env"] = ENV_NAME;
|
||||||
uint32_t freeMem;
|
uint32_t freeMem;
|
||||||
uint32_t minFreeMem;
|
uint32_t minFreeMem;
|
||||||
@@ -2431,7 +2358,6 @@ String stateMeasures() {
|
|||||||
SYSdata["mac"] = (char*)WiFi.macAddress().c_str();
|
SYSdata["mac"] = (char*)WiFi.macAddress().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef ZgatewayBT
|
#ifdef ZgatewayBT
|
||||||
# ifdef ESP32
|
# ifdef ESP32
|
||||||
SYSdata["lowpowermode"] = (int)lowpowermode;
|
SYSdata["lowpowermode"] = (int)lowpowermode;
|
||||||
@@ -2860,7 +2786,6 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
|||||||
if (cmpToMainTopic(topicOri, subjectMQTTtoSYSset)) {
|
if (cmpToMainTopic(topicOri, subjectMQTTtoSYSset)) {
|
||||||
bool restartESP = false;
|
bool restartESP = false;
|
||||||
Log.trace(F("MQTTtoSYS json" CR));
|
Log.trace(F("MQTTtoSYS json" CR));
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
|
||||||
if (SYSdata.containsKey("cmd")) {
|
if (SYSdata.containsKey("cmd")) {
|
||||||
const char* cmd = SYSdata["cmd"];
|
const char* cmd = SYSdata["cmd"];
|
||||||
Log.notice(F("Command: %s" CR), cmd);
|
Log.notice(F("Command: %s" CR), cmd);
|
||||||
@@ -2911,7 +2836,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
|||||||
|
|
||||||
Log.warning(F("Attempting connection to new AP %s" CR), (const char*)SYSdata["wifi_ssid"]);
|
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"]);
|
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();
|
setESPWifiProtocolTxPower();
|
||||||
#endif
|
#endif
|
||||||
WiFi.waitForConnectResult(WiFi_TimeOut * 1000);
|
WiFi.waitForConnectResult(WiFi_TimeOut * 1000);
|
||||||
@@ -2920,7 +2845,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
|||||||
Log.error(F("Failed to connect to new AP; falling back" CR));
|
Log.error(F("Failed to connect to new AP; falling back" CR));
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
WiFi.begin(prev_ssid.c_str(), prev_pass.c_str());
|
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();
|
setESPWifiProtocolTxPower();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -3050,7 +2975,6 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
|||||||
if (disconnectClient) {
|
if (disconnectClient) {
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ZmqttDiscovery
|
#ifdef ZmqttDiscovery
|
||||||
if (SYSdata.containsKey("disc")) {
|
if (SYSdata.containsKey("disc")) {
|
||||||
|
|||||||
Reference in new issue
Block a user