ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
c_FileMgr Class Reference

#include <FileMgr.hpp>

Collaboration diagram for c_FileMgr:

Classes

struct  FileListEntry_t
 

Public Types

enum  FileMode { FileRead = 0 , FileWrite , FileAppend }
 
typedef uint32_t FileId
 
typedef std::function< void(JsonDocument &json)> DeserializationHandler
 

Public Member Functions

 c_FileMgr ()
 < Start up the driver and put it into a safe mode
 
virtual ~c_FileMgr ()
 < deallocate any resources and put the output channels into a safe state
 
void Begin ()
 < Start the module
 
void Poll ()
 
void GetConfig (JsonObject &json)
 
bool SetConfig (JsonObject &json)
 
void GetStatus (JsonObject &json)
 
bool handleFileUpload (const String &filename, size_t index, uint8_t *data, size_t len, bool final, uint32_t totalLen)
 
void AbortSdFileUpload ()
 
void DeleteFlashFile (const String &FileName)
 
bool SaveFlashFile (const String &FileName, String &FileData)
 
bool SaveFlashFile (const String &FileName, const char *FileData)
 
bool SaveFlashFile (const String &FileName, JsonDocument &FileData)
 
bool SaveFlashFile (const String filename, uint32_t index, uint8_t *data, uint32_t len, bool final)
 
bool ReadFlashFile (const String &FileName, String &FileData)
 
bool ReadFlashFile (const String &FileName, JsonDocument &FileData)
 
bool ReadFlashFile (const String &FileName, byte *FileData, size_t maxlen)
 
bool LoadFlashFile (const String &FileName, DeserializationHandler Handler)
 
bool FlashFileExists (const String &FileName)
 
bool SdCardIsInstalled ()
 
FileId CreateSdFileHandle ()
 
void DeleteSdFile (const String &FileName)
 
void SaveSdFile (const String &FileName, String &FileData)
 
void SaveSdFile (const String &FileName, JsonVariant &FileData)
 
bool OpenSdFile (const String &FileName, FileMode Mode, FileId &FileHandle, int FileListIndex)
 
uint64_t ReadSdFile (const FileId &FileHandle, byte *FileData, uint64_t NumBytesToRead, uint64_t StartingPosition)
 
bool ReadSdFile (const String &FileName, String &FileData)
 
bool ReadSdFile (const String &FileName, JsonDocument &FileData)
 
uint64_t WriteSdFileBuf (const FileId &FileHandle, byte *FileData, uint64_t NumBytesToWrite)
 
uint64_t WriteSdFile (const FileId &FileHandle, byte *FileData, uint64_t NumBytesToWrite)
 
uint64_t WriteSdFile (const FileId &FileHandle, byte *FileData, uint64_t NumBytesToWrite, uint64_t StartingPosition)
 
void CloseSdFile (FileId &FileHandle)
 
void GetListOfSdFiles (std::vector< String > &Response)
 
uint64_t GetSdFileSize (const String &FileName)
 
uint64_t GetSdFileSize (const FileId &FileHandle)
 
void RenameSdFile (String &OldName, String &NewName)
 
void BuildFseqList (bool DisplayFileNames)
 
void GetDriverName (String &Name)
 
void NetworkStateChanged (bool NewState)
 
uint64_t GetDefaultFseqFileList (uint8_t *buffer, uint64_t maxlen)
 
void FindFirstZipFile (String &FileName)
 
struct __attribute__ ((__packed__, aligned(4))) CSD
 
int FileListFindSdFileHandle (FileId HandleToFind)
 
void InitSdFileList ()
 

Public Attributes

FileListEntry_t FileList [MaxOpenFiles]
 
File FileSendDir
 
uint32_t LastFileSent = 0
 
uint32_t expectedIndex = 0
 
bool SdAccessSemaphore = false
 

Static Public Attributes

static const FileId INVALID_FILE_HANDLE = 0
 

Private Member Functions

void SetSpiIoPins ()
 
void SetSdSpeed ()
 
void ResetSdCard ()
 
void LockSd ()
 
void UnLockSd ()
 
bool SeekSdFile (const FileId &FileHandle, uint64_t position, SeekMode Mode)
 
void listDir (fs::FS &fs, String dirname, uint8_t levels)
 
void DescribeSdCardToUser ()
 
void handleFileUploadNewFile (const String &filename)
 
void printDirectory (FsFile &dir, int numTabs)
 

Private Attributes

bool SdCardInstalled = false
 
uint8_t miso_pin = SD_CARD_MISO_PIN
 
uint8_t mosi_pin = SD_CARD_MOSI_PIN
 
uint8_t clk_pin = SD_CARD_CLK_PIN
 
uint8_t cs_pin = SD_CARD_CS_PIN
 
FileId fsUploadFileHandle
 
String fsUploadFileName
 
bool fsUploadFileSavedIsEnabled = false
 
uint32_t fsUploadStartTime
 
String FtpUserName = "esps"
 
String FtpPassword = "esps"
 
