A representation of a BLE advertised device found by a scan.
More...
#include <BLEAdvertisedDevice.hpp>
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.
◆ getAddress()
Get the address.
Every BLE device exposes an address that is used to identify it and subsequently connect to it. Call this function to obtain the address of the advertised device.
- Returns
- The address of the advertised device.
◆ getAppearance()
uint16_t BLEAdvertisedDevice::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()
std::string BLEAdvertisedDevice::getManufacturerData |
( |
| ) |
|
Get the manufacturer data.
- Returns
- The manufacturer data of the advertised device.
89 return m_manufacturerData;
◆ getName()
std::string BLEAdvertisedDevice::getName |
( |
| ) |
|
Get the name.
- Returns
- The name of the advertised device.
◆ getPayload()
const uint8_t * BLEAdvertisedDevice::getPayload |
( |
| ) |
|
Get the advertised payload.
The payload includes both a advertisement and a scan response.
- Note
- This is modified by CoXlab Inc.
534 return (
const uint8_t *) m_payload.data();
◆ getPayloadLength()
size_t BLEAdvertisedDevice::getPayloadLength |
( |
| ) |
|
Get the advertised payload length.
The payload length will be equal or less than 62.
- 31 (maximum length of an advertisement) + 31 (maximum length of a scan response)
- Note
- This is modified by CoXlab Inc.
554 return m_payload.size();
◆ getRSSI()
int16_t BLEAdvertisedDevice::getRSSI |
( |
| ) |
|
Get the RSSI.
- Returns
- The RSSI of the advertised device.
◆ getScan()
BLEScan * BLEAdvertisedDevice::getScan |
( |
| ) |
|
Get the scan object that created this advertisement.
- Returns
- The scan object.
◆ getServiceData()
std::string BLEAdvertisedDevice::getServiceData |
( |
| ) |
|
Get the service data.
- Returns
- The ServiceData of the advertised device.
125 return m_serviceData;
◆ getServiceDataUUID()
BLEUUID BLEAdvertisedDevice::getServiceDataUUID |
( |
| ) |
|
Get the service data UUID.
- Returns
- The service data UUID.
134 return m_serviceDataUUID;
◆ getServiceUUID()
BLEUUID BLEAdvertisedDevice::getServiceUUID |
( |
| ) |
|
Get the Service UUID.
- Returns
- The Service UUID of the advertised device.
143 return m_serviceUUIDs[0];
◆ getTXPower()
int8_t BLEAdvertisedDevice::getTXPower |
( |
| ) |
|
Get the TX Power.
- Returns
- The TX Power of the advertised device.
◆ haveAppearance()
bool BLEAdvertisedDevice::haveAppearance |
( |
| ) |
|
Does this advertisement have an appearance value?
- Returns
- True if there is an appearance value present.
172 return m_haveAppearance;
◆ haveManufacturerData()
bool BLEAdvertisedDevice::haveManufacturerData |
( |
| ) |
|
Does this advertisement have manufacturer data?
- Returns
- True if there is manufacturer data present.
181 return (m_manufacturerData.length() > 0);
◆ haveName()
bool BLEAdvertisedDevice::haveName |
( |
| ) |
|
Does this advertisement have a name value?
- Returns
- True if there is a name value present.
190 return (m_name.length() > 0);
◆ haveRSSI()
bool BLEAdvertisedDevice::haveRSSI |
( |
| ) |
|
Does this advertisement have a signal strength value?
- Returns
- True if there is a signal strength value present.
199 return (m_rssi > SHRT_MIN);
◆ haveServiceData()
bool BLEAdvertisedDevice::haveServiceData |
( |
| ) |
|
Does this advertisement have a service data value?
- Returns
- True if there is a service data value present.
208 return m_haveServiceData;
◆ haveServiceUUID()
bool BLEAdvertisedDevice::haveServiceUUID |
( |
| ) |
|
Does this advertisement have a service UUID value?
- Returns
- True if there is a service UUID value present.
217 return (m_serviceUUIDs.size() > 0);
◆ haveTXPower()
bool BLEAdvertisedDevice::haveTXPower |
( |
| ) |
|
Does this advertisement have a transmission power value?
- Returns
- True if there is a transmission power value present.
226 return (m_txPower > CHAR_MIN);
◆ isAdvertisingService()
bool BLEAdvertisedDevice::isAdvertisingService |
( |
BLEUUID |
uuid | ) |
|
Check advertised serviced for existence required UUID.
- Returns
- Return true if service is advertised
151 for (
unsigned i = 0; i < m_serviceUUIDs.size(); i++) {
152 if (m_serviceUUIDs[i].equals(uuid))
return true;
◆ toString()
std::string BLEAdvertisedDevice::toString |
( |
| ) |
|
Create a string representation of this device.
- Returns
- A string representation of this device.
501 std::stringstream ss;
504 ss <<
", name: " << m_name;
510 ss <<
", manufacturer data:";
512 ss <<
' ' << std::setfill(
'0') << std::setw(2) << std::hex << (int)((uint8_t *)
getManufacturerData().data())[i];
514 ss << std::setw(0) << std::dec;
The documentation for this class was generated from the following files: