diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index b0a681f4a..8e50013e3 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -1343,14 +1343,18 @@ void CmndOtaUrl(void) #ifdef CONFIG_ESP_WIFI_REMOTE_ENABLED void CmdHostedOta() { - // If OtaUrl = "https://ota.tasmota.com/tasmota32/tasmota32p4.bin" - // Then use "https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin" - // As an option allow user to enter URL like: - // HostedOta https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_esp32c6.bin - // HostedOta https://ota.tasmota.com/tasmota32/coprocessor/v2.0.14/network_adapter_esp32c6.bin + /* + If OtaUrl = "https://ota.tasmota.com/tasmota32/tasmota32p4.bin" + Then use "https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin" + As an option allow user to enter URL like: + HostedOta https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_esp32c6.bin + HostedOta https://ota.tasmota.com/tasmota32/coprocessor/v2.0.14/network_adapter_esp32c6.bin + Or allow user to enter required version like: + HostedOta v2.0.17 + */ TasmotaGlobal.hosted_ota_url = (char*)calloc(200, sizeof(char)); if (!TasmotaGlobal.hosted_ota_url) { return; } // Unable to allocate memory - if (XdrvMailbox.data_len) { + if (XdrvMailbox.data_len > 15) { strlcpy(TasmotaGlobal.hosted_ota_url, XdrvMailbox.data, 200); } else { // Replace https://ota.tasmota.com/tasmota32/tasmota32p4.bin with https://ota.tasmota.com/tasmota32/coprocessor/network_adapter_esp32c6.bin @@ -1359,7 +1363,12 @@ void CmdHostedOta() { char *bch = strrchr(TasmotaGlobal.hosted_ota_url, '/'); // Only consider filename after last backslash if (bch == nullptr) { bch = TasmotaGlobal.hosted_ota_url; } // No path found so use filename only *bch = '\0'; // full_ota_url = https://ota.tasmota.com/tasmota32 - snprintf_P(TasmotaGlobal.hosted_ota_url, 200, PSTR("%s/coprocessor/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin"), TasmotaGlobal.hosted_ota_url); + char version[16] = { 0 }; + if (XdrvMailbox.data_len) { + snprintf_P(version, sizeof(version), PSTR("/%s"), XdrvMailbox.data); + } + snprintf_P(TasmotaGlobal.hosted_ota_url, 200, PSTR("%s/coprocessor%s/network_adapter_" CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET ".bin"), + TasmotaGlobal.hosted_ota_url, version); } TasmotaGlobal.hosted_ota_state_flag = 1; Response_P(PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"), diff --git a/tasmota/tasmota_support/support_hosted_mcu.ino b/tasmota/tasmota_support/support_hosted_mcu.ino index 5eaa1ea30..ef9b85fa3 100644 --- a/tasmota/tasmota_support/support_hosted_mcu.ino +++ b/tasmota/tasmota_support/support_hosted_mcu.ino @@ -64,7 +64,10 @@ String GetHostedMCUFwVersion(void) { } int OTAHostedMCU(const char* image_url) { - return esp_hosted_slave_ota(image_url); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: About to OTA update with %s"), image_url); + int result = esp_hosted_slave_ota(image_url); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HST: Done with result %d"), result); + return result; } #endif // CONFIG_ESP_WIFI_REMOTE_ENABLED \ No newline at end of file