String WelcomeString = "ESPS V4 FTP"
 
bool FtpEnabled = true
 
uint64_t SdCardSizeMB = 0
 
uint32_t MaxSdSpeed = MaxSdTransSpeedMHz
 
bool FoundZipFile = false
 

Member Typedef Documentation

◆ DeserializationHandler

std::function<void (JsonDocument& json)> c_FileMgr::DeserializationHandler

◆ FileId

Member Enumeration Documentation

◆ FileMode

Enumerator
FileRead 
FileWrite 
FileAppend 

Constructor & Destructor Documentation

◆ c_FileMgr()

c_FileMgr::c_FileMgr ( )

< Start up the driver and put it into a safe mode

◆ ~c_FileMgr()

c_FileMgr::~c_FileMgr ( )
virtual

< deallocate any resources and put the output channels into a safe state

Member Function Documentation

◆ __attribute__()

struct c_FileMgr::__attribute__ ( (__packed__, aligned(4)) )
inline

◆ AbortSdFileUpload()

void c_FileMgr::AbortSdFileUpload ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Begin()

void c_FileMgr::Begin ( )

< Start the module

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildFseqList()

void c_FileMgr::BuildFseqList ( bool DisplayFileNames)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseSdFile()

void c_FileMgr::CloseSdFile ( FileId & FileHandle)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateSdFileHandle()

c_FileMgr::FileId c_FileMgr::CreateSdFileHandle ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteFlashFile()

void c_FileMgr::DeleteFlashFile ( const String & FileName)
Here is the caller graph for this function:

◆ DeleteSdFile()

