summaryrefslogtreecommitdiff
path: root/src/components/ble/FSService.cpp
diff options
context:
space:
mode:
authorTim Keller <geekboy1011@gmail.com>2021-11-16 04:32:53 +0000
committerTim Keller <geekboy1011@gmail.com>2021-12-10 01:18:57 +0000
commit362a5ef1136399c178cf881f7569e3d291432ec1 (patch)
treea4545cf46aa38cf5b85bad3c2290a5d6dfc06164 /src/components/ble/FSService.cpp
parent8f46908d387cc4fe3f911bc0ca517719238418ed (diff)
Added move function
Diffstat (limited to 'src/components/ble/FSService.cpp')
-rw-r--r--src/components/ble/FSService.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/components/ble/FSService.cpp b/src/components/ble/FSService.cpp
index 0230ea15..1082d24c 100644
--- a/src/components/ble/FSService.cpp
+++ b/src/components/ble/FSService.cpp
@@ -270,6 +270,21 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);
break;
}
+ case commands::MOVE: {
+ NRF_LOG_INFO("[FS_S] -> Move");
+ MoveHeader* header = (MoveHeader*) om->om_data;
+ uint16_t plen = header->OldPathLength;
+ // Null Terminate string
+ header->pathstr[plen] = 0;
+ char path[header->NewPathLength + 1] {0};
+ memcpy(path, &header->pathstr[plen + 1], header->NewPathLength);
+ MoveResponse resp {};
+ resp.command = commands::MOVE_STATUS;
+ int res = fs.Rename(header->pathstr, path);
+ resp.status = (res == 0) ? 1 : 2;
+ auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(MoveResponse));
+ ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);
+ }
default:
break;
}