18#ifndef NIMBLE_CPP_ADVERTISED_DEVICE_H_
19#define NIMBLE_CPP_ADVERTISED_DEVICE_H_
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
24# include "NimBLEAddress.h"
25# include "NimBLEScan.h"
26# include "NimBLEUUID.h"
28# if defined(CONFIG_NIMBLE_CPP_IDF)
29# include "host/ble_hs_adv.h"
30# include "host/ble_gap.h"
32# include "nimble/nimble/host/include/host/ble_hs_adv.h"
33# include "nimble/nimble/host/include/host/ble_gap.h"
58 std::string
getURI()
const;
90# if CONFIG_BT_NIMBLE_EXT_ADV
97 const std::vector<uint8_t>&
getPayload()
const;
98 const std::vector<uint8_t>::const_iterator
begin()
const;
99 const std::vector<uint8_t>::const_iterator
end()
const;
109 template <
typename T>
112 if (!skipSizeCheck && data.size() <
sizeof(T))
return T();
113 const char* pData = data.data();
126 template <
typename T>
129 if (!skipSizeCheck && data.size() <
sizeof(T))
return T();
130 const char* pData = data.data();
143 template <
typename T>
146 if (!skipSizeCheck && data.size() <
sizeof(T))
return T();
147 const char* pData = data.data();
155 void update(
const ble_gap_event* event, uint8_t eventType);
156 uint8_t findAdvField(uint8_t type, uint8_t index = 0,
size_t* data_loc =
nullptr)
const;
157 size_t findServiceData(uint8_t index, uint8_t* bytes)
const;
162 uint8_t m_callbackSent{};
163 uint8_t m_advLength{};
165# if CONFIG_BT_NIMBLE_EXT_ADV
166 bool m_isLegacyAdv{};
170 uint16_t m_periodicItvl{};
173 std::vector<uint8_t> m_payload;
A BLE device address.
Definition NimBLEAddress.h:41
A representation of a BLE advertised device found by a scan.
Definition NimBLEAdvertisedDevice.h:45
uint8_t getManufacturerDataCount() const
Get the count of manufacturer data sets.
Definition NimBLEAdvertisedDevice.cpp:200
const std::vector< uint8_t > & getPayload() const
Get the payload advertised by the device.
Definition NimBLEAdvertisedDevice.cpp:787
uint8_t getTargetAddressCount() const
Get the number of target addresses.
Definition NimBLEAdvertisedDevice.cpp:258
bool haveServiceUUID() const
Does this advertisement have a service UUID value?
Definition NimBLEAdvertisedDevice.cpp:572
NimBLEScan * getScan() const
Get the scan object that created this advertised device.
Definition NimBLEAdvertisedDevice.cpp:250
T getServiceData(uint8_t index=0, bool skipSizeCheck=false) const
A template to convert the service data to <type>.
Definition NimBLEAdvertisedDevice.h:127
bool haveURI() const
Does this advertisement have a URI?
Definition NimBLEAdvertisedDevice.cpp:532
T getManufacturerData(bool skipSizeCheck=false) const
A template to convert the service data to <type>.
Definition NimBLEAdvertisedDevice.h:110
uint8_t getAddressType() const
Get the advertised device address type.
Definition NimBLEAdvertisedDevice.cpp:746
uint8_t getSecondaryPhy() const
Get the primary PHY used by this advertisement.
Definition NimBLEAdvertisedDevice.cpp:610
int8_t getTXPower() const
Get the TX Power.
Definition NimBLEAdvertisedDevice.cpp:484
bool isLegacyAdvertisement() const
Check if this advertisement is a legacy or extended type.
Definition NimBLEAdvertisedDevice.cpp:775
NimBLEUUID getServiceDataUUID(uint8_t index=0) const
Get the UUID of the service data at the index.
Definition NimBLEAdvertisedDevice.cpp:344
std::string getURI() const
Get the URI from the advertisement.
Definition NimBLEAdvertisedDevice.cpp:208
bool haveConnParams() const
Does this advertisement have preferred connection parameters?
Definition NimBLEAdvertisedDevice.cpp:500
bool haveTargetAddress() const
Does the advertisement contain a target address?
Definition NimBLEAdvertisedDevice.cpp:548
bool isScannable() const
Check if this device is advertising as scannable.
Definition NimBLEAdvertisedDevice.cpp:767
int8_t getRSSI() const
Get the RSSI.
Definition NimBLEAdvertisedDevice.cpp:242
std::string getPayloadByType(uint16_t type, uint8_t index=0) const
Get the data from any type available in the advertisement.
Definition NimBLEAdvertisedDevice.cpp:218
uint16_t getAppearance() const
Get the appearance.
Definition NimBLEAdvertisedDevice.cpp:127
const std::vector< uint8_t >::const_iterator end() const
Get the end iterator for the payload.
Definition NimBLEAdvertisedDevice.cpp:803
uint16_t getPeriodicInterval() const
Get the periodic interval of the advertisement.
Definition NimBLEAdvertisedDevice.cpp:618
bool haveAppearance() const
Does this advertisement have an appearance value?
Definition NimBLEAdvertisedDevice.cpp:516
bool haveType(uint16_t type) const
Does this advertisement have a adv type type?
Definition NimBLEAdvertisedDevice.cpp:540
uint8_t getPrimaryPhy() const
Get the primary PHY used by this advertisement.
Definition NimBLEAdvertisedDevice.cpp:599
std::string getServiceData(uint8_t index=0) const
Get the service data.
Definition NimBLEAdvertisedDevice.cpp:298
uint8_t getServiceDataCount() const
Get the count of advertised service data UUIDS.
Definition NimBLEAdvertisedDevice.cpp:394
bool haveAdvInterval() const
Does this advertisement have have the advertising interval?
Definition NimBLEAdvertisedDevice.cpp:508
const std::vector< uint8_t >::const_iterator begin() const
Get the begin iterator for the payload.
Definition NimBLEAdvertisedDevice.cpp:795
std::string getManufacturerData(uint8_t index=0) const
Get the manufacturer data.
Definition NimBLEAdvertisedDevice.cpp:192
uint8_t getAdvType() const
Get the advertisement type.
Definition NimBLEAdvertisedDevice.cpp:96
bool haveServiceData() const
Does this advertisement have a service data value?
Definition NimBLEAdvertisedDevice.cpp:564
bool isConnectable() const
Check if this device is advertising as connectable.
Definition NimBLEAdvertisedDevice.cpp:754
const NimBLEAddress & getAddress() const
Get the address of the advertising device.
Definition NimBLEAdvertisedDevice.cpp:83
uint8_t getAdvFlags() const
Get the advertisement flags.
Definition NimBLEAdvertisedDevice.cpp:107
uint16_t getMinInterval() const
Get the preferred min connection interval.
Definition NimBLEAdvertisedDevice.cpp:159
std::string getName() const
Get the advertised name.
Definition NimBLEAdvertisedDevice.cpp:234
bool isAdvertisingService(const NimBLEUUID &uuid) const
Check advertised services for existence of the required UUID.
Definition NimBLEAdvertisedDevice.cpp:469
uint16_t getAdvInterval() const
Get the advertisement interval.
Definition NimBLEAdvertisedDevice.cpp:143
std::string toString() const
Create a string representation of this device.
Definition NimBLEAdvertisedDevice.cpp:690
bool haveManufacturerData() const
Does this advertisement have manufacturer data?
Definition NimBLEAdvertisedDevice.cpp:524
uint8_t getSetId() const
Get the set ID of the extended advertisement.
Definition NimBLEAdvertisedDevice.cpp:589
uint8_t getServiceUUIDCount() const
Get the number of services advertised.
Definition NimBLEAdvertisedDevice.cpp:453
T getServiceData(const NimBLEUUID &uuid, bool skipSizeCheck=false) const
A template to convert the service data to <type>.
Definition NimBLEAdvertisedDevice.h:144
NimBLEUUID getServiceUUID(uint8_t index=0) const
Get the Service UUID.
Definition NimBLEAdvertisedDevice.cpp:407
uint16_t getMaxInterval() const
Get the preferred max connection interval.
Definition NimBLEAdvertisedDevice.cpp:175
bool haveName() const
Does this advertisement have a name value?
Definition NimBLEAdvertisedDevice.cpp:556
NimBLEAddress getTargetAddress(uint8_t index=0) const
Get the target address at the index.
Definition NimBLEAdvertisedDevice.cpp:270
uint8_t getAdvLength() const
Get the length of the advertisement data in the payload.
Definition NimBLEAdvertisedDevice.cpp:734
bool haveTXPower() const
Does this advertisement have a transmission power value?
Definition NimBLEAdvertisedDevice.cpp:580
Perform and manage BLE scans.
Definition NimBLEScan.h:67
A model of a BLE UUID.
Definition NimBLEUUID.h:41