Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_NearestCrownstoneTracker.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Nov 17, 2020
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
10#include <common/cs_Component.h>
18
33 static constexpr uint8_t LAST_RECEIVED_TIMEOUT_THRESHOLD = 180;
34 static constexpr uint16_t MIN_THROTTLED_ADVERTISEMENT_PERIOD_MS = 100;
35
36 static constexpr uint8_t RSSI_FALL_OFF_RATE_DB_PER_S = 1;
37 static constexpr int8_t RSSI_CUT_OFF_THRESHOLD = -90;
38
40
42
43public:
48 cs_ret_code_t init() override;
49
54 bool handleAcceptedAsset(const scanned_device_t& asset, const asset_id_t& id, uint8_t filterBitmask);
55
56private:
57 // cached objects for efficiency
60
61 // -------------------------------------------
62 // ------------- Incoming events -------------
63 // -------------------------------------------
64
71
78
91
105
106 // -------------------------------------------
107 // ------------- Outgoing events -------------
108 // -------------------------------------------
109
115
121
127
131 void onWinnerChanged(bool winnerIsThisCrownstone);
132
133 // ---------------------------------
134 // ------------- Utils -------------
135 // ---------------------------------
136
141
149
150public:
157};
Definition: cs_AssetStore.h:15
Helper class to manage decoupling of components.
Definition: cs_Component.h:35
Event listener.
Definition: cs_EventListener.h:17
This class implements the in-mesh computation of which crownstone is nearest to a 'trackable' device.
Definition: cs_NearestCrownstoneTracker.h:32
static constexpr uint8_t LAST_RECEIVED_TIMEOUT_THRESHOLD
Definition: cs_NearestCrownstoneTracker.h:33
void saveWinningReport(asset_record_t &rec, rssi_and_channel_t winningRssi, stone_id_t winningId)
saves the report in the _winning list.
void broadcastPersonalReport(asset_record_t &record)
makes a report from the records personalRssi field and broadcast it over the mesh.
static constexpr auto FILTER_STRATEGY
Definition: cs_NearestCrownstoneTracker.h:41
bool onReceiveAssetAdvertisement(cs_mesh_model_msg_asset_report_id_t &trackedEvent)
Heart of the algorithm.
void broadcastReport(cs_mesh_model_msg_asset_report_id_t &report)
Sends a mesh broadcast for the given report.
stone_id_t _myStoneId
Definition: cs_NearestCrownstoneTracker.h:58
static constexpr uint16_t MIN_THROTTLED_ADVERTISEMENT_PERIOD_MS
Definition: cs_NearestCrownstoneTracker.h:34
static constexpr int8_t RSSI_CUT_OFF_THRESHOLD
Definition: cs_NearestCrownstoneTracker.h:37
AssetStore * _assetStore
Definition: cs_NearestCrownstoneTracker.h:59
void handleMeshMsgEvent(event_t &evt)
Called on EVT_RECV_MESH_MSG events.
asset_record_t * getRecordFiltered(const asset_id_t &assetId)
getRecord for assetId from assetStore and return it.
void onWinnerChanged(bool winnerIsThisCrownstone)
(Only logs a message)
void handleEvent(event_t &evt)
Handlers for: EVT_ASSET_ACCEPTED EVT_FILTERS_UPDATED.
static constexpr uint8_t RSSI_FALL_OFF_RATE_DB_PER_S
Definition: cs_NearestCrownstoneTracker.h:36
FilterStrategy
Definition: cs_NearestCrownstoneTracker.h:39
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 chang...
void onReceiveAssetReport(cs_mesh_model_msg_asset_report_id_t &report, stone_id_t reporter)
Heart of the algorithm.
void handleAssetAcceptedEvent(event_t &evt)
Called on EVT_ASSET_ACCEPTED events.
void sendUartUpdate(asset_record_t &record)
Sends a message over UART containing the winner, its rssi and the asset id.
cs_ret_code_t init() override
Caches CONFIG_CROWNSTONE_ID and AssetStore.
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
uint8_t stone_id_t
Definition: cs_Typedefs.h:23
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
Definition: cs_AssetFilterPackets.h:93
Definition: cs_AssetRecord.h:12
Definition: cs_MeshModelPackets.h:236
Definition: cs_RssiAndChannel.h:63
Scanned device.
Definition: cs_PacketsInternal.h:107