flux sdk  v01.05.00-3-gedf3296
Embedded C++ SDK
Loading...
Searching...
No Matches
flxKVPStorePage Class Reference

#include <flxKVPStorePage.h>

Public Member Functions

 flxKVPStorePage ()
 
bool initialize (flxKVPStoreDevice *theDevice, uint32_t sectorNumber)
 
flxKVPError_t loadPage (void)
 Loads the page from the storage device. More...
 
flxKVPError_t writeEntry (const flxKVPStoreEntry &theEntry)
 Writes a flxFPSEntry to the storage device. More...
 
flxKVPError_t readEntry (uint32_t index, flxKVPStoreEntry &theEntry)
 Reads an entry from the flash storage page. More...
 
flxKVPError_t findEntry (uint8_t iNS, const char *szKey, flxKVPStoreEntry &theEntry, uint32_t &entryIndex)
 
flxKVPError_t findEntry (uint8_t iNS, const char *szKey, flxKVPStoreEntry &theEntry)
 
flxKVPError_t deleteEntry (uint32_t index)
 Deletes an entry at the specified index. More...
 
flxKVPError_t updateEntry (uint32_t index, const flxKVPStoreEntry &theEntry)
 Updates an entry in the flash page. More...
 
flxKVPError_t setValue (uint8_t iNS, flxDataType_t dType, const char *szKey, const void *value, size_t valueSize)
 Sets the value of a key-value pair in the flash page. More...
 
flxKVPError_t setValue (uint8_t iNS, const char *szKey, const char *value)
 
flxKVPError_t setValue (uint8_t iNS, const char *szKey, char *value)
 
template<typename T >
flxKVPError_t setValue (uint8_t iNS, const char *szKey, T &value)
 
flxKVPError_t setValueString (uint8_t iNS, const char *szKey, const char *value, size_t valueSize)
 Sets the value of a key-value pair in the flxFPSPage. More...
 
flxKVPError_t readValue (uint8_t iNS, flxDataType_t dType, const char *szKey, void *value, size_t valueSize)
 Reads the value associated with the specified key from the flash storage page. More...
 
template<typename T >
flxKVPError_t readValue (uint8_t iNS, const char *szKey, T &value)
 
flxKVPError_t readValue (uint8_t iNS, const char *szKey, char *value, size_t len)
 
flxKVPError_t deleteValue (uint8_t iNS, const char *szKey)
 Delete a key-value pair from the flash storage page. More...
 
bool keyExists (uint8_t iNS, const char *szKey)
 
flxKVPPageStatus status ()
 
flxKVPError_t initPage (bool bErase=false)
 Initialize the page AND write init values to flash. More...
 
void dumpPage (void)
 Dumps the contents of the page to the Serial monitor. More...
 

Static Public Attributes

static constexpr uint32_t kPageInitialized = flxKVPPageStatus::kPageAvailable
 
static constexpr uint32_t kPageFull = flxKVPPageStatus::kPageFull
 
static constexpr uint32_t kSectorSize = 4096
 
static constexpr uint32_t kNEntriesPerPage = (kSectorSize / flxKVPStoreEntry::kEntrySize) - kNBookKeepingEntries
 
static constexpr uint32_t kNoSector = 0xFFFFFFFF
 

Constructor & Destructor Documentation

◆ flxKVPStorePage()

flxKVPStorePage::flxKVPStorePage ( )

Member Function Documentation

◆ deleteEntry()

flxKVPError_t flxKVPStorePage::deleteEntry ( uint32_t  index)

Deletes an entry at the specified index.

Parameters
indexThe index of the entry to delete.
Returns
flxKVPError_t Returns kKVPErrorInvalidIndex if the index is invalid, kKVPErrorIO if there was an I/O error, or kKVPErrorOK if the entry was successfully deleted.

◆ deleteValue()

flxKVPError_t flxKVPStorePage::deleteValue ( uint8_t  iNS,
const char *  szKey 
)

Delete a key-value pair from the flash storage page.

This function deletes a key-value pair from the flash storage page based on the provided namespace and key.

