esp-nimble-cpp  1.3.2
NimBLEAdvertisedDevice Class Reference

A representation of a BLE advertised device found by a scan. More...

Public Member Functions

 NimBLEAdvertisedDevice ()
 Constructor.
 
NimBLEAddress getAddress ()
 Get the address of the advertising device. More...
 
uint8_t getAdvType ()
 Get the advertisement type. More...
 
uint16_t getAppearance ()
 Get the appearance. More...
 
uint16_t getAdvInterval ()
 Get the advertisement interval. More...
 
uint16_t getMinInterval ()
 Get the preferred min connection interval. More...
 
uint16_t getMaxInterval ()
 Get the preferred max connection interval. More...
 
std::string getManufacturerData ()
 Get the manufacturer data. More...
 
std::string getURI ()
 Get the URI from the advertisement. More...
 
template<typename T >
getManufacturerData (bool skipSizeCheck=false)
 A template to convert the service data to <type>. More...
 
std::string getName ()
 Get the advertised name. More...
 
int getRSSI ()
 Get the RSSI. More...
 
NimBLEScangetScan ()
 Get the scan object that created this advertised device. More...
 
size_t getServiceDataCount ()
 Get the count of advertised service data UUIDS. More...
 
std::string getServiceData (uint8_t index=0)
 Get the service data. More...
 
std::string getServiceData (const NimBLEUUID &uuid)
 Get the service data. More...
 
template<typename T >
getServiceData (uint8_t index=0, bool skipSizeCheck=false)
 A template to convert the service data to <type>. More...
 
template<typename T >
getServiceData (const NimBLEUUID &uuid, bool skipSizeCheck=false)
 A template to convert the service data to <type>. More...
 
NimBLEUUID getServiceDataUUID (uint8_t index=0)
 Get the UUID of the serice data at the index. More...
 
NimBLEUUID getServiceUUID (uint8_t index=0)
 Get the Service UUID. More...
 
size_t getServiceUUIDCount ()
 Get the number of services advertised. More...
 
NimBLEAddress getTargetAddress (uint8_t index=0)
 Get the target address at the index. More...
 
size_t getTargetAddressCount ()
 Get the number of target addresses. More...
 
int8_t getTXPower ()
 Get the TX Power. More...
 
uint8_t * getPayload ()
 Get the payload advertised by the device. More...
 
uint8_t getAdvLength ()
 Get the length of the advertisement data in the payload. More...
 
size_t getPayloadLength ()
 Get the length of the payload advertised by the device. More...
 
uint8_t getAddressType ()
 Get the advertised device address type. More...
 
time_t getTimestamp ()
 Get the timeStamp of when the device last advertised. More...
 
bool isAdvertisingService (const NimBLEUUID &uuid)
 Check advertised services for existance of the required UUID. More...
 
bool haveAppearance ()
 Does this advertisement have an appearance value? More...
 
bool haveManufacturerData ()
 Does this advertisement have manufacturer data? More...
 
bool haveName ()
 Does this advertisement have a name value? More...
 
bool haveRSSI ()
 Does this advertisement have a signal strength value? More...
 
bool haveServiceData ()
 Does this advertisement have a service data value? More...
 
bool haveServiceUUID ()
 Does this advertisement have a service UUID value? More...
 
bool haveTXPower ()
 Does this advertisement have a transmission power value? More...
 
bool haveConnParams ()
 Does this advertisement have preferred connection parameters? More...
 
bool haveAdvInterval ()
 Does this advertisement have have the advertising interval? More...
 
bool haveTargetAddress ()
 Does the advertisement contain a target address? More...
 
bool haveURI ()
 Does this advertisement have a URI? More...
 
std::string toString ()
 Create a string representation of this device. More...
 

Detailed Description

A representation of a BLE advertised device found by a scan.

When we perform a BLE scan, the result will be a set of devices that are advertising. This class provides a model of a detected device.

Member Function Documentation

◆ getAddress()

NimBLEAddress NimBLEAdvertisedDevice::getAddress ( )

Get the address of the advertising device.

Returns
The address of the advertised device.

◆ getAddressType()

uint8_t NimBLEAdvertisedDevice::getAddressType ( )

Get the advertised device address type.

Returns
The device address type:
  • BLE_ADDR_PUBLIC (0x00)
  • BLE_ADDR_RANDOM (0x01)
  • BLE_ADDR_PUBLIC_ID (0x02)
  • BLE_ADDR_RANDOM_ID (0x03)

◆ getAdvInterval()

uint16_t NimBLEAdvertisedDevice::getAdvInterval ( )

Get the advertisement interval.

Returns
The advertisement interval in 0.625ms units.

◆ getAdvLength()

uint8_t NimBLEAdvertisedDevice::getAdvLength ( )

Get the length of the advertisement data in the payload.

Returns
The number of bytes in the payload that is from the advertisment.

◆ getAdvType()

uint8_t NimBLEAdvertisedDevice::getAdvType ( )

Get the advertisement type.

Returns
The advertising type the device is reporting:
  • BLE_HCI_ADV_TYPE_ADV_IND (0) - indirect advertising
  • BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD (1) - direct advertisng - high duty cycle
  • BLE_HCI_ADV_TYPE_ADV_SCAN_IND (2) - indirect scan response
  • BLE_HCI_ADV_TYPE_ADV_NONCONN_IND (3) - indirect advertisng - not connectable
  • BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD (4) - direct advertising - low duty cycle

◆ getAppearance()

uint16_t NimBLEAdvertisedDevice::getAppearance ( )

Get the appearance.

A BLE device can declare its own appearance. The appearance is how it would like to be shown to an end user typcially in the form of an icon.

Returns
The appearance of the advertised device.

◆ getManufacturerData() [1/2]

std::string NimBLEAdvertisedDevice::getManufacturerData ( )

Get the manufacturer data.

Returns
The manufacturer data of the advertised device.

◆ getManufacturerData() [2/2]

template<typename T >
T NimBLEAdvertisedDevice::getManufacturerData ( bool  skipSizeCheck = false)
inline

A template to convert the service data to <type>.

Template Parameters
TThe type to convert the data to.
Parameters
[in]skipSizeCheckIf true it will skip checking if the data size is less than sizeof(<type>).
Returns
The data converted to <type> or NULL if skipSizeCheck is false and the data is less than sizeof(<type>).

Use: getManufacturerData<type>(skipSizeCheck);

◆ getMaxInterval()

uint16_t NimBLEAdvertisedDevice::getMaxInterval ( )

Get the preferred max connection interval.

Returns
The preferred max connection interval in 1.25ms units.

◆ getMinInterval()

uint16_t NimBLEAdvertisedDevice::getMinInterval ( )

Get the preferred min connection interval.

Returns
The preferred min connection interval in 1.25ms units.

◆ getName()

std::string NimBLEAdvertisedDevice::getName ( )

Get the advertised name.

Returns
The name of the advertised device.

◆ getPayload()

uint8_t * NimBLEAdvertisedDevice::getPayload ( )

Get the payload advertised by the device.

Returns
The advertisement payload.

◆ getPayloadLength()

size_t NimBLEAdvertisedDevice::getPayloadLength ( )

Get the length of the payload advertised by the device.

Returns
The size of the payload in bytes.

◆ getRSSI()

int NimBLEAdvertisedDevice::getRSSI ( )

Get the RSSI.

Returns
The RSSI of the advertised device.

◆ getScan()

NimBLEScan * NimBLEAdvertisedDevice::getScan ( )

Get the scan object that created this advertised device.

Returns
The scan object.

◆ getServiceData() [1/4]

std::string NimBLEAdvertisedDevice::getServiceData ( const NimBLEUUID uuid)

Get the service data.

Parameters
[in]uuidThe uuid of the service data requested.
Returns
The advertised service data or empty string if no data.

◆ getServiceData() [2/4]

template<typename T >
T NimBLEAdvertisedDevice::getServiceData ( const NimBLEUUID uuid,
bool  skipSizeCheck = false 
)
inline

A template to convert the service data to <type>.

Template Parameters
TThe type to convert the data to.
Parameters
[in]uuidThe uuid of the service data requested.
[in]skipSizeCheckIf true it will skip checking if the data size is less than sizeof(<type>).
Returns
The data converted to <type> or NULL if skipSizeCheck is false and the data is less than sizeof(<type>).

Use: getServiceData<type>(skipSizeCheck);

◆ getServiceData() [3/4]

std::string NimBLEAdvertisedDevice::getServiceData ( uint8_t  index = 0)

Get the service data.

Parameters
[in]indexThe index of the service data requested.
Returns
The advertised service data or empty string if no data.

◆ getServiceData() [4/4]

template<typename T >
T NimBLEAdvertisedDevice::getServiceData ( uint8_t  index = 0,
bool  skipSizeCheck = false 
)
inline

A template to convert the service data to <type>.

Template Parameters
TThe type to convert the data to.
Parameters
[in]indexThe vector index of the service data requested.
[in]skipSizeCheckIf true it will skip checking if the data size is less than sizeof(<type>).
Returns
The data converted to <type> or NULL if skipSizeCheck is false and the data is less than sizeof(<type>).

Use: getServiceData<type>(skipSizeCheck);

◆ getServiceDataCount()

size_t NimBLEAdvertisedDevice::getServiceDataCount ( )

Get the count of advertised service data UUIDS.

Returns
The number of service data UUIDS in the vector.

◆ getServiceDataUUID()

NimBLEUUID NimBLEAdvertisedDevice::getServiceDataUUID ( uint8_t  index = 0)

Get the UUID of the serice data at the index.

Parameters
[in]indexThe index of the service data UUID requested.
Returns
The advertised service data UUID or an empty UUID if not found.

◆ getServiceUUID()

NimBLEUUID NimBLEAdvertisedDevice::getServiceUUID ( uint8_t  index = 0)

Get the Service UUID.

Parameters
[in]indexThe index of the service UUID requested.
Returns
The Service UUID of the advertised service, or an empty UUID if not found.

◆ getServiceUUIDCount()

size_t NimBLEAdvertisedDevice::getServiceUUIDCount ( )

Get the number of services advertised.

Returns
The count of services in the advertising packet.

◆ getTargetAddress()

NimBLEAddress NimBLEAdvertisedDevice::getTargetAddress ( uint8_t  index = 0)

Get the target address at the index.

Parameters
[in]indexThe index of the target address.
Returns
The target address.

◆ getTargetAddressCount()

size_t NimBLEAdvertisedDevice::getTargetAddressCount ( )

Get the number of target addresses.

Returns
The number of addresses.

◆ getTimestamp()

time_t NimBLEAdvertisedDevice::getTimestamp ( )

Get the timeStamp of when the device last advertised.

Returns
The timeStamp of when the device was last seen.

◆ getTXPower()

int8_t NimBLEAdvertisedDevice::getTXPower ( )

Get the TX Power.

Returns
The TX Power of the advertised device.

◆ getURI()

std::string NimBLEAdvertisedDevice::getURI ( )

Get the URI from the advertisement.

Returns
The URI data.

◆ haveAdvInterval()

bool NimBLEAdvertisedDevice::haveAdvInterval ( )

Does this advertisement have have the advertising interval?

Returns
True if the advertisement interval is present.

◆ haveAppearance()

bool NimBLEAdvertisedDevice::haveAppearance ( )

Does this advertisement have an appearance value?

Returns
True if there is an appearance value present.

◆ haveConnParams()

bool NimBLEAdvertisedDevice::haveConnParams ( )

Does this advertisement have preferred connection parameters?

Returns
True if connection parameters are present.

◆ haveManufacturerData()

bool NimBLEAdvertisedDevice::haveManufacturerData ( )

Does this advertisement have manufacturer data?

Returns
True if there is manufacturer data present.

◆ haveName()

bool NimBLEAdvertisedDevice::haveName ( )

Does this advertisement have a name value?

Returns
True if there is a name value present.

◆ haveRSSI()

bool NimBLEAdvertisedDevice::haveRSSI ( )

Does this advertisement have a signal strength value?

Returns
True if there is a signal strength value present.

◆ haveServiceData()

bool NimBLEAdvertisedDevice::haveServiceData ( )

Does this advertisement have a service data value?

Returns
True if there is a service data value present.

◆ haveServiceUUID()

bool NimBLEAdvertisedDevice::haveServiceUUID ( )

Does this advertisement have a service UUID value?

Returns
True if there is a service UUID value present.

◆ haveTargetAddress()

bool NimBLEAdvertisedDevice::haveTargetAddress ( )

Does the advertisement contain a target address?

Returns
True if an address is present.

◆ haveTXPower()

bool NimBLEAdvertisedDevice::haveTXPower ( )

Does this advertisement have a transmission power value?

Returns
True if there is a transmission power value present.

◆ haveURI()

bool NimBLEAdvertisedDevice::haveURI ( )

Does this advertisement have a URI?

Returns
True if there is a URI present.

◆ isAdvertisingService()

bool NimBLEAdvertisedDevice::isAdvertisingService ( const NimBLEUUID uuid)

Check advertised services for existance of the required UUID.

Parameters
[in]uuidThe service uuid to look for in the advertisement.
Returns
Return true if service is advertised

◆ toString()

std::string NimBLEAdvertisedDevice::toString ( )

Create a string representation of this device.

Returns
A string representation of this device.