15 #ifndef COMPONENTS_NIMBLEADVERTISEDDEVICE_H_
16 #define COMPONENTS_NIMBLEADVERTISEDDEVICE_H_
18 #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
20 #include "NimBLEAddress.h"
21 #include "NimBLEScan.h"
22 #include "NimBLEUUID.h"
24 #if defined(CONFIG_NIMBLE_CPP_IDF)
25 #include "host/ble_hs_adv.h"
27 #include "nimble/nimble/host/include/host/ble_hs_adv.h"
66 if(!skipSizeCheck && data.size() <
sizeof(T))
return T();
67 const char *pData = data.data();
90 if(!skipSizeCheck && data.size() <
sizeof(T))
return T();
91 const char *pData = data.data();
107 if(!skipSizeCheck && data.size() <
sizeof(T))
return T();
108 const char *pData = data.data();
109 return *((T *)pData);
141 void setAdvType(uint8_t advType);
142 void setPayload(
const uint8_t *payload, uint8_t length,
bool append);
143 void setRSSI(
int rssi);
144 uint8_t findAdvField(uint8_t type, uint8_t index = 0, uint8_t *data_loc =
nullptr);
145 uint8_t findServiceData(uint8_t index, uint8_t* bytes);
154 std::vector<uint8_t> m_payload;
A BLE device address.
Definition: NimBLEAddress.h:39
A callback handler for callbacks associated device scanning.
Definition: NimBLEAdvertisedDevice.h:164
virtual void onResult(NimBLEAdvertisedDevice *advertisedDevice)=0
Called when a new scan result is detected.
A representation of a BLE advertised device found by a scan.
Definition: NimBLEAdvertisedDevice.h:42
bool haveTargetAddress()
Does the advertisement contain a target address?
Definition: NimBLEAdvertisedDevice.cpp:532
time_t getTimestamp()
Get the timeStamp of when the device last advertised.
Definition: NimBLEAdvertisedDevice.cpp:771
uint16_t getAppearance()
Get the appearance.
Definition: NimBLEAdvertisedDevice.cpp:71
bool haveConnParams()
Does this advertisement have preferred connection parameters?
Definition: NimBLEAdvertisedDevice.cpp:487
uint16_t getMinInterval()
Get the preferred min connection interval.
Definition: NimBLEAdvertisedDevice.cpp:107
bool isAdvertisingService(const NimBLEUUID &uuid)
Check advertised services for existance of the required UUID.
Definition: NimBLEAdvertisedDevice.cpp:453
uint16_t getMaxInterval()
Get the preferred max connection interval.
Definition: NimBLEAdvertisedDevice.cpp:125
NimBLEUUID getServiceDataUUID(uint8_t index=0)
Get the UUID of the serice data at the index.
Definition: NimBLEAdvertisedDevice.cpp:313
NimBLEAddress getTargetAddress(uint8_t index=0)
Get the target address at the index.
Definition: NimBLEAdvertisedDevice.cpp:232
bool haveServiceUUID()
Does this advertisement have a service UUID value?
Definition: NimBLEAdvertisedDevice.cpp:570
size_t getServiceDataCount()
Get the count of advertised service data UUIDS.
Definition: NimBLEAdvertisedDevice.cpp:369
bool haveRSSI()
Does this advertisement have a signal strength value?
Definition: NimBLEAdvertisedDevice.cpp:552
size_t getServiceUUIDCount()
Get the number of services advertised.
Definition: NimBLEAdvertisedDevice.cpp:434
bool haveURI()
Does this advertisement have a URI?
Definition: NimBLEAdvertisedDevice.cpp:523
bool haveName()
Does this advertisement have a name value?
Definition: NimBLEAdvertisedDevice.cpp:542
T getServiceData(uint8_t index=0, bool skipSizeCheck=false)
A template to convert the service data to <type>.
Definition: NimBLEAdvertisedDevice.h:88
size_t getTargetAddressCount()
Get the number of target addresses.
Definition: NimBLEAdvertisedDevice.cpp:217
uint16_t getAdvInterval()
Get the advertisement interval.
Definition: NimBLEAdvertisedDevice.cpp:89
T getServiceData(const NimBLEUUID &uuid, bool skipSizeCheck=false)
A template to convert the service data to <type>.
Definition: NimBLEAdvertisedDevice.h:105
uint8_t getAdvType()
Get the advertisement type.
Definition: NimBLEAdvertisedDevice.cpp:58
NimBLEAddress getAddress()
Get the address of the advertising device.
Definition: NimBLEAdvertisedDevice.cpp:44
bool haveAdvInterval()
Does this advertisement have have the advertising interval?
Definition: NimBLEAdvertisedDevice.cpp:496
NimBLEUUID getServiceUUID(uint8_t index=0)
Get the Service UUID.
Definition: NimBLEAdvertisedDevice.cpp:385
NimBLEAdvertisedDevice()
Constructor.
Definition: NimBLEAdvertisedDevice.cpp:29
bool haveManufacturerData()
Does this advertisement have manufacturer data?
Definition: NimBLEAdvertisedDevice.cpp:514
std::string toString()
Create a string representation of this device.
Definition: NimBLEAdvertisedDevice.cpp:678
size_t getPayloadLength()
Get the length of the payload advertised by the device.
Definition: NimBLEAdvertisedDevice.cpp:780
bool haveAppearance()
Does this advertisement have an appearance value?
Definition: NimBLEAdvertisedDevice.cpp:505
int getRSSI()
Get the RSSI.
Definition: NimBLEAdvertisedDevice.cpp:199
NimBLEScan * getScan()
Get the scan object that created this advertised device.
Definition: NimBLEAdvertisedDevice.cpp:208
std::string getURI()
Get the URI from the advertisement.
Definition: NimBLEAdvertisedDevice.cpp:161
std::string getName()
Get the advertised name.
Definition: NimBLEAdvertisedDevice.cpp:179
uint8_t getAdvLength()
Get the length of the advertisement data in the payload.
Definition: NimBLEAdvertisedDevice.cpp:749
T getManufacturerData(bool skipSizeCheck=false)
A template to convert the service data to <type>.
Definition: NimBLEAdvertisedDevice.h:64
std::string getServiceData(uint8_t index=0)
Get the service data.
Definition: NimBLEAdvertisedDevice.cpp:264
bool haveTXPower()
Does this advertisement have a transmission power value?
Definition: NimBLEAdvertisedDevice.cpp:579
std::string getManufacturerData()
Get the manufacturer data.
Definition: NimBLEAdvertisedDevice.cpp:143
uint8_t * getPayload()
Get the payload advertised by the device.
Definition: NimBLEAdvertisedDevice.cpp:724
bool haveServiceData()
Does this advertisement have a service data value?
Definition: NimBLEAdvertisedDevice.cpp:561
uint8_t getAddressType()
Get the advertised device address type.
Definition: NimBLEAdvertisedDevice.cpp:762
int8_t getTXPower()
Get the TX Power.
Definition: NimBLEAdvertisedDevice.cpp:469
Perform and manage BLE scans.
Definition: NimBLEScan.h:63
A model of a BLE UUID.
Definition: NimBLEUUID.h:37