Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
This class implements the in-mesh computation of which crownstone is nearest to a 'trackable' device. More...
#include <cs_NearestCrownstoneTracker.h>
Public Member Functions | |
cs_ret_code_t | init () override |
Caches CONFIG_CROWNSTONE_ID and AssetStore. More... | |
bool | handleAcceptedAsset (const scanned_device_t &asset, const asset_id_t &id, uint8_t filterBitmask) |
Returns true if it is desired to send a message to inform other devices in the mesh of relevant changes. More... | |
void | handleEvent (event_t &evt) |
Handlers for: EVT_ASSET_ACCEPTED EVT_FILTERS_UPDATED. 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 |
Private Types | |
enum class | FilterStrategy { TIME_OUT , RSSI_FALL_OFF } |
Private Member Functions | |
void | handleMeshMsgEvent (event_t &evt) |
Called on EVT_RECV_MESH_MSG events. More... | |
void | handleAssetAcceptedEvent (event_t &evt) |
Called on EVT_ASSET_ACCEPTED events. More... | |
bool | onReceiveAssetAdvertisement (cs_mesh_model_msg_asset_report_id_t &trackedEvent) |
Heart of the algorithm. More... | |
void | onReceiveAssetReport (cs_mesh_model_msg_asset_report_id_t &report, stone_id_t reporter) |
Heart of the algorithm. More... | |
void | broadcastReport (cs_mesh_model_msg_asset_report_id_t &report) |
Sends a mesh broadcast for the given report. More... | |
void | broadcastPersonalReport (asset_record_t &record) |
makes a report from the records personalRssi field and broadcast it over the mesh. More... | |
void | sendUartUpdate (asset_record_t &record) |
Sends a message over UART containing the winner, its rssi and the asset id. More... | |
void | onWinnerChanged (bool winnerIsThisCrownstone) |
(Only logs a message) More... | |
void | saveWinningReport (asset_record_t &rec, rssi_and_channel_t winningRssi, stone_id_t winningId) |
saves the report in the _winning list. More... | |
asset_record_t * | getRecordFiltered (const asset_id_t &assetId) |
getRecord for assetId from assetStore and return it. More... | |
Private Attributes | |
stone_id_t | _myStoneId |
AssetStore * | _assetStore |
Static Private Attributes | |
static constexpr uint8_t | LAST_RECEIVED_TIMEOUT_THRESHOLD = 180 |
static constexpr uint16_t | MIN_THROTTLED_ADVERTISEMENT_PERIOD_MS = 100 |
static constexpr uint8_t | RSSI_FALL_OFF_RATE_DB_PER_S = 1 |
static constexpr int8_t | RSSI_CUT_OFF_THRESHOLD = -90 |
static constexpr auto | FILTER_STRATEGY = FilterStrategy::TIME_OUT |
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... | |
This class implements the in-mesh computation of which crownstone is nearest to a 'trackable' device.
When a trackable device broadcasts an advertisement, and the TrackableParser consequently dispatches a TrackableEvent, it is this class that performs the necessary communication and computation to decide whether or not this crownstone is closest to the trackable device.
It is possible to enable this component on a subset of the crownstones in a mesh if necessary (for optimization purposes perhaps). When doing that, the resulting nearest crownstone will be an element of this subset.
|
strongprivate |
|
private |
makes a report from the records personalRssi field and broadcast it over the mesh.
|
private |
Sends a mesh broadcast for the given report.
(stone id of reporter is contained in bluetooth metadata)
|
private |
getRecord for assetId from assetStore and return it.
return nullptr if rec->lastReceivedCounter is above threshold.
this
must be init()-ialized.
bool NearestCrownstoneTracker::handleAcceptedAsset | ( | const scanned_device_t & | asset, |
const asset_id_t & | id, | ||
uint8_t | filterBitmask | ||
) |
Returns true if it is desired to send a message to inform other devices in the mesh of relevant changes.
|
private |
Called on EVT_ASSET_ACCEPTED events.
Transforms an accepted asset event into a report and handles it by calling onReceivedAssetAdvertisement.
|
virtual |
Handlers for: EVT_ASSET_ACCEPTED EVT_FILTERS_UPDATED.
Implements EventListener.
|
private |
Called on EVT_RECV_MESH_MSG events.
Extract report from other crownstones that come in from the mesh and call onReceiveAssetReport.
|
overridevirtual |
Caches CONFIG_CROWNSTONE_ID and AssetStore.
If assetstore is not available, ERR_NOT_FOUND is returned.
Reimplemented from Component.
|
private |
Heart of the algorithm.
See implementation for exact behaviour.
This method implements what a crownstone needs to communicate when it directly receives an advertisement from a trackable device.
Updates personal report, possibly updates winning report.
Returns true if it is desired to send a message to inform other devices in the mesh of relevant changes.
|
private |
Heart of the algorithm.
See implementation for exact behaviour.
This method implements what a crownstone needs to communicate when it receives a message from another crownstone containing information about a trackable device.
Possibly updates winning report and possibly broadcasts a message to inform other devices in the mesh of relevant changes. E.g. when the updated winning report now loses from this devices personal report.
|
private |
(Only logs a message)
|
private |
saves the report in the _winning list.
|
private |
Sends a message over UART containing the winner, its rssi and the asset id.
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |