D:\git\skunkworks\herald-for-cpp\herald\include\herald\ble\filter\ble_advert_types.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2020-2021 Herald Project Contributors |
2 | | // SPDX-License-Identifier: Apache-2.0 |
3 | | // |
4 | | |
5 | | #ifndef HERALD_BLE_ADVERT_TYPES_H |
6 | | #define HERALD_BLE_ADVERT_TYPES_H |
7 | | |
8 | | #include "../../datatype/data.h" |
9 | | |
10 | | #include <vector> |
11 | | // #include <string> |
12 | | // #include <cstdint> |
13 | | |
14 | | namespace herald { |
15 | | namespace ble { |
16 | | namespace filter { |
17 | | |
18 | | using namespace herald::datatype; |
19 | | |
20 | | // high level types |
21 | | |
22 | | // We use the below to convert BLEAdvertSegmentType to int |
23 | | // (or indeed any enum class to any base class) |
24 | | template <typename T> |
25 | 2 | constexpr auto to_integral(T e) { return static_cast<std::underlying_type_t<T>>(e); } ??$to_integral@W4BLEAdvertManufacturers@filter@ble@herald@@@filter@ble@herald@@YA?A?<auto>@@W4BLEAdvertManufacturers@012@@Z Line | Count | Source | 25 | 2 | constexpr auto to_integral(T e) { return static_cast<std::underlying_type_t<T>>(e); } |
Unexecuted instantiation: ??$to_integral@W4BLEAdvertSegmentType@filter@ble@herald@@@filter@ble@herald@@YA?A?<auto>@@W4BLEAdvertSegmentType@012@@Z |
26 | | |
27 | | /// BLE Advert types - Note: We only list those we use in Herald for some reason |
28 | | /// See https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/ |
29 | | enum class BLEAdvertSegmentType : int { |
30 | | unknown = 0x00, // Valid - this number is not assigned |
31 | | flags = 0x01, |
32 | | serviceUUID16IncompleteList = 0x02, |
33 | | serviceUUID16CompleteList = 0x03, |
34 | | serviceUUID32IncompleteList = 0x04, |
35 | | serviceUUID32CompleteList = 0x05, |
36 | | serviceUUID128IncompleteList = 0x06, |
37 | | serviceUUID128CompleteList = 0x07, |
38 | | deviceNameShortened = 0x08, |
39 | | deviceNameComplete = 0x09, |
40 | | txPowerLevel = 0x0A, |
41 | | deviceClass = 0x0D, |
42 | | simplePairingHash = 0x0E, |
43 | | simplePairingRandomiser = 0x0F, |
44 | | deviceID = 0x10, |
45 | | meshMessage = 0x2A, |
46 | | meshBeacon = 0x2B, |
47 | | bigInfo = 0x2C, |
48 | | broadcastCode = 0x2D, |
49 | | manufacturerData = 0xFF |
50 | | }; |
51 | | |
52 | | BLEAdvertSegmentType typeFor(int code); |
53 | | // BLEAdvertSegmentType typeFor(const std::string& name); |
54 | | |
55 | | struct BLEAdvertSegment { |
56 | | BLEAdvertSegmentType type; |
57 | | Data data; |
58 | 6 | BLEAdvertSegment(BLEAdvertSegmentType t,Data&& d) : type(t), data(d) {}; |
59 | 6 | BLEAdvertSegment(const BLEAdvertSegment&) = default; |
60 | 0 | BLEAdvertSegment(BLEAdvertSegment&&) = default; |
61 | 0 | BLEAdvertSegment& operator=(const BLEAdvertSegment&) = default; |
62 | | BLEAdvertSegment& operator=(BLEAdvertSegment&&) = default; |
63 | | }; |
64 | | |
65 | | struct BLEScanResponseData { |
66 | | std::size_t dataLength; |
67 | | std::vector<BLEAdvertSegment> segments; |
68 | | BLEScanResponseData(std::size_t dl, std::vector<BLEAdvertSegment>&& segs) : |
69 | 0 | dataLength(dl), segments(segs) {}; |
70 | | BLEScanResponseData(const BLEScanResponseData&) = default; |
71 | | BLEScanResponseData(BLEScanResponseData&&) = default; |
72 | | }; |
73 | | |
74 | | enum class BLEAdvertManufacturers : uint16_t { |
75 | | // NOTE: Little endian actual values at this point |
76 | | apple = 0x004c, // TODO patch the Android extractAppleManuSegment function too |
77 | | heraldUnregistered = 0xfaff |
78 | | }; |
79 | | |
80 | | // low level types |
81 | | struct BLEAdvertManufacturerData { |
82 | | std::uint16_t manufacturer; |
83 | | Data data; |
84 | 2 | BLEAdvertManufacturerData(std::uint16_t code, Data&& d) : manufacturer(code), data(d) {}; |
85 | 2 | BLEAdvertManufacturerData(const BLEAdvertManufacturerData&) = default; |
86 | 0 | BLEAdvertManufacturerData(BLEAdvertManufacturerData&&) = default; |
87 | | }; |
88 | | |
89 | | struct BLEAdvertAppleManufacturerSegment { |
90 | | std::uint8_t type; |
91 | | Data data; |
92 | 1 | BLEAdvertAppleManufacturerSegment(std::uint8_t t, Data&& d) : type(t), data(d) {}; |
93 | 1 | BLEAdvertAppleManufacturerSegment(const BLEAdvertAppleManufacturerSegment&) = default; |
94 | 0 | BLEAdvertAppleManufacturerSegment(BLEAdvertAppleManufacturerSegment&&) = default; |
95 | | }; |
96 | | |
97 | | } |
98 | | } |
99 | | } |
100 | | |
101 | | #endif |