mirror of https://github.com/arendst/Tasmota.git
Change wifi connection check
Change wifi connection check
This commit is contained in:
parent
14a7424e9b
commit
99ae0c9cab
|
@ -2167,7 +2167,7 @@ void Every250mSeconds()
|
|||
wifi_state_flag = WIFI_RESTART;
|
||||
break;
|
||||
case 3: // Every x.75 second
|
||||
if (WL_CONNECTED == WiFi.status()) { MqttCheck(); }
|
||||
if (!global_state.wifi_down) { MqttCheck(); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1630,9 +1630,7 @@ int WifiState()
|
|||
{
|
||||
int state = -1;
|
||||
|
||||
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
||||
state = WIFI_RESTART;
|
||||
}
|
||||
if (!global_state.wifi_down) { state = WIFI_RESTART; }
|
||||
if (wifi_config_type) { state = wifi_config_type; }
|
||||
return state;
|
||||
}
|
||||
|
@ -2209,7 +2207,7 @@ void RtcSecond()
|
|||
|
||||
if ((ntp_sync_minute > 59) && (RtcTime.minute > 2)) ntp_sync_minute = 1; // If sync prepare for a new cycle
|
||||
uint8_t offset = (uptime < 30) ? RtcTime.second : (((ESP.getChipId() & 0xF) * 3) + 3) ; // First try ASAP to sync. If fails try once every 60 seconds based on chip id
|
||||
if ((WL_CONNECTED == WiFi.status()) && (offset == RtcTime.second) && ((RtcTime.year < 2016) || (ntp_sync_minute == RtcTime.minute) || ntp_force_sync)) {
|
||||
if (!global_state.wifi_down && (offset == RtcTime.second) && ((RtcTime.year < 2016) || (ntp_sync_minute == RtcTime.minute) || ntp_force_sync)) {
|
||||
ntp_time = sntp_get_current_timestamp();
|
||||
if (ntp_time > 1451602800) { // Fix NTP bug in core 2.4.1/SDK 2.2.1 (returns Thu Jan 01 08:00:10 1970 after power on)
|
||||
ntp_force_sync = 0;
|
||||
|
@ -2452,9 +2450,7 @@ void AddLog(byte loglevel)
|
|||
if (!web_log_index) web_log_index++; // Index 0 is not allowed as it is the end of char string
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
if ((WL_CONNECTED == WiFi.status()) && (loglevel <= syslog_level)) {
|
||||
Syslog();
|
||||
}
|
||||
if (!global_state.wifi_down && (loglevel <= syslog_level)) { Syslog(); }
|
||||
}
|
||||
|
||||
void AddLog_P(byte loglevel, const char *formatP)
|
||||
|
|
|
@ -397,7 +397,7 @@ void StopWebserver()
|
|||
void WifiManagerBegin()
|
||||
{
|
||||
// setup AP
|
||||
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
||||
if (!global_state.wifi_down) {
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION));
|
||||
} else {
|
||||
|
|
|
@ -638,7 +638,7 @@ void DisplayLogBufferInit()
|
|||
DisplayLogBufferAdd(buffer);
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_MAC " %s"), WiFi.macAddress().c_str());
|
||||
DisplayLogBufferAdd(buffer);
|
||||
if (!global_state.wifi_down && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
||||
if (!global_state.wifi_down) {
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("IP %s"), WiFi.localIP().toString().c_str());
|
||||
DisplayLogBufferAdd(buffer);
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_RSSI " %d%%"), WifiGetRssiAsQuality(WiFi.RSSI()));
|
||||
|
@ -663,7 +663,8 @@ enum SensorQuantity {
|
|||
JSON_CURRENT,
|
||||
JSON_VOLTAGE,
|
||||
JSON_POWERUSAGE,
|
||||
JSON_CO2 };
|
||||
JSON_CO2,
|
||||
JSON_FREQUENCY };
|
||||
const char kSensorQuantity[] PROGMEM =
|
||||
D_JSON_TEMPERATURE "|" // degrees
|
||||
D_JSON_HUMIDITY "|" D_JSON_LIGHT "|" D_JSON_NOISE "|" D_JSON_AIRQUALITY "|" // percentage
|
||||
|
@ -676,7 +677,8 @@ const char kSensorQuantity[] PROGMEM =
|
|||
D_JSON_CURRENT "|" // Ampere
|
||||
D_JSON_VOLTAGE "|" // Volt
|
||||
D_JSON_POWERUSAGE "|" // Watt
|
||||
D_JSON_CO2 ; // ppm
|
||||
D_JSON_CO2 "|" // ppm
|
||||
D_JSON_FREQUENCY ; // Hz
|
||||
|
||||
void DisplayJsonValue(const char *topic, const char* device, const char* mkey, const char* value)
|
||||
{
|
||||
|
@ -732,6 +734,9 @@ void DisplayJsonValue(const char *topic, const char* device, const char* mkey, c
|
|||
else if (JSON_CO2 == quantity_code) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s" D_UNIT_PARTS_PER_MILLION), value);
|
||||
}
|
||||
else if (JSON_FREQUENCY == quantity_code) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s" D_UNIT_HERTZ), value);
|
||||
}
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("%s %s"), source, svalue);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer);
|
||||
|
|
Loading…
Reference in New Issue