NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLEBeacon.h
1/*
2 * Copyright 2020-2024 Ryan Powell <ryan@nable-embedded.io> and
3 * esp-nimble-cpp, NimBLE-Arduino contributors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NIMBLE_CPP_BEACON_H_
19#define NIMBLE_CPP_BEACON_H_
20
21#include "nimconfig.h"
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
23
24class NimBLEUUID;
25
26# include <cstdint>
27
34 public:
35 struct BeaconData {
36 uint16_t manufacturerId{0x4c00};
37 uint8_t subType{0x02};
38 uint8_t subTypeLength{0x15};
39 uint8_t proximityUUID[16]{};
40 uint16_t major{};
41 uint16_t minor{};
42 int8_t signalPower{};
43 } __attribute__((packed));
44
45 const BeaconData& getData();
46 uint16_t getMajor();
47 uint16_t getMinor();
48 uint16_t getManufacturerId();
50 int8_t getSignalPower();
51 void setData(const uint8_t* data, uint8_t length);
52 void setData(const BeaconData& data);
53 void setMajor(uint16_t major);
54 void setMinor(uint16_t minor);
55 void setManufacturerId(uint16_t manufacturerId);
56 void setProximityUUID(const NimBLEUUID& uuid);
57 void setSignalPower(int8_t signalPower);
58
59 private:
60 BeaconData m_beaconData;
61}; // NimBLEBeacon
62
63#endif // NIMBLE_CPP_BEACON_H_
64#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
Representation of a beacon. See:
Definition NimBLEBeacon.h:33
void setManufacturerId(uint16_t manufacturerId)
Set the manufacturer ID.
Definition NimBLEBeacon.cpp:110
void setMinor(uint16_t minor)
Set the minor value.
Definition NimBLEBeacon.cpp:118
uint16_t getMinor()
Get the minor value being advertised.
Definition NimBLEBeacon.cpp:57
int8_t getSignalPower()
Get the signal power being advertised.
Definition NimBLEBeacon.cpp:73
void setProximityUUID(const NimBLEUUID &uuid)
Set the proximity UUID.
Definition NimBLEBeacon.cpp:126
uint16_t getManufacturerId()
Get the manufacturer ID being advertised.
Definition NimBLEBeacon.cpp:49
const BeaconData & getData()
Retrieve the data that is being advertised.
Definition NimBLEBeacon.cpp:33
NimBLEUUID getProximityUUID()
Get the proximity UUID being advertised.
Definition NimBLEBeacon.cpp:65
uint16_t getMajor()
Get the major value being advertised.
Definition NimBLEBeacon.cpp:41
void setData(const uint8_t *data, uint8_t length)
Set the beacon data.
Definition NimBLEBeacon.cpp:82
void setMajor(uint16_t major)
Set the major value.
Definition NimBLEBeacon.cpp:102
void setSignalPower(int8_t signalPower)
Set the signal power.
Definition NimBLEBeacon.cpp:137
A model of a BLE UUID.
Definition NimBLEUUID.h:41