Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/components/ble/FSService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,17 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
memcpy(filepath, header->pathstr, plen);
filepath[plen] = 0; // Copy and null terminate string
fileSize = header->totalSize;
WriteResponse resp;
WriteResponse resp {};
resp.command = commands::WRITE_PACING;
resp.offset = header->offset;
resp.modTime = 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;
resp.status = 0x01;
} else {
resp.status = (int8_t) res;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Althoug the original had a c stype cast I prever to have C++ style static_cast here please

}
resp.freespace = std::min(fs.getSize() - (fs.GetFSSize() * fs.getBlockSize()), fileSize - header->offset);
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(WriteResponse));
Expand All @@ -182,9 +184,10 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
case commands::WRITE_DATA: {
NRF_LOG_INFO("[FS_S] -> WriteData");
auto* header = (WritePacing*) om->om_data;
WriteResponse resp;
WriteResponse resp {};
resp.command = commands::WRITE_PACING;
resp.offset = header->offset;
resp.status = 0x01;
int res = 0;

if (!(res = fs.FileOpen(&f, filepath, LFS_O_RDWR | LFS_O_CREAT))) {
Expand Down
Loading