void c_FileMgr::DeleteSdFile ( const String & FileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DescribeSdCardToUser()

void c_FileMgr::DescribeSdCardToUser ( )
private
Here is the caller graph for this function:

◆ FileListFindSdFileHandle()

int c_FileMgr::FileListFindSdFileHandle ( FileId HandleToFind)
Here is the caller graph for this function:

◆ FindFirstZipFile()

void c_FileMgr::FindFirstZipFile ( String & FileName)
Here is the call graph for this function:

◆ FlashFileExists()

bool c_FileMgr::FlashFileExists ( const String & FileName)

◆ GetConfig()

void c_FileMgr::GetConfig ( JsonObject & json)
Here is the caller graph for this function:

◆ GetDefaultFseqFileList()

uint64_t c_FileMgr::GetDefaultFseqFileList ( uint8_t * buffer,
uint64_t maxlen )
Here is the caller graph for this function:

◆ GetDriverName()

void c_FileMgr::GetDriverName ( String & Name)
inline

◆ GetListOfSdFiles()

void c_FileMgr::GetListOfSdFiles ( std::vector< String > & Response)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSdFileSize() [1/2]

uint64_t c_FileMgr::GetSdFileSize ( const FileId & FileHandle)
Here is the call graph for this function:

◆ GetSdFileSize() [2/2]

uint64_t c_FileMgr::GetSdFileSize ( const String & FileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStatus()

void c_FileMgr::GetStatus ( JsonObject & json)
Here is the caller graph for this function:

◆ handleFileUpload()

bool c_FileMgr::handleFileUpload ( const String & filename,
size_t index,
uint8_t * data,
size_t len,
bool final,
uint32_t totalLen )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleFileUploadNewFile()

void c_FileMgr::handleFileUploadNewFile ( const String & filename)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitSdFileList()

void c_FileMgr::InitSdFileList ( )
Here is the caller graph for this function:

◆ listDir()

void c_FileMgr::listDir ( fs::FS & fs,
String dirname,
uint8_t levels )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFlashFile()

bool c_FileMgr::LoadFlashFile ( const String & FileName,
DeserializationHandler Handler )
Here is the caller graph for this function:

◆ LockSd()

void c_FileMgr::LockSd ( )
private
Here is the caller graph for this function:

◆ NetworkStateChanged()

void c_FileMgr::NetworkStateChanged ( bool NewState)
Here is the caller graph for this function:

◆ OpenSdFile()

bool c_FileMgr::OpenSdFile ( const String & FileName,
FileMode Mode,
FileId & FileHandle,
int FileListIndex )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Poll()

void c_FileMgr::Poll ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printDirectory()

void c_FileMgr::printDirectory ( FsFile & dir,
int numTabs )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadFlashFile() [1/3]

bool c_FileMgr::ReadFlashFile ( const String & FileName,
byte * FileData,
size_t maxlen )

◆ ReadFlashFile() [2/3]

bool c_FileMgr::ReadFlashFile ( const String & FileName,
JsonDocument & FileData )
Here is the call graph for this function:

◆ ReadFlashFile() [3/3]

bool c_FileMgr::ReadFlashFile ( const String & FileName,
String & FileData )
Here is the caller graph for this function:

◆ ReadSdFile() [1/3]

uint64_t c_FileMgr::ReadSdFile ( const FileId & FileHandle,
byte * FileData,
uint64_t NumBytesToRead,
uint64_t StartingPosition )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadSdFile() [2/3]

bool c_FileMgr::ReadSdFile ( const String & FileName,
JsonDocument & FileData )
Here is the call graph for this function:

◆ ReadSdFile() [3/3]

bool c_FileMgr::ReadSdFile ( const String & FileName,
String & FileData )
Here is the call graph for this function:

◆ RenameSdFile()

void c_FileMgr::RenameSdFile ( String & OldName,
String & NewName )
Here is the call graph for this function:

◆ ResetSdCard()

void c_FileMgr::ResetSdCard ( )
private

◆ SaveFlashFile() [1/4]

bool c_FileMgr::SaveFlashFile ( const String & FileName,
const char * FileData )

◆ SaveFlashFile() [2/4]

bool c_FileMgr::SaveFlashFile ( const String & FileName,
JsonDocument & FileData )

◆ SaveFlashFile() [3/4]

bool c_FileMgr::SaveFlashFile ( const String & FileName,
String & FileData )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveFlashFile() [4/4]

bool c_FileMgr::SaveFlashFile ( const String filename,
uint32_t index,
uint8_t * data,
uint32_t len,
bool final )

◆ SaveSdFile() [1/2]

void c_FileMgr::SaveSdFile ( const String & FileName,
JsonVariant & FileData )
Here is the call graph for this function:

◆ SaveSdFile() [2/2]

void c_FileMgr::SaveSdFile ( const String & FileName,
String & FileData )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SdCardIsInstalled()

bool c_FileMgr::SdCardIsInstalled ( )
inline
Here is the caller graph for this function:

◆ SeekSdFile()

bool c_FileMgr::SeekSdFile ( const FileId & FileHandle,
uint64_t position,
SeekMode Mode )
private
Here is the call graph for this function:

◆ SetConfig()

bool c_FileMgr::SetConfig ( JsonObject & json)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSdSpeed()

void c_FileMgr::SetSdSpeed ( )
private
Here is the caller graph for this function:

◆ SetSpiIoPins()

void c_FileMgr::SetSpiIoPins ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnLockSd()

void c_FileMgr::UnLockSd ( )
private
Here is the caller graph for this function:

◆ WriteSdFile() [1/2]

uint64_t c_FileMgr::WriteSdFile ( const FileId & FileHandle,
byte * FileData,
uint64_t NumBytesToWrite )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteSdFile() [2/2]

uint64_t c_FileMgr::WriteSdFile ( const FileId & FileHandle,
byte * FileData,
uint64_t NumBytesToWrite,
uint64_t StartingPosition )
Here is the call graph for this function:

◆ WriteSdFileBuf()

uint64_t c_FileMgr::WriteSdFileBuf ( const FileId & FileHandle,
byte * FileData,
uint64_t NumBytesToWrite )
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ clk_pin

uint8_t c_FileMgr::clk_pin = SD_CARD_CLK_PIN
private

◆ cs_pin

uint8_t c_FileMgr::cs_pin = SD_CARD_CS_PIN
private

◆ expectedIndex

uint32_t c_FileMgr::expectedIndex = 0

◆ FileList

FileListEntry_t c_FileMgr::FileList[MaxOpenFiles]

◆ FileSendDir

File c_FileMgr::FileSendDir

◆ FoundZipFile

bool c_FileMgr::FoundZipFile = false
private

◆ fsUploadFileHandle

FileId c_FileMgr::fsUploadFileHandle
private

◆ fsUploadFileName

String c_FileMgr::fsUploadFileName
private

◆ fsUploadFileSavedIsEnabled

bool c_FileMgr::fsUploadFileSavedIsEnabled = false
private

◆ fsUploadStartTime

uint32_t c_FileMgr::fsUploadStartTime
private

◆ FtpEnabled

bool c_FileMgr::FtpEnabled = true
private

◆ FtpPassword

String c_FileMgr::FtpPassword = "esps"
private

◆ FtpUserName

String c_FileMgr::FtpUserName = "esps"
private

◆ INVALID_FILE_HANDLE

const FileId c_FileMgr::INVALID_FILE_HANDLE = 0
static

◆ LastFileSent

uint32_t c_FileMgr::LastFileSent = 0

◆ MaxSdSpeed

uint32_t c_FileMgr::MaxSdSpeed = MaxSdTransSpeedMHz
private

◆ miso_pin

uint8_t c_FileMgr::miso_pin = SD_CARD_MISO_PIN
private

◆ mosi_pin

uint8_t c_FileMgr::mosi_pin = SD_CARD_MOSI_PIN
private

◆ SdAccessSemaphore

bool c_FileMgr::SdAccessSemaphore = false

◆ SdCardInstalled

bool c_FileMgr::SdCardInstalled = false
private

◆ SdCardSizeMB

uint64_t c_FileMgr::SdCardSizeMB = 0
private

◆ WelcomeString

String c_FileMgr::WelcomeString = "ESPS V4 FTP"
private

The documentation for this class was generated from the following files: