diff --git a/CHANGELOG.md b/CHANGELOG.md index 45ce15fd8..7899108dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. - Support for Frysk language translations by Christiaan Heerze - ESP8266 Fallback to ``*.bin.gz`` binary when OTA upload of ``*.bin`` binary fails - Berry language improved Tasmota integration +- Filesystem commands ``Ufs``, ``UfsType``, ``UfsSize``, ``UfsFree``, ``UfsDelete`` and ``UfsRename`` +- Basic support for filesystem ``autoexec.bat`` ### Changed - IRremoteESP8266 library from v2.7.14 to v2.7.15 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 175054b38..f68cf0a34 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -95,6 +95,8 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Commands ``ZbNameKey``, ``ZbDeviceTopic``, ``ZbNoPrefix``, ``ZbEndpointSuffix``, ``ZbNoAutoBind`` and ``ZbNameTopic`` as synonyms for ``SetOption83, 89, 100, 101, 110`` and ``112`` - Commands ``ZbNoAutoBind``, ``ZbReceivedTopic`` and ``ZbOmitDevice`` as synonyms for ``SetOption116, 118`` and ``119`` - Commands ``BuzzerActive`` and ``BuzzerPwm`` as synonyms for ``SetOption67`` and ``111`` +- Filesystem commands ``Ufs``, ``UfsType``, ``UfsSize``, ``UfsFree``, ``UfsDelete`` and ``UfsRename`` +- Basic support for filesystem ``autoexec.bat`` - Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152) - Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196) - Rotary No Pullup GPIO selection ``Rotary A/B_n`` [#10407](https://github.com/arendst/Tasmota/issues/10407) diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index 08c7f18c8..c022e89be 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -336,6 +336,16 @@ bool TfsDeleteFile(const char *fname) { return true; } +bool TfsRenameFile(const char *fname1, const char *fname2) { + if (!ffs_type) { return false; } + + if (!ffsp->rename(fname1, fname2)) { + AddLog(LOG_LEVEL_INFO, PSTR("TFS: Rename failed")); + return false; + } + return true; +} + /*********************************************************************************************\ * Autoexec support \*********************************************************************************************/ @@ -380,10 +390,10 @@ void UfsAutoexec(void) { \*********************************************************************************************/ const char kUFSCommands[] PROGMEM = "Ufs|" // Prefix - "|Type|Size|Free|Delete"; + "|Type|Size|Free|Delete|Rename"; void (* const kUFSCommand[])(void) PROGMEM = { - &UFSInfo, &UFSType, &UFSSize, &UFSFree, &UFSDelete}; + &UFSInfo, &UFSType, &UFSSize, &UFSFree, &UFSDelete, &UFSRename}; void UFSInfo(void) { Response_P(PSTR("{\"Ufs\":{\"Type\":%d,\"Size\":%d,\"Free\":%d}"), ufs_type, UfsInfo(0, 0), UfsInfo(1, 0)); @@ -435,6 +445,28 @@ void UFSDelete(void) { } } +void UFSRename(void) { + // UfsRename sdcard or flashfs file if only one of them available + // UfsRename2 flashfs file if available + if (XdrvMailbox.data_len > 0) { + bool result = false; + const char *fname1 = strtok(XdrvMailbox.data, ","); + const char *fname2 = strtok(nullptr, ","); + if (fname1 && fname2) { + if (ffs_type && (ffs_type != ufs_type) && (2 == XdrvMailbox.index)) { + result = TfsRenameFile(fname1, fname2); + } else { + result = (ufs_type && ufsp->rename(fname1, fname2)); + } + } + if (!result) { + ResponseCmndChar(PSTR(D_JSON_FAILED)); + } else { + ResponseCmndDone(); + } + } +} + /*********************************************************************************************\ * Web support \*********************************************************************************************/