|
Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Class that toggles the switch when a device, like a phone, is held close to the Crownstone. More...
#include <cs_TapToToggle.h>


Public Member Functions | |
| void | init (int8_t rssiThreshold) |
| void | handleEvent (event_t &event) |
| Handle events. 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... | |
Static Public Member Functions | |
| static TapToToggle & | getInstance () |
Private Member Functions | |
| TYPIFY (CONFIG_TAP_TO_TOGGLE_ENABLED) enabled | |
| Whether tap to toggle is enabled on this crownstone. More... | |
| TapToToggle () | |
| void | handleBackgroundAdvertisement (adv_background_parsed_t *adv) |
| Handle background advertisement. More... | |
| void | tick () |
| Decrease score of each MAC address. More... | |
Private Attributes | |
| t2t_entry_t | list [T2T_LIST_COUNT] |
| uint16_t | timeoutCounter = 0 |
| Used to count down the timeout. More... | |
| int8_t | rssiThreshold = 0 |
| RSSI threshold, above which score will be added. More... | |
| int8_t | defaultRssiThreshold = 0 |
| Default RSSI threshold for this board. More... | |
| uint8_t | scoreIncrement = T2T_SCORE_INC |
| Score is increased with this value when rssi is above rssi threshold. More... | |
| uint8_t | scoreThreshold = T2T_SCORE_THRESHOLD |
| Threshold above which the toggle is triggered. More... | |
| uint8_t | scoreMax = T2T_SCORE_MAX |
| Score can't be higher than this value. More... | |
| uint8_t | timeoutTicks = (T2T_TIMEOUT_MS / TICK_INTERVAL_MS) |
| Minimal time in ticks between 2 tap to toggle events. More... | |
Class that toggles the switch when a device, like a phone, is held close to the Crownstone.
Receives data from event EVT_ADV_BACKGROUND_PARSED. Checks if tap to toggle is enabled in that data. Determines whether a device is considered to be close. Implemented as a leaking bucket:
|
private |
|
inlinestatic |
|
private |
Handle background advertisement.
Checks if RSSI is above threshold. Checks if tap to toggle is enabled in the background advertisement. Checks if timeout is active. Adds to score. Triggers toggle.
|
virtual |
Handle events.
This method is overloaded by all classes that derive from EventListener. They can receive an event_t struct and act upon it. These events are dispatched by the EventDispatcher.
Implements EventListener.
| void TapToToggle::init | ( | int8_t | rssiThreshold | ) |
|
private |
Decrease score of each MAC address.
|
private |
Whether tap to toggle is enabled on this crownstone.
|
private |
Default RSSI threshold for this board.
|
private |
|
private |
RSSI threshold, above which score will be added.
|
private |
Score is increased with this value when rssi is above rssi threshold.
|
private |
Score can't be higher than this value.
|
private |
Threshold above which the toggle is triggered.
|
private |
Used to count down the timeout.
|
private |
Minimal time in ticks between 2 tap to toggle events.