Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
AssetFilterSyncer Class Reference

Class that takes care of synchronizing the asset filters between crownstones. More...

#include <cs_AssetFilterSyncer.h>

Inheritance diagram for AssetFilterSyncer:
Collaboration diagram for AssetFilterSyncer:

Public Member Functions

cs_ret_code_t init ()
 Init the class: More...
 
void handleEvent (event_t &evt)
 Internal usage. More...
 
- Public Member Functions inherited from EventListener
 EventListener ()
 
virtual ~EventListener ()
 unregisters the listener. More...
 
virtual void handleEvent (event_t &event)=0
 Handle events. More...
 
void listen ()
 Registers this with the EventDispatcher. More...
 
- Public Member Functions inherited from Component
template<class T >
T * getComponent (Component *requester=nullptr)
 Returns a component of type T* from _parent->children(), If not found try again with ancestors: _parent-> ... ->_parent->children(). More...
 
virtual cs_ret_code_t init ()
 Components can implement this if they need to get references to sibling or if they need to do specific initialization. More...
 
void parentAllChildren ()
 utility that loops over all elements of getChildren() and setParent on the non-nullptr ones. More...
 
virtual ~Component ()=default
 

Static Public Attributes

static constexpr uint16_t VERSION_BROADCAST_NORMAL_INTERVAL_SECONDS = 5 * 60
 Interval at which the master version is broadcasted. More...
 
static constexpr uint16_t VERSION_BROADCAST_LOW_INTERVAL_SECONDS = 1
 
static constexpr uint16_t VERSION_BROADCAST_INTERVAL_RESET_SECONDS = 60
 How long the low interval will be used after setting it to low interval. More...
 

Private Types

enum class  SyncStep {
  NONE , CONNECT , GET_FILTER_SUMMARIES , REMOVE_FILTERS ,
  UPLOAD_FILTERS , COMMIT , DISCONNECT
}
 Async steps that are taken when synchronizing filters to another crownstone. More...
 
enum class  VersionCompare { UNKOWN , OLDER , EQUAL , NEWER }
 Results of comparing master version with another crownstone. More...
 

Private Member Functions

void sendVersion (bool reliable)
 Sends the master version and CRC over the mesh. More...
 
void sendVersionAtLowInterval ()
 Send version at a low interval for some time. More...
 
void setStep (SyncStep step)
 Set the current step of the sync process. More...
 
void reset ()
 Abort the sync process. More...
 
VersionCompare compareToMyVersion (asset_filter_cmd_protocol_t protocol, uint16_t masterVersion, uint32_t masterCrc)
 Compare given master version with the master version of this crownstone. More...
 
void syncFilters (stone_id_t stoneId)
 Start updating filters of another crownstone. More...
 
void connect (stone_id_t stoneId)
 Steps of the sync process. More...
 
void removeNextFilter ()
 
void uploadNextFilter ()
 
void commit ()
 
void disconnect ()
 
void done ()
 When the whole sync process to a stone was successful, call done(). More...
 
cs_ret_code_t onVersion (stone_id_t stoneId, cs_mesh_model_msg_asset_filter_version_t &packet)
 Handle a received version mesh message. More...
 
void onModificationInProgress (bool inProgress)
 Handle a possible change of "filter modification in progress". More...
 
void onConnectResult (cs_ret_code_t retCode)
 Handle steps of the sync process. More...
 
void onDisconnect ()
 
void onWriteResult (cs_central_write_result_t &result)
 
void onFilterSummaries (cs_data_t &payload)
 
void onTick (uint32_t tickCount)
 Handle the tick event. More...
 

Private Attributes

AssetFilterStore_store = nullptr
 Pointer to the (intialized) filter store. More...
 
SyncStep _step = SyncStep::NONE
 Current step. More...
 
uint8_t _nextFilterIndex
 Next index of filter IDs to upload/remove array. More...
 
uint16_t _nextChunkIndex
 Next chunk index to upload. More...
 
uint8_t _filterIdsToUpload [AssetFilterStore::MAX_FILTER_IDS]
 Filter IDs that should be uploaded. More...
 
uint8_t _filterUploadCount
 
uint8_t _filterIdsToRemove [AssetFilterStore::MAX_FILTER_IDS]
 Filter IDs that should be removed. More...
 
uint8_t _filterRemoveCount
 
uint16_t _sendVersionAtLowIntervalCountdown = 0
 Countdown counter that keeps track when the send version interval should go back to normal again. More...
 
uint16_t _sendVersionCountdown = 0
 Countdown counter that keeps track when to call sendVersion again. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Component
virtual std::vector< Component * > getChildren ()
 Components with children can override this method to return them. More...
 
cs_ret_code_t initChildren ()
 
void setParent (Component *p)
 Children that are instantiated later can also be added individually. More...
 

Detailed Description

Class that takes care of synchronizing the asset filters between crownstones.

  • Regularly informs other crownstones of the master version and CRC.
  • Will connect and update the asset filters of a crownstone with an older master version.

Member Enumeration Documentation

◆ SyncStep

enum class AssetFilterSyncer::SyncStep
strongprivate

Async steps that are taken when synchronizing filters to another crownstone.

Enumerator
NONE 
CONNECT 
GET_FILTER_SUMMARIES 
REMOVE_FILTERS 
UPLOAD_FILTERS 
COMMIT 
DISCONNECT 

◆ VersionCompare

enum class AssetFilterSyncer::VersionCompare
strongprivate

Results of comparing master version with another crownstone.

Enumerator
UNKOWN 
OLDER 
EQUAL 
NEWER 

Member Function Documentation

◆ commit()

void AssetFilterSyncer::commit ( )
private

◆ compareToMyVersion()

VersionCompare AssetFilterSyncer::compareToMyVersion ( asset_filter_cmd_protocol_t  protocol,
uint16_t  masterVersion,
uint32_t  masterCrc 
)
private

Compare given master version with the master version of this crownstone.

◆ connect()

void AssetFilterSyncer::connect ( stone_id_t  stoneId)
private

Steps of the sync process.

◆ disconnect()

void AssetFilterSyncer::disconnect ( )
private

◆ done()

void AssetFilterSyncer::done ( )
private

When the whole sync process to a stone was successful, call done().

◆ handleEvent()

void AssetFilterSyncer::handleEvent ( event_t evt)
virtual

Internal usage.

Implements EventListener.

◆ init()

cs_ret_code_t AssetFilterSyncer::init ( )
virtual

Init the class:

  • Starts listening for events.

Reimplemented from Component.

◆ onConnectResult()

void AssetFilterSyncer::onConnectResult ( cs_ret_code_t  retCode)
private

Handle steps of the sync process.

◆ onDisconnect()

void AssetFilterSyncer::onDisconnect ( )
private

◆ onFilterSummaries()

void AssetFilterSyncer::onFilterSummaries ( cs_data_t payload)
private

◆ onModificationInProgress()

void AssetFilterSyncer::onModificationInProgress ( bool  inProgress)
private

Handle a possible change of "filter modification in progress".

◆ onTick()

void AssetFilterSyncer::onTick ( uint32_t  tickCount)
private

Handle the tick event.

◆ onVersion()

cs_ret_code_t AssetFilterSyncer::onVersion ( stone_id_t  stoneId,
cs_mesh_model_msg_asset_filter_version_t packet 
)
private

Handle a received version mesh message.

◆ onWriteResult()

void AssetFilterSyncer::onWriteResult ( cs_central_write_result_t result)
private

◆ removeNextFilter()

void AssetFilterSyncer::removeNextFilter ( )
private

◆ reset()

void AssetFilterSyncer::reset ( )
private

Abort the sync process.

◆ sendVersion()

void AssetFilterSyncer::sendVersion ( bool  reliable)
private

Sends the master version and CRC over the mesh.

◆ sendVersionAtLowInterval()

void AssetFilterSyncer::sendVersionAtLowInterval ( )
private

Send version at a low interval for some time.

◆ setStep()

void AssetFilterSyncer::setStep ( SyncStep  step)
private

Set the current step of the sync process.

◆ syncFilters()

void AssetFilterSyncer::syncFilters ( stone_id_t  stoneId)
private

Start updating filters of another crownstone.

◆ uploadNextFilter()

void AssetFilterSyncer::uploadNextFilter ( )
private

Member Data Documentation

◆ _filterIdsToRemove

uint8_t AssetFilterSyncer::_filterIdsToRemove[AssetFilterStore::MAX_FILTER_IDS]
private

Filter IDs that should be removed.

◆ _filterIdsToUpload

uint8_t AssetFilterSyncer::_filterIdsToUpload[AssetFilterStore::MAX_FILTER_IDS]
private

Filter IDs that should be uploaded.

◆ _filterRemoveCount

uint8_t AssetFilterSyncer::_filterRemoveCount
private

◆ _filterUploadCount

uint8_t AssetFilterSyncer::_filterUploadCount
private

◆ _nextChunkIndex

uint16_t AssetFilterSyncer::_nextChunkIndex
private

Next chunk index to upload.

◆ _nextFilterIndex

uint8_t AssetFilterSyncer::_nextFilterIndex
private

Next index of filter IDs to upload/remove array.

◆ _sendVersionAtLowIntervalCountdown

uint16_t AssetFilterSyncer::_sendVersionAtLowIntervalCountdown = 0
private

Countdown counter that keeps track when the send version interval should go back to normal again.

◆ _sendVersionCountdown

uint16_t AssetFilterSyncer::_sendVersionCountdown = 0
private

Countdown counter that keeps track when to call sendVersion again.

◆ _step

SyncStep AssetFilterSyncer::_step = SyncStep::NONE
private

Current step.

◆ _store

AssetFilterStore* AssetFilterSyncer::_store = nullptr
private

Pointer to the (intialized) filter store.

◆ VERSION_BROADCAST_INTERVAL_RESET_SECONDS

constexpr uint16_t AssetFilterSyncer::VERSION_BROADCAST_INTERVAL_RESET_SECONDS = 60
staticconstexpr

How long the low interval will be used after setting it to low interval.

◆ VERSION_BROADCAST_LOW_INTERVAL_SECONDS

constexpr uint16_t AssetFilterSyncer::VERSION_BROADCAST_LOW_INTERVAL_SECONDS = 1
staticconstexpr

◆ VERSION_BROADCAST_NORMAL_INTERVAL_SECONDS

constexpr uint16_t AssetFilterSyncer::VERSION_BROADCAST_NORMAL_INTERVAL_SECONDS = 5 * 60
staticconstexpr

Interval at which the master version is broadcasted.


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