Add HostedMCU file update using command HostedLoad <version>|<filename>
- Increased filesystem file name size from 48 to 50 characters
This commit is contained in:
parent
affb7ce8a4
commit
02d53557c4
@ -8,12 +8,14 @@ All notable changes to this project will be documented in this file.
|
|||||||
- TLS enabled ECDSA by default for ESP8266 (#24009)
|
- TLS enabled ECDSA by default for ESP8266 (#24009)
|
||||||
- Berry `cb.free_cb` for extension manager (#24014)
|
- Berry `cb.free_cb` for extension manager (#24014)
|
||||||
- Berry `light.get()` direct access to values (#24033)
|
- Berry `light.get()` direct access to values (#24033)
|
||||||
|
- HostedMCU file update using command `HostedLoad <version>|<filename>`
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Refactored library UDisplay (#24007)
|
- Refactored library UDisplay (#24007)
|
||||||
- LVGL library from v9.3.0 to v9.4.0 (#24028)
|
- LVGL library from v9.3.0 to v9.4.0 (#24028)
|
||||||
|
- Increased filesystem file name size from 48 to 50 characters
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- TLS fix ECDSA and add `SetOption165 1` to enable ECDSA in addition to RSA (#24000)
|
- TLS fix ECDSA and add `SetOption165 1` to enable ECDSA in addition to RSA (#24000)
|
||||||
|
|||||||
@ -114,6 +114,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||||||
|
|
||||||
## Changelog v15.1.0.1
|
## Changelog v15.1.0.1
|
||||||
### Added
|
### Added
|
||||||
|
- HostedMCU file update using command `HostedLoad <version>|<filename>`
|
||||||
- TLS enabled ECDSA by default for ESP8266 [#24009](https://github.com/arendst/Tasmota/issues/24009)
|
- TLS enabled ECDSA by default for ESP8266 [#24009](https://github.com/arendst/Tasmota/issues/24009)
|
||||||
- Berry `cb.free_cb` for extension manager [#24014](https://github.com/arendst/Tasmota/issues/24014)
|
- Berry `cb.free_cb` for extension manager [#24014](https://github.com/arendst/Tasmota/issues/24014)
|
||||||
- Berry `light.get()` direct access to values [#24033](https://github.com/arendst/Tasmota/issues/24033)
|
- Berry `light.get()` direct access to values [#24033](https://github.com/arendst/Tasmota/issues/24033)
|
||||||
@ -123,6 +124,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||||||
### Changed
|
### Changed
|
||||||
- LVGL library from v9.3.0 to v9.4.0 [#24028](https://github.com/arendst/Tasmota/issues/24028)
|
- LVGL library from v9.3.0 to v9.4.0 [#24028](https://github.com/arendst/Tasmota/issues/24028)
|
||||||
- Refactored library UDisplay [#24007](https://github.com/arendst/Tasmota/issues/24007)
|
- Refactored library UDisplay [#24007](https://github.com/arendst/Tasmota/issues/24007)
|
||||||
|
- Increased filesystem file name size from 48 to 50 characters
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- InfluxDb receives IPAddress as a value regression from v15.0.1.3 [#24031](https://github.com/arendst/Tasmota/issues/24031)
|
- InfluxDb receives IPAddress as a value regression from v15.0.1.3 [#24031](https://github.com/arendst/Tasmota/issues/24031)
|
||||||
|
|||||||
@ -334,6 +334,7 @@
|
|||||||
#define D_JSON_ONE_OR_GT "1 or >%s to upgrade"
|
#define D_JSON_ONE_OR_GT "1 or >%s to upgrade"
|
||||||
#define D_CMND_OTAURL "OtaUrl"
|
#define D_CMND_OTAURL "OtaUrl"
|
||||||
#define D_CMND_HOSTEDOTA "HostedOta"
|
#define D_CMND_HOSTEDOTA "HostedOta"
|
||||||
|
#define D_CMND_HOSTEDLOAD "HostedLoad"
|
||||||
#define D_CMND_SERIALLOG "SerialLog"
|
#define D_CMND_SERIALLOG "SerialLog"
|
||||||
#define D_CMND_SYSLOG "SysLog"
|
#define D_CMND_SYSLOG "SysLog"
|
||||||
#define D_CMND_FILELOG "FileLog"
|
#define D_CMND_FILELOG "FileLog"
|
||||||
|
|||||||
@ -87,6 +87,8 @@ ftp start stop ftp server: 0 = OFF, 1 = SDC, 2 = FlashFile
|
|||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const int UFS_FILENAME_SIZE = 50;
|
||||||
|
|
||||||
// Global file system pointer
|
// Global file system pointer
|
||||||
FS *ufsp;
|
FS *ufsp;
|
||||||
// Flash file system pointer
|
// Flash file system pointer
|
||||||
@ -94,7 +96,7 @@ FS *ffsp;
|
|||||||
// Local pointer for file managment
|
// Local pointer for file managment
|
||||||
FS *dfsp;
|
FS *dfsp;
|
||||||
|
|
||||||
char ufs_path[48];
|
char ufs_path[UFS_FILENAME_SIZE];
|
||||||
File ufs_upload_file;
|
File ufs_upload_file;
|
||||||
uint8_t ufs_dir;
|
uint8_t ufs_dir;
|
||||||
// 0 = None, 1 = SD, 2 = ffat, 3 = littlefs
|
// 0 = None, 1 = SD, 2 = ffat, 3 = littlefs
|
||||||
@ -104,7 +106,7 @@ uint8_t ffs_type;
|
|||||||
uint8_t sd_type;
|
uint8_t sd_type;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char run_file[48];
|
char run_file[UFS_FILENAME_SIZE];
|
||||||
int run_file_pos = -1;
|
int run_file_pos = -1;
|
||||||
bool run_file_mutex = 0;
|
bool run_file_mutex = 0;
|
||||||
bool download_busy;
|
bool download_busy;
|
||||||
@ -916,8 +918,6 @@ String UfsJsonSettingsRead(const char* key) {
|
|||||||
* Commands
|
* Commands
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
const int UFS_FILENAME_SIZE = 48;
|
|
||||||
|
|
||||||
char* UfsFilename(char* fname, char* fname_in) {
|
char* UfsFilename(char* fname, char* fname_in) {
|
||||||
fname_in = Trim(fname_in); // Remove possible leading spaces
|
fname_in = Trim(fname_in); // Remove possible leading spaces
|
||||||
snprintf_P(fname, UFS_FILENAME_SIZE, PSTR("%s%s"), ('/' == fname_in[0]) ? "" : "/", fname_in);
|
snprintf_P(fname, UFS_FILENAME_SIZE, PSTR("%s%s"), ('/' == fname_in[0]) ? "" : "/", fname_in);
|
||||||
@ -1469,7 +1469,7 @@ void UfsDirectory(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UfsListDir(char *path, uint8_t depth) {
|
void UfsListDir(char *path, uint8_t depth) {
|
||||||
char name[48];
|
char name[UFS_FILENAME_SIZE];
|
||||||
char npath[128];
|
char npath[128];
|
||||||
char format[12];
|
char format[12];
|
||||||
sprintf(format, PSTR("%%-%ds"), 24 - depth);
|
sprintf(format, PSTR("%%-%ds"), 24 - depth);
|
||||||
@ -1712,7 +1712,7 @@ void download_task(void *path) {
|
|||||||
|
|
||||||
|
|
||||||
bool UfsUploadFileOpen(const char* upload_filename) {
|
bool UfsUploadFileOpen(const char* upload_filename) {
|
||||||
char npath[48];
|
char npath[UFS_FILENAME_SIZE];
|
||||||
snprintf_P(npath, sizeof(npath), PSTR("%s/%s"), ufs_path, upload_filename);
|
snprintf_P(npath, sizeof(npath), PSTR("%s/%s"), ufs_path, upload_filename);
|
||||||
dfsp->remove(npath);
|
dfsp->remove(npath);
|
||||||
ufs_upload_file = dfsp->open(npath, UFS_FILE_WRITE);
|
ufs_upload_file = dfsp->open(npath, UFS_FILE_WRITE);
|
||||||
|
|||||||
@ -29,8 +29,9 @@ extern "C" {
|
|||||||
enum EspHostTypes { ESP_HOST, ESP_HOSTED };
|
enum EspHostTypes { ESP_HOST, ESP_HOSTED };
|
||||||
|
|
||||||
struct Hosted_t {
|
struct Hosted_t {
|
||||||
char *hosted_ota_url; // Hosted MCU OTA URL
|
char *ota_url; // Hosted MCU OTA URL
|
||||||
int hosted_ota_state_flag; // Hosted MCU OTA initiated flag
|
int ota_http_state_flag; // Hosted MCU OTA HTTP initiated flag
|
||||||
|
int ota_file_state_flag; // Hosted MCU OTA File initiated flag
|
||||||
} Hosted;
|
} Hosted;
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
@ -107,22 +108,94 @@ void HostedMCUStatus(void) {
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
void HostedMCUEverySecond(void) {
|
void HostedMCUEverySecond(void) {
|
||||||
if (Hosted.hosted_ota_state_flag && CommandsReady()) {
|
if (!CommandsReady()) { return; }
|
||||||
Hosted.hosted_ota_state_flag--;
|
|
||||||
|
#ifdef ESP_HOSTED_NEW_OTA
|
||||||
|
if (Hosted.ota_file_state_flag) {
|
||||||
|
Hosted.ota_file_state_flag--;
|
||||||
|
if (Hosted.ota_file_state_flag <= 0) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HST: File update %s"), Hosted.ota_url);
|
||||||
|
int ret = -1;
|
||||||
|
// Blocking
|
||||||
|
|
||||||
|
if (!ffsp) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: No file system"));
|
||||||
|
} else {
|
||||||
|
File file = ffsp->open(Hosted.ota_url, "r");
|
||||||
|
if (!file) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: File not found"));
|
||||||
|
} else {
|
||||||
|
// Start load on coprocessor
|
||||||
|
if ((ret = esp_hosted_slave_ota_begin()) != ESP_OK) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_begin failed %d"), ret);
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
const size_t bufSize = 1024;
|
||||||
|
uint8_t *buf = (uint8_t*)malloc(bufSize);
|
||||||
|
if (buf) {
|
||||||
|
int read;
|
||||||
|
bool write_ok = true;
|
||||||
|
int total_size = 0;
|
||||||
|
while ((read = file.read(buf, bufSize)) > 0) {
|
||||||
|
total_size += read;
|
||||||
|
if ((ret = esp_hosted_slave_ota_write(buf, (uint32_t)read)) != ESP_OK) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_write failed %d"), ret);
|
||||||
|
write_ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (total_size % 102400 == 0) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HST: Progress %d KB"), total_size / 1024);
|
||||||
|
}
|
||||||
|
delay(1);
|
||||||
|
OsWatchLoop();
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
file.close();
|
||||||
|
if (write_ok) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HST: Successful %d bytes"), total_size);
|
||||||
|
if ((ret = esp_hosted_slave_ota_end()) != ESP_OK) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_end failed %d"), ret);
|
||||||
|
} else {
|
||||||
|
// Activate will likely reboot the slave
|
||||||
|
ret = esp_hosted_slave_ota_activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Done with result %d"), ret);
|
||||||
|
free(Hosted.ota_url);
|
||||||
|
Hosted.ota_url = nullptr;
|
||||||
|
Response_P(PSTR("{\"" D_CMND_HOSTEDLOAD "\":\""));
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
// next lines are questionable, because currently the system will reboot immediately on succesful upgrade
|
||||||
|
ResponseAppend_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
|
||||||
|
TasmotaGlobal.restart_flag = 5; // Allow time for webserver to update console
|
||||||
|
} else {
|
||||||
|
ResponseAppend_P(PSTR(D_JSON_FAILED " %d\"}"), ret);
|
||||||
|
}
|
||||||
|
ResponseAppend_P(PSTR("\"}"));
|
||||||
|
MqttPublishPrefixTopicRulesProcess_P(STAT, PSTR(D_CMND_HOSTEDLOAD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ESP_HOSTED_NEW_OTA
|
||||||
|
if (Hosted.ota_http_state_flag) {
|
||||||
|
Hosted.ota_http_state_flag--;
|
||||||
/*
|
/*
|
||||||
if (2 == Hosted.hosted_ota_state_flag) {
|
if (2 == Hosted.ota_http_state_flag) {
|
||||||
SettingsSave(0);
|
SettingsSave(0);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (Hosted.hosted_ota_state_flag <= 0) {
|
if (Hosted.ota_http_state_flag <= 0) {
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: About to OTA update with %s"), Hosted.hosted_ota_url);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HST: OTA update %s"), Hosted.ota_url);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
// Blocking
|
// Blocking
|
||||||
|
|
||||||
#ifdef ESP_HOSTED_NEW_OTA
|
#ifdef ESP_HOSTED_NEW_OTA
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Using streaming OTA API"));
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Using streaming OTA API"));
|
||||||
HTTPClientLight http;
|
HTTPClientLight http;
|
||||||
if (!http.begin(Hosted.hosted_ota_url)) {
|
if (!http.begin(Hosted.ota_url)) {
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: HTTP begin failed"));
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: HTTP begin failed"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
@ -148,23 +221,24 @@ void HostedMCUEverySecond(void) {
|
|||||||
WiFiClient& stream = http.getStream();
|
WiFiClient& stream = http.getStream();
|
||||||
int read;
|
int read;
|
||||||
bool write_ok = true;
|
bool write_ok = true;
|
||||||
int chunk_count = 0;
|
int total_size = 0;
|
||||||
while ((read = stream.readBytes((char*)buf, bufSize)) > 0) {
|
while ((read = stream.readBytes((char*)buf, bufSize)) > 0) {
|
||||||
|
total_size += read;
|
||||||
if ((ret = esp_hosted_slave_ota_write(buf, (uint32_t)read)) != ESP_OK) {
|
if ((ret = esp_hosted_slave_ota_write(buf, (uint32_t)read)) != ESP_OK) {
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_write failed %d"), ret);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_write failed %d"), ret);
|
||||||
write_ok = false;
|
write_ok = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
chunk_count++;
|
if (total_size % 102400 == 0) {
|
||||||
if (chunk_count % 100 == 0) {
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HST: Progress %d KB"), total_size / 1024);
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_write %dK"), chunk_count);
|
|
||||||
}
|
}
|
||||||
yield();
|
delay(1);
|
||||||
|
OsWatchLoop();
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
http.end();
|
http.end();
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_write done"));
|
|
||||||
if (write_ok) {
|
if (write_ok) {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HST: Successful %d bytes"), total_size);
|
||||||
if ((ret = esp_hosted_slave_ota_end()) != ESP_OK) {
|
if ((ret = esp_hosted_slave_ota_end()) != ESP_OK) {
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_end failed %d"), ret);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: ota_end failed %d"), ret);
|
||||||
} else {
|
} else {
|
||||||
@ -178,12 +252,12 @@ void HostedMCUEverySecond(void) {
|
|||||||
}
|
}
|
||||||
#else // OLD_OTA
|
#else // OLD_OTA
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Using legacy OTA API"));
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Using legacy OTA API"));
|
||||||
ret = esp_hosted_slave_ota(Hosted.hosted_ota_url);
|
ret = esp_hosted_slave_ota(Hosted.ota_url);
|
||||||
#endif // ESP_HOSTED_NEW_OTA
|
#endif // ESP_HOSTED_NEW_OTA
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Done with result %d"), ret);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Done with result %d"), ret);
|
||||||
free(Hosted.hosted_ota_url);
|
free(Hosted.ota_url);
|
||||||
Hosted.hosted_ota_url = nullptr;
|
Hosted.ota_url = nullptr;
|
||||||
Response_P(PSTR("{\"" D_CMND_HOSTEDOTA "\":\""));
|
Response_P(PSTR("{\"" D_CMND_HOSTEDOTA "\":\""));
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
// next lines are questionable, because currently the system will reboot immediately on succesful upgrade
|
// next lines are questionable, because currently the system will reboot immediately on succesful upgrade
|
||||||
@ -203,10 +277,18 @@ void HostedMCUEverySecond(void) {
|
|||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
const char kHostedCommands[] PROGMEM = "Hosted|" // Prefix
|
const char kHostedCommands[] PROGMEM = "Hosted|" // Prefix
|
||||||
"|Ota";
|
"|"
|
||||||
|
#ifdef ESP_HOSTED_NEW_OTA
|
||||||
|
"Load|"
|
||||||
|
#endif // ESP_HOSTED_NEW_OTA
|
||||||
|
"Ota";
|
||||||
|
|
||||||
void (* const HostedCommand[])(void) PROGMEM = {
|
void (* const HostedCommand[])(void) PROGMEM = {
|
||||||
&CmndHosted, &CmndHostedOta };
|
&CmndHosted,
|
||||||
|
#ifdef ESP_HOSTED_NEW_OTA
|
||||||
|
&CmndHostedLoad,
|
||||||
|
#endif // ESP_HOSTED_NEW_OTA
|
||||||
|
&CmndHostedOta };
|
||||||
|
|
||||||
void CmndHosted(void) {
|
void CmndHosted(void) {
|
||||||
Response_P(PSTR("{\"Hosted\":{\"Host\":\"%s\",\"Hosted\":\"%s\",\"MCU\":\"%s\"}}"),
|
Response_P(PSTR("{\"Hosted\":{\"Host\":\"%s\",\"Hosted\":\"%s\",\"MCU\":\"%s\"}}"),
|
||||||
@ -214,6 +296,35 @@ void CmndHosted(void) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ESP_HOSTED_NEW_OTA
|
||||||
|
void CmndHostedLoad(void) {
|
||||||
|
/*
|
||||||
|
Expect files in folder /coprocessor/v2.0.17/network_adapter_esp32c6.bin
|
||||||
|
As an option allow user to enter file like:
|
||||||
|
HostedLoad /coprocessor/network_adapter_esp32c6.bin
|
||||||
|
Or allow user to enter required version like:
|
||||||
|
HostedLoad v2.0.17
|
||||||
|
*/
|
||||||
|
if (GetHostedMCUFwVersion() < 0x00020600) { return; }
|
||||||
|
|
||||||
|
Hosted.ota_url = (char*)calloc(200, sizeof(char));
|
||||||
|
if (!Hosted.ota_url) { return; } // Unable to allocate memory
|
||||||
|
if (XdrvMailbox.data_len > 15) {
|
||||||
|
strlcpy(Hosted.ota_url, XdrvMailbox.data, 200);
|
||||||
|
} else {
|
||||||
|
char version[16] = { 0 };
|
||||||
|
if (XdrvMailbox.data_len) {
|
||||||
|
snprintf_P(version, sizeof(version), PSTR("/%s"), XdrvMailbox.data);
|
||||||
|
}
|
||||||
|
snprintf_P(Hosted.ota_url, 200, PSTR("/coprocessor%s/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin"),
|
||||||
|
version);
|
||||||
|
}
|
||||||
|
Hosted.ota_file_state_flag = 1;
|
||||||
|
Response_P(PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"),
|
||||||
|
XdrvMailbox.command, GetHostedFwVersion(ESP_HOSTED).c_str(), Hosted.ota_url);
|
||||||
|
}
|
||||||
|
#endif // ESP_HOSTED_NEW_OTA
|
||||||
|
|
||||||
void CmndHostedOta(void) {
|
void CmndHostedOta(void) {
|
||||||
/*
|
/*
|
||||||
If OtaUrl = "https://ota.tasmota.com/tasmota32/tasmota32p4.bin"
|
If OtaUrl = "https://ota.tasmota.com/tasmota32/tasmota32p4.bin"
|
||||||
@ -224,27 +335,27 @@ void CmndHostedOta(void) {
|
|||||||
Or allow user to enter required version like:
|
Or allow user to enter required version like:
|
||||||
HostedOta v2.0.17
|
HostedOta v2.0.17
|
||||||
*/
|
*/
|
||||||
Hosted.hosted_ota_url = (char*)calloc(200, sizeof(char));
|
Hosted.ota_url = (char*)calloc(200, sizeof(char));
|
||||||
if (!Hosted.hosted_ota_url) { return; } // Unable to allocate memory
|
if (!Hosted.ota_url) { return; } // Unable to allocate memory
|
||||||
if (XdrvMailbox.data_len > 15) {
|
if (XdrvMailbox.data_len > 15) {
|
||||||
strlcpy(Hosted.hosted_ota_url, XdrvMailbox.data, 200);
|
strlcpy(Hosted.ota_url, XdrvMailbox.data, 200);
|
||||||
} else {
|
} else {
|
||||||
// Replace https://ota.tasmota.com/tasmota32/tasmota32p4.bin with https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_esp32c6.bin
|
// Replace https://ota.tasmota.com/tasmota32/tasmota32p4.bin with https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_esp32c6.bin
|
||||||
char ota_url[TOPSZ];
|
char ota_url[TOPSZ];
|
||||||
strlcpy(Hosted.hosted_ota_url, GetOtaUrl(ota_url, sizeof(ota_url)), 200);
|
strlcpy(Hosted.ota_url, GetOtaUrl(ota_url, sizeof(ota_url)), 200);
|
||||||
char *bch = strrchr(Hosted.hosted_ota_url, '/'); // Only consider filename after last backslash
|
char *bch = strrchr(Hosted.ota_url, '/'); // Only consider filename after last backslash
|
||||||
if (bch == nullptr) { bch = Hosted.hosted_ota_url; } // No path found so use filename only
|
if (bch == nullptr) { bch = Hosted.ota_url; } // No path found so use filename only
|
||||||
*bch = '\0'; // full_ota_url = https://ota.tasmota.com/tasmota32
|
*bch = '\0'; // full_ota_url = https://ota.tasmota.com/tasmota32
|
||||||
char version[16] = { 0 };
|
char version[16] = { 0 };
|
||||||
if (XdrvMailbox.data_len) {
|
if (XdrvMailbox.data_len) {
|
||||||
snprintf_P(version, sizeof(version), PSTR("/%s"), XdrvMailbox.data);
|
snprintf_P(version, sizeof(version), PSTR("/%s"), XdrvMailbox.data);
|
||||||
}
|
}
|
||||||
snprintf_P(Hosted.hosted_ota_url, 200, PSTR("%s/coprocessor%s/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin"),
|
snprintf_P(Hosted.ota_url, 200, PSTR("%s/coprocessor%s/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin"),
|
||||||
Hosted.hosted_ota_url, version);
|
Hosted.ota_url, version);
|
||||||
}
|
}
|
||||||
Hosted.hosted_ota_state_flag = 1;
|
Hosted.ota_http_state_flag = 1;
|
||||||
Response_P(PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"),
|
Response_P(PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"),
|
||||||
XdrvMailbox.command, GetHostedFwVersion(ESP_HOSTED).c_str(), Hosted.hosted_ota_url);
|
XdrvMailbox.command, GetHostedFwVersion(ESP_HOSTED).c_str(), Hosted.ota_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user