Focus on getting flash access working properly
This commit is contained in:
parent
8f6a390c36
commit
d89e38d3bf
|
@ -60,9 +60,10 @@ int FSService::OnFSServiceRequested(uint16_t connectionHandle, uint16_t attribut
|
||||||
|
|
||||||
int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
|
int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
auto command = static_cast<commands>(om->om_data[0]);
|
auto command = static_cast<commands>(om->om_data[0]);
|
||||||
NRF_LOG_INFO("[FS_S] -> FSCommandHandler");
|
NRF_LOG_INFO("[FS_S] -> FSCommandHandler %d",command);
|
||||||
|
fs.Mount();
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
/*
|
||||||
case commands::READ: {
|
case commands::READ: {
|
||||||
NRF_LOG_INFO("[FS_S] -> Read");
|
NRF_LOG_INFO("[FS_S] -> Read");
|
||||||
if (state != FSState::IDLE) {
|
if (state != FSState::IDLE) {
|
||||||
|
@ -194,7 +195,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(MKDirResponse));
|
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(MKDirResponse));
|
||||||
ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);
|
ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);
|
||||||
break;
|
break;
|
||||||
}
|
}*/
|
||||||
case commands::LISTDIR: {
|
case commands::LISTDIR: {
|
||||||
NRF_LOG_INFO("[FS_S] -> ListDir");
|
NRF_LOG_INFO("[FS_S] -> ListDir");
|
||||||
ListDirHeader* header = (ListDirHeader*) om->om_data;
|
ListDirHeader* header = (ListDirHeader*) om->om_data;
|
||||||
|
@ -244,7 +245,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
NRF_LOG_INFO("[FS_S] ->Path %s ,", info.name);
|
NRF_LOG_INFO("[FS_S] ->Path %s ,", info.name);
|
||||||
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(ListDirResponse)+resp.path_length);
|
auto* om = ble_hs_mbuf_from_flat(&resp, sizeof(ListDirResponse)+resp.path_length);
|
||||||
ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);
|
ble_gattc_notify_custom(connectionHandle, transferCharacteristicHandle, om);
|
||||||
vTaskDelay(5); // Allow stuff to actually go out over the BLE conn
|
vTaskDelay(10); // Allow stuff to actually go out over the BLE conn
|
||||||
resp.entry++;
|
resp.entry++;
|
||||||
}
|
}
|
||||||
fs.DirClose(&dir);
|
fs.DirClose(&dir);
|
||||||
|
@ -258,6 +259,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fs.UnMount();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Loads resp with file data given a valid filepath header and resp
|
// Loads resp with file data given a valid filepath header and resp
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace Pinetime {
|
||||||
uint32_t entry;
|
uint32_t entry;
|
||||||
uint32_t totalentries;
|
uint32_t totalentries;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t modification_time;
|
uint64_t modification_time;
|
||||||
uint32_t file_size;
|
uint32_t file_size;
|
||||||
char path[];
|
char path[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,6 +54,14 @@ void FS::VerifyResource() {
|
||||||
resourcesValid = true;
|
resourcesValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FS::Mount() {
|
||||||
|
flashDriver.Wakeup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FS::UnMount() {
|
||||||
|
flashDriver.Sleep();
|
||||||
|
}
|
||||||
|
|
||||||
int FS::FileOpen(lfs_file_t* file_p, const char* fileName, const int flags) {
|
int FS::FileOpen(lfs_file_t* file_p, const char* fileName, const int flags) {
|
||||||
return lfs_file_open(&lfs, file_p, fileName, flags);
|
return lfs_file_open(&lfs, file_p, fileName, flags);
|
||||||
}
|
}
|
||||||
|
@ -96,8 +104,8 @@ int FS::DirCreate(const char* path) {
|
||||||
return lfs_mkdir(&lfs, path);
|
return lfs_mkdir(&lfs, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FS::Stat(const char* path, lfs_info* info){
|
int FS::Stat(const char* path, lfs_info* info) {
|
||||||
return lfs_stat(&lfs,path,info);
|
return lfs_stat(&lfs, path, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete directory and all files inside
|
// Delete directory and all files inside
|
||||||
|
|
|
@ -13,6 +13,9 @@ namespace Pinetime {
|
||||||
void Init();
|
void Init();
|
||||||
void LVGLFileSystemInit();
|
void LVGLFileSystemInit();
|
||||||
|
|
||||||
|
void Mount();
|
||||||
|
void UnMount();
|
||||||
|
|
||||||
int FileOpen(lfs_file_t* file_p, const char* fileName, const int flags);
|
int FileOpen(lfs_file_t* file_p, const char* fileName, const int flags);
|
||||||
int FileClose(lfs_file_t* file_p);
|
int FileClose(lfs_file_t* file_p);
|
||||||
int FileRead(lfs_file_t* file_p, uint8_t* buff, uint32_t size);
|
int FileRead(lfs_file_t* file_p, uint8_t* buff, uint32_t size);
|
||||||
|
@ -32,7 +35,6 @@ namespace Pinetime {
|
||||||
void VerifyResource();
|
void VerifyResource();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Pinetime::Drivers::SpiNorFlash& flashDriver;
|
Pinetime::Drivers::SpiNorFlash& flashDriver;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -70,7 +72,6 @@ namespace Pinetime {
|
||||||
static int SectorErase(const struct lfs_config* c, lfs_block_t block);
|
static int SectorErase(const struct lfs_config* c, lfs_block_t block);
|
||||||
static int SectorProg(const struct lfs_config* c, lfs_block_t block, lfs_off_t off, const void* buffer, lfs_size_t size);
|
static int SectorProg(const struct lfs_config* c, lfs_block_t block, lfs_off_t off, const void* buffer, lfs_size_t size);
|
||||||
static int SectorRead(const struct lfs_config* c, lfs_block_t block, lfs_off_t off, void* buffer, lfs_size_t size);
|
static int SectorRead(const struct lfs_config* c, lfs_block_t block, lfs_off_t off, void* buffer, lfs_size_t size);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user