Parameters
iNSThe namespace of the key-value pair.
szKeyThe key of the key-value pair.
Returns
The result of the delete operation.
  • kKVPErrorOK: The key-value pair was successfully deleted.
  • kKVPErrorNoMatch: The key-value pair was not found in the page.

◆ dumpPage()

void flxKVPStorePage::dumpPage ( void  )

Dumps the contents of the page to the Serial monitor.

This method prints the page number, status, base address, last empty entry, and the state of each entry in the page to the Serial monitor.

◆ findEntry() [1/2]

flxKVPError_t flxKVPStorePage::findEntry ( uint8_t  iNS,
const char *  szKey,
flxKVPStoreEntry theEntry 
)
inline

◆ findEntry() [2/2]

flxKVPError_t flxKVPStorePage::findEntry ( uint8_t  iNS,
const char *  szKey,
flxKVPStoreEntry theEntry,
uint32_t &  entryIndex 
)

Finds an entry in the flxFPSPage object.

Parameters
iNSThe namespace of the entry.
szKeyThe key of the entry.
theEntryThe output parameter to store the found entry.
[in,out]entryIndexInput: the index of the entry to start the search from, returns the index of the found entry.
Returns
The error code indicating the result of the operation. kKVPErrorConfig if the storage is not initialized, kKVPErrorKey if the key is invalid, kKVPErrorInvalidIndex if the provided index is invalid, kKVPErrorIO if there was an I/O error, or kKVPErrorNoMatch if no matching entry was found.

◆ initialize()

bool flxKVPStorePage::initialize ( flxKVPStoreDevice theDevice,
uint32_t  sectorNumber 
)

Initializes the flxFPSPage object.

Parameters
theDeviceThe flxFPSDevice object to associate with this page.
sectorNumberThe sector number of the page.
Returns
True if initialization is successful, false otherwise.

◆ initPage()

flxKVPError_t flxKVPStorePage::initPage ( bool  bErase = false)

Initialize the page AND write init values to flash.

Parameters
bEraseif true, erase the page - defaults to false
Returns
flxKVPError_t kKVPErrorOK if success

◆ keyExists()

bool flxKVPStorePage::keyExists ( uint8_t  iNS,
const char *  szKey 
)

Checks if a key exists in the flash page.

Parameters
iNSThe namespace of the key.
szKeyThe key to check.
Returns
True if the key exists, false otherwise.

◆ loadPage()

flxKVPError_t flxKVPStorePage::loadPage ( void  )

Loads the page from the storage device.

Returns
kKVPErrorOK if successful. KVPErrorConfig if the page has not been initialized.
KVPErrorIO if there was an I/O error.

◆ readEntry()

flxKVPError_t flxKVPStorePage::readEntry ( uint32_t  index,
flxKVPStoreEntry theEntry 
)

Reads an entry from the flash storage page.

This function reads the entry at the specified index from the flash storage page.

Parameters
indexThe index of the entry to read.
theEntryReference to the flxFPSEntry object to store the read entry.
Returns
The error code indicating the status of the read operation.
  • kKVPErrorConfig: If the storage is not initialized or the entry state is not entryWritten.
  • kKVPErrorIO: If there was an I/O error during the read operation.
  • kKVPErrorOK: If the read operation was successful.

◆ readValue() [1/3]

flxKVPError_t flxKVPStorePage::readValue ( uint8_t  iNS,
const char *  szKey,
char *  value,
size_t  len 
)
inline

◆ readValue() [2/3]

template<typename T >
flxKVPError_t flxKVPStorePage::readValue ( uint8_t  iNS,
const char *  szKey,
T &  value 
)
inline

◆ readValue() [3/3]

flxKVPError_t flxKVPStorePage::readValue ( uint8_t  iNS,
flxDataType_t  dType,
const char *  szKey,
void *  value,
size_t  valueSize 
)

Reads the value associated with the specified key from the flash storage page.

