11#include <components/libraries/fds/fds.h>
Class to store items persistently in flash (persistent) memory.
Definition: cs_Storage.h:57
CS_TYPE _currentSearchType
Definition: cs_Storage.h:302
cs_storage_error_callback_t _errorCallback
Definition: cs_Storage.h:299
ret_code_t writeInternal(const cs_state_data_t &data)
Write to persistent storage.
cs_ret_code_t readNext(cs_state_data_t &data)
Find and read next stored value of given type.
uint32_t _eraseEndPage
Page that should not be erased.
Definition: cs_Storage.h:317
cs_ret_code_t factoryReset()
Perform factory reset.
void handleRemoveRecordEvent(fds_evt_t const *p_fds_evt)
bool _initialized
Definition: cs_Storage.h:297
cs_ret_code_t readNextInternal(uint16_t recordKey, uint16_t &fileId, uint8_t *buf, uint16_t size)
Read next fileId for given recordKey.
void handleWriteEvent(fds_evt_t const *p_fds_evt)
static Storage & getInstance()
Returns the singleton instance of this class.
Definition: cs_Storage.h:64
cs_ret_code_t readRecord(fds_record_desc_t recordDesc, uint8_t *buf, uint16_t size, uint16_t &fileId)
Read a record: copy data to buffer, and sets fileId.
bool _collectingGarbage
Definition: cs_Storage.h:304
cs_ret_code_t remove(CS_TYPE type, cs_state_id_t id)
Remove value of given type and id.
bool _removingFile
Definition: cs_Storage.h:305
cs_ret_code_t write(const cs_state_data_t &data)
Write to persistent storage.
uint32_t _erasePage
Next page to erase.
Definition: cs_Storage.h:312
std::vector< uint16_t > _busyRecordKeys
Definition: cs_Storage.h:307
void setErrorCallback(cs_storage_error_callback_t callback)
Set the callback for errors.
cs_ret_code_t continueFactoryReset()
Continue the factory reset process.
void clearBusy(uint16_t recordKey)
void handleRemoveFileEvent(fds_evt_t const *p_fds_evt)
cs_state_id_t getStateId(uint16_t fileId)
Get state value id, given file id.
fds_find_token_t _findToken
Definition: cs_Storage.h:301
cs_ret_code_t garbageCollect()
Garbage collection reclaims the flash space that is occupied by records that have been deleted,...
cs_ret_code_t findNextInternal(uint16_t recordKey, uint16_t &fileId)
Find next fileId for given recordKey.
cs_ret_code_t read(cs_state_data_t &data)
Find and read stored value of given type and id.
cs_ret_code_t readFirst(cs_state_data_t &data)
Find and read from first stored value of given type.
ret_code_t exists(cs_file_id_t file_id, uint16_t recordKey, fds_record_desc_t &record_desc, bool &result)
Check if a type of record exists and return the record descriptor.
uint16_t getFileId(cs_state_id_t valueId)
Get file id, given state value id.
uint8_t * allocate(size16_t &size)
Allocate ram that is correctly aligned and padded.
void handleGarbageCollectionEvent(fds_evt_t const *p_fds_evt)
bool isInitialized()
Definition: cs_Storage.h:71
cs_ret_code_t remove(CS_TYPE type)
Remove all values of a type.
void setBusy(uint16_t recordKey)
cs_ret_code_t readV3ResetCounter(cs_state_data_t &data)
Read the old (v3) reset counter.
bool isValidFileId(uint16_t fileId)
void initSearch(CS_TYPE type)
Start a new search, where the user wants to iterate over a certain type.
bool isBusy(uint16_t recordKey)
cs_ret_code_t findFirst(CS_TYPE type, cs_state_id_t &id)
Find first id of stored values of given type.
void handleFileStorageEvent(fds_evt_t const *p_fds_evt)
Handle FDS events.
CS_TYPE _eraseDoneEvent
Definition: cs_Storage.h:319
void operator=(Storage const &)=delete
cs_ret_code_t eraseAllPages()
Erase all flash pages used by FDS.
cs_ret_code_t erasePages(const CS_TYPE doneEvent, void *startAddress, void *endAddress)
Erase flash pages.
bool _registeredFds
Definition: cs_Storage.h:298
void handleFlashOperationSuccess()
Handle FDS SOC event NRF_EVT_FLASH_OPERATION_SUCCESS.
bool _performingFactoryReset
Definition: cs_Storage.h:306
cs_ret_code_t remove(cs_state_id_t id)
Remove all values with given id.
ret_code_t garbageCollectInternal()
void handleFlashOperationError()
Handle FDS SOC event NRF_EVT_FLASH_OPERATION_ERROR.
Storage(Storage const &)=delete
void initSearch()
Start a new search.
cs_ret_code_t getErrorCode(ret_code_t code)
cs_ret_code_t findNext(CS_TYPE type, cs_state_id_t &id)
Find next id of stored values of given type.
size16_t getPaddedSize(size16_t size)
Returns size after padding for flash.
bool isValidRecordKey(uint16_t recordKey)
void eraseNextPage()
Erase next page, started via eraseAllPages().
Definition: cs_TestAccess.h:11
uint32_t ret_code_t
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Apr.
Definition: cs_Nordic.h:14
void(* cs_storage_error_callback_t)(cs_storage_operation_t operation, CS_TYPE type, cs_state_id_t id)
Definition: cs_Storage.h:26
cs_storage_operation_t
Definition: cs_Storage.h:18
@ CS_STORAGE_OP_GC
Definition: cs_Storage.h:23
@ CS_STORAGE_OP_REMOVE
Definition: cs_Storage.h:21
@ CS_STORAGE_OP_WRITE
Definition: cs_Storage.h:20
@ CS_STORAGE_OP_READ
Definition: cs_Storage.h:19
@ CS_STORAGE_OP_REMOVE_ALL_VALUES_WITH_ID
Definition: cs_Storage.h:22
uint16_t size16_t
Definition: cs_Typedefs.h:25
uint8_t cs_state_id_t
Definition: cs_Typedefs.h:28
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
CS_TYPE
Types:
Definition: cs_Types.h:79
uint16_t cs_file_id_t
Definition: cs_Types.h:458
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_StateData.h:22