mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Refactor MQTT and webserver
This commit is contained in:
parent
17c94a2b62
commit
c580a9c387
@ -2590,7 +2590,7 @@ uint8_t BUploadInit(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BUploadWriteBuffer(uint8_t *buf, size_t size) {
|
uint32_t BUploadWriteBuffer(uint8_t *buf, size_t size) {
|
||||||
if (0 == BUpload.spi_sector_cursor) { // Starting a new sector write so we need to erase it first
|
if (0 == BUpload.spi_sector_cursor) { // Starting a new sector write so we need to erase it first
|
||||||
ESP.flashEraseSector(BUpload.spi_sector_counter);
|
ESP.flashEraseSector(BUpload.spi_sector_counter);
|
||||||
}
|
}
|
||||||
@ -2600,7 +2600,11 @@ void BUploadWriteBuffer(uint8_t *buf, size_t size) {
|
|||||||
if (2 == BUpload.spi_sector_cursor) { // The web upload sends 2048 bytes at a time so keep track of the cursor position to reset it for the next flash sector erase
|
if (2 == BUpload.spi_sector_cursor) { // The web upload sends 2048 bytes at a time so keep track of the cursor position to reset it for the next flash sector erase
|
||||||
BUpload.spi_sector_cursor = 0;
|
BUpload.spi_sector_cursor = 0;
|
||||||
BUpload.spi_sector_counter++;
|
BUpload.spi_sector_counter++;
|
||||||
|
if (BUpload.spi_sector_counter > (SPIFFS_END -2)) {
|
||||||
|
return 9; // File too large - Not enough free space
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE
|
#endif // USE_TASMOTA_CLIENT or SHELLY_FW_UPGRADE
|
||||||
@ -2918,7 +2922,8 @@ void HandleUploadLoop(void)
|
|||||||
#ifdef SHELLY_FW_UPGRADE
|
#ifdef SHELLY_FW_UPGRADE
|
||||||
else if (UPL_SHD == Web.upload_file_type) {
|
else if (UPL_SHD == Web.upload_file_type) {
|
||||||
// Write a block
|
// Write a block
|
||||||
BUploadWriteBuffer(upload.buf, upload.currentSize);
|
Web.upload_error = BUploadWriteBuffer(upload.buf, upload.currentSize);
|
||||||
|
if (Web.upload_error != 0) { return; }
|
||||||
}
|
}
|
||||||
#endif // SHELLY_FW_UPGRADE
|
#endif // SHELLY_FW_UPGRADE
|
||||||
#ifdef USE_TASMOTA_CLIENT
|
#ifdef USE_TASMOTA_CLIENT
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#define XDRV_02 2
|
#define XDRV_02 2
|
||||||
|
|
||||||
|
#ifndef MQTT_WIFI_CLIENT_TIMEOUT
|
||||||
|
#define MQTT_WIFI_CLIENT_TIMEOUT 200 // Wifi TCP connection timeout (default is 5000 mSec)
|
||||||
|
#endif
|
||||||
|
|
||||||
// #define DEBUG_DUMP_TLS // allow dumping of TLS Flash keys
|
// #define DEBUG_DUMP_TLS // allow dumping of TLS Flash keys
|
||||||
|
|
||||||
#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
@ -635,7 +639,7 @@ void MqttReconnect(void)
|
|||||||
Response_P(S_LWT_OFFLINE);
|
Response_P(S_LWT_OFFLINE);
|
||||||
|
|
||||||
if (MqttClient.connected()) { MqttClient.disconnect(); }
|
if (MqttClient.connected()) { MqttClient.disconnect(); }
|
||||||
EspClient.setTimeout(200);
|
EspClient.setTimeout(MQTT_WIFI_CLIENT_TIMEOUT);
|
||||||
#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
if (Mqtt.mqtt_tls) {
|
if (Mqtt.mqtt_tls) {
|
||||||
tlsClient->stop();
|
tlsClient->stop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user