summaryrefslogtreecommitdiff
path: root/src/components/ble/FSService.cpp
diff options
context:
space:
mode:
authorTim Keller <geekboy1011@gmail.com>2021-11-21 06:17:07 +0000
committerTim Keller <geekboy1011@gmail.com>2021-12-10 01:18:57 +0000
commitd1e9aa107617565b456f05e20e9468ab270d323e (patch)
treecfdc7fc470747e239b81eade318a4885bc5faaef /src/components/ble/FSService.cpp
parentfdb5e27aea99c3a5117661948de75e7853165ff5 (diff)
Force variable cleanup because LFS makes assumptions about variable initialization state
Diffstat (limited to 'src/components/ble/FSService.cpp')
-rw-r--r--src/components/ble/FSService.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/components/ble/FSService.cpp b/src/components/ble/FSService.cpp
index 2222ae9a..03d4673d 100644
--- a/src/components/ble/FSService.cpp
+++ b/src/components/ble/FSService.cpp
@@ -71,9 +71,11 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
}
lfs_dir_t dir;
lfs_info info;
+ lfs_file f;
+ memset(&f, 0, sizeof(lfs_file_t));
+ memset(&dir, 0, sizeof(lfs_dir_t));
switch (command) {
case commands::READ: {
- lfs_file f;
NRF_LOG_INFO("[FS_S] -> Read");
auto* header = (ReadHeader*) om->om_data;
uint16_t plen = header->pathlen;
@@ -109,7 +111,6 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
break;
}
case commands::READ_PACING: {
- lfs_file f;
NRF_LOG_INFO("[FS_S] -> Readpacing");
auto* header = (ReadHeader*) om->om_data;
ReadResponse resp;
@@ -142,7 +143,6 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
break;
}
case commands::WRITE: {
- lfs_file f;
NRF_LOG_INFO("[FS_S] -> Write");
auto* header = (WriteHeader*) om->om_data;
uint16_t plen = header->pathlen;
@@ -157,8 +157,8 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
resp.offset = header->offset;
resp.modTime = 0;
- int res = fs.FileOpen(&f, filepath, LFS_O_WRONLY | LFS_O_CREAT);
- if(res == 0){
+ int res = fs.FileOpen(&f, filepath, LFS_O_RDWR | LFS_O_CREAT);
+ if (res == 0) {
fs.FileClose(&f);
resp.status = (res == 0) ? 0x01 : (int8_t) res;
}
@@ -168,7 +168,6 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
break;
}
case commands::WRITE_DATA: {
- lfs_file f;
NRF_LOG_INFO("[FS_S] -> WriteData");
auto* header = (WritePacing*) om->om_data;
WriteResponse resp;
@@ -185,7 +184,6 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
if (res < 0) {
resp.status = (int8_t) res;
}
-
resp.freespace = std::min(fs.getSize() - (fs.GetFSSize() * fs.getBlockSize()), fileSize - header->offset);
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(WriteResponse));
ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);