5 #ifndef HERALD_BLE_DEVICE_H
6 #define HERALD_BLE_DEVICE_H
8 #include "ble_tx_power.h"
9 #include "ble_mac_address.h"
10 #include "ble_sensor_configuration.h"
12 #include "../device.h"
14 #include "../datatype/payload_data.h"
15 #include "../datatype/payload_sharing_data.h"
16 #include "../datatype/immediate_send_data.h"
17 #include "../datatype/target_identifier.h"
18 #include "../datatype/time_interval.h"
19 #include "../datatype/date.h"
20 #include "../datatype/uuid.h"
21 #include "filter/ble_advert_parser.h"
32 using namespace herald::ble::filter;
34 class BLEDeviceDelegate;
36 enum class BLEDeviceAttribute : int {
37 peripheral, state, operatingSystem, payloadData, rssi, txPower, immediateSendData
40 enum class BLEDeviceOperatingSystem : int {
41 android_tbc, android, ios_tbc, ios, ignore, shared, unknown
45 enum class BLEDeviceState : int {
47 connecting, connected, disconnected
51 enum class BLEInternalState : short {
66 enum class BLELegacyService : short {
74 namespace SignalCharacteristicType {
75 constexpr
bool SpecCompliant =
true;
76 constexpr
bool NotSpecCompliant =
false;
87 BLEInternalState internalState()
const;
88 void internalState(BLEInternalState newInternalState);
90 BLEDeviceState state()
const;
91 void state(BLEDeviceState newState);
93 BLEDeviceOperatingSystem operatingSystem()
const;
94 void operatingSystem(BLEDeviceOperatingSystem newOS);
96 bool hasHeraldService()
const;
97 void hasHeraldService(
bool newValue);
98 bool hasLegacyService()
const;
99 BLELegacyService legacyService()
const;
100 void legacyService(BLELegacyService newValue);
101 bool hasPayloadCharacteristic()
const;
102 void hasPayloadCharacteristic(
bool newValue);
103 bool signalCharacteristic()
const;
104 void signalCharacteristic(
bool newValue);
105 bool hasSecureCharacteristic()
const;
106 void hasSecureCharacteristic(
bool newValue);
107 bool hasEverConnected()
const;
108 void hasEverConnected(
bool newValue);
113 std::bitset<16> bitFields;
133 std::vector<BLEAdvertSegment> segments;
136 using FilteredState = std::monostate;
154 ignoreForDuration(0),
157 connectRepeatedFailures(0),
168 unsigned short int connectRepeatedFailures;
197 bool operator==(
const BLEDevice& other)
const noexcept;
198 bool operator!=(
const BLEDevice& other)
const noexcept;
208 std::
string description() const;
209 operator
std::
string() const;
212 TimeInterval timeIntervalSinceLastUpdate() const override;
226 bool hasService(const
UUID& serviceUUID) const;
228 BLEDeviceState state() const;
229 void state(BLEDeviceState newState);
232 BLEDeviceOperatingSystem operatingSystem() const;
233 void operatingSystem(BLEDeviceOperatingSystem newOS);
236 void rssi(
RSSI newRSSI);
238 std::optional<BLETxPower> txPower() const;
239 void txPower(BLETxPower newPower);
251 TimeInterval timeIntervalSinceLastPayloadDataUpdate() const;
252 TimeInterval timeIntervalSinceLastWritePayloadSharing() const;
257 std::optional<
UUID> signalCharacteristic() const;
258 void signalCharacteristic(
UUID newChar);
260 std::optional<
UUID> payloadCharacteristic() const;
261 void payloadCharacteristic(
UUID newChar);
275 void ignore(
bool newIgnore);
276 void invalidateCharacteristics();
277 void registerDiscovery(
Date at);
Generic abstraction of a particular local proximate device type.
Definition: device.h:27
Definition: ble_device_delegate.h:13
INTERNAL Herald class used to minimise the memory footprint with hundreds of devices nearby.
Definition: ble_device.h:80
Definition: ble_device.h:181
const BLESensorConfiguration & configuration() const noexcept
Returns the BLESensorConfiguration reference relating to this instance.
void reset(const TargetIdentifier &newID, BLEDeviceDelegate &newDelegate)
Resets the device to what it's state would be if just constructed. Allows re-use in fixed size contai...
Definition: ble_mac_address.h:18
Definition: payload_data.h:13
Definition: target_identifier.h:17
Definition: time_interval.h:19
Contains all low-level Herald datatype implementations.
Definition: base64_string.h:14
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15
Defines BLE sensor configuration data, e.g. service and characteristic UUIDs.
Definition: ble_sensor_configuration.h:23
Definition: ble_device.h:132
Definition: ble_device.h:151
Definition: ble_advert_types.h:55