mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
Sync to Tasmota
Sync to Tasmota
This commit is contained in:
commit
16d8b8df4e
@ -740,6 +740,8 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CMND_GPIOS == command_code) {
|
else if (CMND_GPIOS == command_code) {
|
||||||
|
mytmplt cmodule;
|
||||||
|
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||||
for (byte i = 0; i < GPIO_SENSOR_END; i++) {
|
for (byte i = 0; i < GPIO_SENSOR_END; i++) {
|
||||||
if (!jsflg) {
|
if (!jsflg) {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_GPIOS "%d\":["), lines);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_GPIOS "%d\":["), lines);
|
||||||
@ -747,12 +749,14 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
|||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,"), mqtt_data);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,"), mqtt_data);
|
||||||
}
|
}
|
||||||
jsflg = 1;
|
jsflg = 1;
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"%d (%s)\""), mqtt_data, i, GetTextIndexed(stemp1, sizeof(stemp1), i, kSensorNames));
|
if (!GetUsedInModule(i, cmodule.gp.io)) {
|
||||||
if ((strlen(mqtt_data) > (LOGSZ - TOPSZ)) || (i == GPIO_SENSOR_END -1)) {
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"%d (%s)\""), mqtt_data, i, GetTextIndexed(stemp1, sizeof(stemp1), i, kSensorNames));
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s]}"), mqtt_data);
|
if ((strlen(mqtt_data) > (LOGSZ - TOPSZ)) || (i == GPIO_SENSOR_END -1)) {
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, type);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s]}"), mqtt_data);
|
||||||
jsflg = 0;
|
MqttPublishPrefixTopic_P(RESULT_OR_STAT, type);
|
||||||
lines++;
|
jsflg = 0;
|
||||||
|
lines++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mqtt_data[0] = '\0';
|
mqtt_data[0] = '\0';
|
||||||
@ -1000,7 +1004,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
|||||||
break;
|
break;
|
||||||
case 99:
|
case 99:
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
||||||
ESP.restart();
|
EspRestart();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_ONE_TO_RESTART);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_ONE_TO_RESTART);
|
||||||
@ -1937,7 +1941,7 @@ void StateLoop()
|
|||||||
restart_flag--;
|
restart_flag--;
|
||||||
if (restart_flag <= 0) {
|
if (restart_flag <= 0) {
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
||||||
ESP.restart();
|
EspRestart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2012,8 +2016,7 @@ void ArduinoOTAInit()
|
|||||||
}
|
}
|
||||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str);
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLog(LOG_LEVEL_INFO);
|
||||||
delay(100); // Allow time for message xfer
|
EspRestart();
|
||||||
ESP.restart();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ArduinoOTA.onEnd([]()
|
ArduinoOTA.onEnd([]()
|
||||||
@ -2021,8 +2024,7 @@ void ArduinoOTAInit()
|
|||||||
if ((LOG_LEVEL_DEBUG <= seriallog_level)) Serial.println();
|
if ((LOG_LEVEL_DEBUG <= seriallog_level)) Serial.println();
|
||||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING));
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING));
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLog(LOG_LEVEL_INFO);
|
||||||
delay(100); // Allow time for message xfer
|
EspRestart();
|
||||||
ESP.restart();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
|
@ -671,7 +671,7 @@ void ShowSource(int source)
|
|||||||
|
|
||||||
void GetFeatures()
|
void GetFeatures()
|
||||||
{
|
{
|
||||||
feature_drv1 = 0x00000000; // xdrv_00_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino
|
feature_drv1 = 0x00000000; // xdrv_01_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino
|
||||||
|
|
||||||
// feature_drv1 |= 0x00000001;
|
// feature_drv1 |= 0x00000001;
|
||||||
// feature_drv1 |= 0x00000002;
|
// feature_drv1 |= 0x00000002;
|
||||||
@ -1033,6 +1033,7 @@ void WifiBegin(uint8_t flag)
|
|||||||
WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186
|
WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WiFi.persistent(false); // Solve possible wifi init errors
|
||||||
WiFi.disconnect(true); // Delete SDK wifi config
|
WiFi.disconnect(true); // Delete SDK wifi config
|
||||||
delay(200);
|
delay(200);
|
||||||
WiFi.mode(WIFI_STA); // Disable AP mode
|
WiFi.mode(WIFI_STA); // Disable AP mode
|
||||||
@ -1246,13 +1247,30 @@ int WifiState()
|
|||||||
|
|
||||||
void WifiConnect()
|
void WifiConnect()
|
||||||
{
|
{
|
||||||
WiFi.persistent(false); // Solve possible wifi init errors
|
WiFi.persistent(false); // Solve possible wifi init errors
|
||||||
wifi_status = 0;
|
wifi_status = 0;
|
||||||
wifi_retry_init = WIFI_RETRY_OFFSET_SEC + ((ESP.getChipId() & 0xF) * 2);
|
wifi_retry_init = WIFI_RETRY_OFFSET_SEC + ((ESP.getChipId() & 0xF) * 2);
|
||||||
wifi_retry = wifi_retry_init;
|
wifi_retry = wifi_retry_init;
|
||||||
wifi_counter = 1;
|
wifi_counter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WifiDisconnect()
|
||||||
|
{
|
||||||
|
// Courtesy of EspEasy
|
||||||
|
WiFi.persistent(true); // use SDK storage of SSID/WPA parameters
|
||||||
|
ETS_UART_INTR_DISABLE();
|
||||||
|
wifi_station_disconnect(); // this will store empty ssid/wpa into sdk storage
|
||||||
|
ETS_UART_INTR_ENABLE();
|
||||||
|
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
void EspRestart()
|
||||||
|
{
|
||||||
|
delay(100); // Allow time for message xfer
|
||||||
|
WifiDisconnect();
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_DISCOVERY
|
#ifdef USE_DISCOVERY
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* mDNS
|
* mDNS
|
||||||
|
@ -181,7 +181,7 @@
|
|||||||
* - Disable a feature by preceding it with //
|
* - Disable a feature by preceding it with //
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
//#define USE_ARDUINO_OTA // Add optional support for Arduino OTA (+4k5 code)
|
//#define USE_ARDUINO_OTA // Add optional support for Arduino OTA (+13k code)
|
||||||
|
|
||||||
// -- Localization --------------------------------
|
// -- Localization --------------------------------
|
||||||
// If non selected the default en-GB will be used
|
// If non selected the default en-GB will be used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user