Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
AssetForwarder makes it possible for the AssetFiltering to merge mesh messages when they have very similar data. More...
#include <cs_AssetForwarder.h>
Classes | |
struct | outbox_msg_t |
Public Member Functions | |
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 | flush () |
Sends the mesh messages in the outbox and clears it. More... | |
void | clearOutbox () |
Removes all messages currently queued for sending. More... | |
bool | sendAssetMacToMesh (asset_record_t *record, const scanned_device_t &asset) |
Prepare a CS_MESH_MODEL_TYPE_ASSET_RSSI_MAC message and put it on the outbox. More... | |
bool | sendAssetIdToMesh (asset_record_t *record, const scanned_device_t &asset, const asset_id_t &assetId, uint8_t filterBitmask) |
Prepare a CS_MESH_MODEL_TYPE_ASSET_INFO message and put it on the outbox. More... | |
void | setThrottleCountdownBumpTicks (uint8_t ticks) |
sets how many ticks will be added to records upon sending a message. More... | |
virtual void | handleEvent (event_t &event) |
Forwards relevant incoming mesh messages to UART. More... | |
![]() | |
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... | |
![]() | |
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 | MIN_THROTTLED_ADVERTISEMENT_PERIOD_MS = 1000 |
Private Member Functions | |
bool | dispatchOutboxMessage (outbox_msg_t &outMsg) |
validates the message, then update throttle send over uart send over mesh More... | |
outbox_msg_t * | getEmptyOutboxSlot () |
Returns an empty slot in the outbox. More... | |
outbox_msg_t * | findSimilar (outbox_msg_t &outMsg) |
Returns a similar message in the outbox. More... | |
bool | addToOutbox (outbox_msg_t &outMsg) |
Adds a message to the outbox. More... | |
void | forwardAssetToUart (const cs_mesh_model_msg_asset_report_mac_t &assetMsg, stone_id_t seenByStoneId) |
Forward an asset mesh message to UART. More... | |
void | forwardAssetToUart (const cs_mesh_model_msg_asset_report_id_t &assetMsg, stone_id_t seenByStoneId) |
Private Attributes | |
stone_id_t | _myStoneId |
uint8_t | _throttleCountdownBumpTicks = 0 |
outbox_msg_t | _outbox [8] = {} |
Additional Inherited Members | |
![]() | |
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... | |
AssetForwarder makes it possible for the AssetFiltering to merge mesh messages when they have very similar data.
To use it, you place messages in the 'outbox' with sendAssetMacToMesh(..) or sendAssetIdToMesh(..). These functions merge the message with a similar one depending on the respective type.
After all messages have been created, call flush() to send the message, or clearOutbox() to cancel your plans.
By passing an asset_record along the flush() function will update the throttling counter.
|
private |
Adds a message to the outbox.
Merges wit message in outbox if possible. Returns true on success.
void AssetForwarder::clearOutbox | ( | ) |
Removes all messages currently queued for sending.
|
private |
validates the message, then update throttle send over uart send over mesh
returns true if message was valid
|
private |
Returns a similar message in the outbox.
Returns null pointer when not found.
void AssetForwarder::flush | ( | ) |
Sends the mesh messages in the outbox and clears it.
Updates the records throttling counters.
Messages are sent over both Uart and Mesh
|
private |
|
private |
Forward an asset mesh message to UART.
[in] | assetMsg | The mesh message to forward. |
[in] | seenByStoneId | The stone that scanned the asset. |
|
private |
Returns an empty slot in the outbox.
Returns null pointer when there is no empty slot.
|
virtual |
Forwards relevant incoming mesh messages to UART.
Implements EventListener.
|
virtual |
Components can implement this if they need to get references to sibling or if they need to do specific initialization.
E.g.
class componentX : public Component { public: cs_ret_code_t init() { // construct childA ... // construct childZ
return initChildren(); } };
Reimplemented from Component.
bool AssetForwarder::sendAssetIdToMesh | ( | asset_record_t * | record, |
const scanned_device_t & | asset, | ||
const asset_id_t & | assetId, | ||
uint8_t | filterBitmask | ||
) |
Prepare a CS_MESH_MODEL_TYPE_ASSET_INFO message and put it on the outbox.
If an identical message is already contained in the outbox, nothing happens.
Returns true if there was enough space in the outbox to place the message. Else, false.
bool AssetForwarder::sendAssetMacToMesh | ( | asset_record_t * | record, |
const scanned_device_t & | asset | ||
) |
Prepare a CS_MESH_MODEL_TYPE_ASSET_RSSI_MAC message and put it on the outbox.
If an identical message is already contained in the outbox, nothing happens.
Record is required for throttling. If not available, throttling will not be updated.
Returns true if there was enough space in the outbox to place the message. Else, false.
void AssetForwarder::setThrottleCountdownBumpTicks | ( | uint8_t | ticks | ) |
sets how many ticks will be added to records upon sending a message.
|
private |
|
private |
|
private |
|
staticconstexpr |