File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,10 @@ void setup() {
27
27
beacon.setSignalPower (0xC5 ); // Optional
28
28
beacon.setProximityUUID (BLEUUID (iBeaconUUID)); // Unlike Bluedroid, you do not need to reverse endianness here
29
29
30
- // Extract beacon data
31
- NimBLEBeacon::BeaconData beaconData = beacon.getData ();
32
-
33
30
// Create advertisement data
34
31
NimBLEAdvertisementData beaconAdvertisementData;
35
32
beaconAdvertisementData.setFlags (0x04 ); // BR_EDR_NOT_SUPPORTED
36
- beaconAdvertisementData.setManufacturerData (reinterpret_cast < const uint8_t *>(&beaconData), sizeof (NimBLEBeacon::BeaconData ));
33
+ beaconAdvertisementData.setManufacturerData (beacon. getData ( ));
37
34
38
35
// Start advertising
39
36
NimBLEAdvertising *advertising = NimBLEDevice::getAdvertising ();
Original file line number Diff line number Diff line change 24
24
class NimBLEUUID ;
25
25
26
26
# include < cstdint>
27
+ # include < vector>
27
28
28
29
/* *
29
30
* @brief Representation of a beacon.
@@ -40,6 +41,10 @@ class NimBLEBeacon {
40
41
uint16_t major{};
41
42
uint16_t minor{};
42
43
int8_t signalPower{};
44
+ operator std::vector<uint8_t > () const {
45
+ return std::vector<uint8_t >(reinterpret_cast <const uint8_t *>(this ),
46
+ reinterpret_cast <const uint8_t *>(this ) + sizeof (BeaconData));
47
+ }
43
48
} __attribute__((packed));
44
49
45
50
const BeaconData& getData ();
You can’t perform that action at this time.
0 commit comments