Keeps up the asset filters.
Definition: cs_AssetFilterStore.h:26
void handleGetFilterSummariesCommand(cs_result_t &result)
Writes the filter summary in the result.
CS_TYPE getNthStateType(uint8_t index)
Used to loop over all asset filter state types.
bool validateFilters()
Checks for all filters if the allocated filter data size is equal to the computed size based on its c...
CS_TYPE getStateType(uint16_t filterDataSize)
Get the State type, given the filter data size.
uint8_t * allocateFilter(uint8_t filterId, size_t stateDataSize)
Allocates RAM for a filter of given size, and adds it to the filters array.
uint32_t _masterCrc
CRC over all the filter IDs and CRCs.
Definition: cs_AssetFilterStore.h:116
bool deallocateFilter(uint8_t filterId)
Same as deallocateFilterByIndex, but looks up the filter by the filterId.
uint32_t getMasterCrc()
Get the current master CRC.
std::optional< uint8_t > findFilterIndex(uint8_t filterId)
Returns the index of the filter with given filterId, if any.
void handleEvent(event_t &evt)
Internal usage.
uint8_t _filtersCount
Number of allocated filters in the filters array.
Definition: cs_AssetFilterStore.h:103
uint16_t _masterVersion
Keeps track of the version of the filters.
Definition: cs_AssetFilterStore.h:109
void computeFilterCrcs()
Computes the CRC of the filters, and sets it in the filter.
uint32_t computeMasterCrc()
Calculate the master CRC and return it (not stored).
void startInProgress()
To be called when about to modify filters.
cs_ret_code_t handleUploadFilterCommand(const asset_filter_cmd_upload_filter_t &cmdData)
Handle an upload command.
uint8_t getFilterCount()
Get the number of filters.
AssetFilter getFilter(uint8_t index)
Get the Nth filter.
cs_ret_code_t init()
set _filterModificationInProgress to false.
uint16_t getMasterVersion()
Get the current master version.
static constexpr uint8_t MAX_FILTER_IDS
Max number of filters.
Definition: cs_AssetFilterStore.h:75
cs_ret_code_t handleCommitFilterChangesCommand(const asset_filter_cmd_commit_filter_changes_t &cmdData)
Commit the filters.
cs_ret_code_t handleRemoveFilterCommand(const asset_filter_cmd_remove_filter_t &cmdData)
Removes given filter immediately.
void loadFromFlash(CS_TYPE type)
Load filters of a specific type (size) from flash.
bool isInProgress()
Whether changes are in progress.
void sendInProgressStatus()
Send an internal event when isInProgress() may have changed.
cs_ret_code_t commit(uint16_t masterVersion, uint32_t masterCrc, bool store)
Commit current filters.
void deallocateFilterByIndex(uint8_t parsingFilterIndex)
Deallocates the filter at given index in the filters array.
size_t getTotalHeapAllocatedSize()
Returns the total amount of heap allocated for the filters.
static constexpr size_t FILTER_BUFFER_SIZE
Max total size that the filters take up in RAM.
Definition: cs_AssetFilterStore.h:82
uint16_t getStateSize(uint16_t filterDataSize)
Get the size required for State, given the filter data size.
void inProgressTimeout()
Called when the modification in progress is timed out.
uint8_t * findFilter(uint8_t filterId)
Returns a pointer to the filter with given filterId, or nullptr if not found.
uint8_t * _filters[MAX_FILTER_IDS]
List of pointers to the allocated buffers for the filters.
Definition: cs_AssetFilterStore.h:98
void endInProgress(uint16_t newMasterVersion, uint32_t newMasterCrc)
To be called when filters are no longer being modified.
void loadFromFlash()
Load filters and version from flash.
static constexpr int MODIFICATION_IN_PROGRESS_TIMEOUT_SECONDS
Time after last edit command (upload, remove), until "modification in progress" times out.
Definition: cs_AssetFilterStore.h:87
uint16_t _modificationInProgressCountdown
When this value is not 0, the filters are being modified.
Definition: cs_AssetFilterStore.h:123
void markFiltersCommitted()
Sets flags.committed to true.
bool isReady()
Returns true if this object is ready to be used.
void storeFilters()
Store filters to flash.
Class that contains all data required for an asset filter:
Definition: cs_AssetFilter.h:19
Helper class to manage decoupling of components.
Definition: cs_Component.h:35
Event listener.
Definition: cs_EventListener.h:17
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
CS_TYPE
Types:
Definition: cs_Types.h:79
Definition: cs_AssetFilterPackets.h:34
Definition: cs_AssetFilterPackets.h:29
Definition: cs_AssetFilterPackets.h:20
Definition: cs_PacketsInternal.h:46