mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-25 23:37:16 +00:00
Tune support for MQTT Settings save/restore
This commit is contained in:
parent
22b95e64c1
commit
c70ad4101f
@ -1417,10 +1417,14 @@ void CmndStateRetain(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CmndFileUpload(void) {
|
void CmndFileUpload(void) {
|
||||||
// FileUpload 0 - Abort current upload
|
/*
|
||||||
// FileUpload {"File":"Config_wemos10_9.4.0.3.dmp","Id":1620385091,"Type":2,"Size":4096,"Md5":"496fcbb433bbca89833063174d2c5747"}
|
Upload (binary) max 700 bytes chunks of data base64 encoded with MD5 hash over base64 decoded data
|
||||||
// FileUpload {"Id":1620385091,"Data":"CRJcTQ9fYGF ... OT1BRUlNUVVZXWFk="}
|
FileUpload 0 - Abort current upload
|
||||||
|
FileUpload {"File":"Config_wemos10_9.4.0.3.dmp","Id":1620385091,"Type":2,"Size":4096}
|
||||||
|
FileUpload {"Id":1620385091,"Data":"CRJcTQ9fYGF ... OT1BRUlNUVVZXWFk="}
|
||||||
|
FileUpload {"Id":1620385091,"Data":" ... "}
|
||||||
|
FileUpload {"Id":1620385091,"Md5":"496fcbb433bbca89833063174d2c5747"}
|
||||||
|
*/
|
||||||
const char* base64_data = nullptr;
|
const char* base64_data = nullptr;
|
||||||
uint32_t rcv_id = 0;
|
uint32_t rcv_id = 0;
|
||||||
|
|
||||||
@ -1476,7 +1480,7 @@ void CmndFileUpload(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Mqtt.file_buffer) {
|
if (Mqtt.file_buffer) {
|
||||||
if (base64_data) {
|
if ((Mqtt.file_pos < Mqtt.file_size) && base64_data) {
|
||||||
// Save upload into buffer - Handle possible buffer overflows
|
// Save upload into buffer - Handle possible buffer overflows
|
||||||
uint32_t rcvd_bytes = decode_base64_length((unsigned char*)base64_data);
|
uint32_t rcvd_bytes = decode_base64_length((unsigned char*)base64_data);
|
||||||
unsigned char decode_output[rcvd_bytes];
|
unsigned char decode_output[rcvd_bytes];
|
||||||
@ -1491,7 +1495,7 @@ void CmndFileUpload(void) {
|
|||||||
Mqtt.file_pos += read_bytes;
|
Mqtt.file_pos += read_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mqtt.file_pos < Mqtt.file_size) {
|
if ((Mqtt.file_pos < Mqtt.file_size) || (Mqtt.file_md5.length() != 32)) {
|
||||||
ResponseCmndChar(PSTR(D_JSON_ACK));
|
ResponseCmndChar(PSTR(D_JSON_ACK));
|
||||||
} else {
|
} else {
|
||||||
Mqtt.md5.calculate();
|
Mqtt.md5.calculate();
|
||||||
@ -1519,16 +1523,20 @@ void CmndFileUpload(void) {
|
|||||||
Mqtt.file_id = 0;
|
Mqtt.file_id = 0;
|
||||||
Mqtt.file_size = 0;
|
Mqtt.file_size = 0;
|
||||||
Mqtt.file_type = 0;
|
Mqtt.file_type = 0;
|
||||||
|
Mqtt.file_md5 = (const char*) nullptr; // Force deallocation of the String internal memory
|
||||||
}
|
}
|
||||||
MqttPublishPrefixTopic_P(STAT, XdrvMailbox.command); // Enforce stat/wemos10/FILEUPLOAD
|
MqttPublishPrefixTopic_P(STAT, XdrvMailbox.command); // Enforce stat/wemos10/FILEUPLOAD
|
||||||
ResponseClear();
|
ResponseClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndFileDownload(void) {
|
void CmndFileDownload(void) {
|
||||||
// Filedownload 0 - Abort current download
|
/*
|
||||||
// FileDownload 2 - Start download of settings file
|
Download (binary) max 700 bytes chunks of data base64 encoded with MD5 hash over base64 decoded data
|
||||||
// FileDownload - Continue downloading data
|
Currently supports Settings (file type 2)
|
||||||
|
Filedownload 0 - Abort current download
|
||||||
|
FileDownload 2 - Start download of settings file
|
||||||
|
FileDownload - Continue downloading data until reception of MD5 hash
|
||||||
|
*/
|
||||||
if (Mqtt.file_id && Mqtt.file_buffer) {
|
if (Mqtt.file_id && Mqtt.file_buffer) {
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user