Parameters
iNSThe namespace of the key-value pair.
dTypeThe data type of the value.
szKeyThe key to search for.
valuePointer to the buffer where the value will be stored.
valueSizeThe size of the buffer.
Returns
flxKVPError_t The error code indicating the result of the operation. Returns kKVPErrorNoMatch if no matching value found, kKVPErrorBadType if the data type does not match, kKVPErrorBuffer if the buffer is too small, kKVPErrorIO if there was an I/O error, or kKVPErrorCorrupt if the data is corrupt. , or kKVPErrorOK if the operation was successful.

◆ setValue() [1/4]

flxKVPError_t flxKVPStorePage::setValue ( uint8_t  iNS,
const char *  szKey,
char *  value 
)
inline

◆ setValue() [2/4]

flxKVPError_t flxKVPStorePage::setValue ( uint8_t  iNS,
const char *  szKey,
const char *  value 
)
inline

◆ setValue() [3/4]

template<typename T >
flxKVPError_t flxKVPStorePage::setValue ( uint8_t  iNS,
const char *  szKey,
T &  value 
)
inline

◆ setValue() [4/4]

flxKVPError_t flxKVPStorePage::setValue ( uint8_t  iNS,
flxDataType_t  dType,
const char *  szKey,
const void *  value,
size_t  valueSize 
)

Sets the value of a key-value pair in the flash page.

Parameters
iNSThe namespace index.
dTypeThe data type of the value.
szKeyThe key.
valueA pointer to the value.
valueSizeThe size of the value.
Returns
The error code indicating the success or failure of the operation. kKVPErrorOK if successful

◆ setValueString()

flxKVPError_t flxKVPStorePage::setValueString ( uint8_t  iNS,
const char *  szKey,
const char *  value,
size_t  valueSize 
)

Sets the value of a key-value pair in the flxFPSPage.

Parameters
iNSThe namespace of the key-value pair.
szKeyThe key of the key-value pair.
valueThe value to be set.
valueSizeThe size of the value.
Returns
flxKVPError_t Returns kKVPErrorConfig if the storage is not initialized, kKVPErrorPageFull if the page is full, kKVPErrorIO if there was an I/O error and kKVPErrorOK if the operation was successful.

◆ status()

flxKVPPageStatus flxKVPStorePage::status ( )
inline

◆ updateEntry()

flxKVPError_t flxKVPStorePage::updateEntry ( uint32_t  index,
const flxKVPStoreEntry theEntry 
)

Updates an entry in the flash page.

This function updates the entry at the specified index with the provided entry data.

Parameters
indexThe index of the entry to be updated.
theEntryThe entry data to be written.
Returns
The error code indicating the status of the update operation.
  • kKVPErrorConfig: If there is no storage device available.
  • kKVPErrorInvalidIndex: If the provided index is invalid.
  • kKVPErrorIO: If there was an error during the write operation.
  • kKVPErrorOK: If the update operation was successful.

◆ writeEntry()

flxKVPError_t flxKVPStorePage::writeEntry ( const flxKVPStoreEntry theEntry)

Writes a flxFPSEntry to the storage device.

Parameters
[in]theEntryThe flxFPSEntry to be written.
Returns
flxKVPError_t The error code indicating the result of the write operation. Returns kKVPErrorConfig if the page has not been initialized, kKVPErrorPageFull if the page is full, or kKVPErrorIO if there was an I/O error.

Member Data Documentation

◆ kNEntriesPerPage

constexpr uint32_t flxKVPStorePage::kNEntriesPerPage = (kSectorSize / flxKVPStoreEntry::kEntrySize) - kNBookKeepingEntries
staticconstexpr

◆ kNoSector

constexpr uint32_t flxKVPStorePage::kNoSector = 0xFFFFFFFF
staticconstexpr

◆ kPageFull

constexpr uint32_t flxKVPStorePage::kPageFull = flxKVPPageStatus::kPageFull
staticconstexpr

◆ kPageInitialized

constexpr uint32_t flxKVPStorePage::kPageInitialized = flxKVPPageStatus::kPageAvailable
staticconstexpr

◆ kSectorSize

constexpr uint32_t flxKVPStorePage::kSectorSize = 4096
staticconstexpr

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