esp-nimble-cpp 2.0.2
|
Extended advertisement data. More...
#include <NimBLEExtAdvertising.h>
Public Member Functions | |
NimBLEExtAdvertisement (uint8_t priPhy=BLE_HCI_LE_PHY_1M, uint8_t secPhy=BLE_HCI_LE_PHY_1M) | |
Construct a BLE extended advertisement. | |
bool | setAppearance (uint16_t appearance) |
Set the appearance. | |
bool | addServiceUUID (const NimBLEUUID &serviceUUID) |
Add a service uuid to exposed list of services. | |
bool | addServiceUUID (const char *serviceUUID) |
Add a service uuid to exposed list of services. | |
bool | removeServiceUUID (const NimBLEUUID &serviceUUID) |
Remove a service UUID from the advertisement. | |
bool | removeServiceUUID (const char *serviceUUID) |
Remove a service UUID from the advertisement. | |
bool | removeServices () |
Remove all service UUIDs from the advertisement. | |
bool | setCompleteServices (const NimBLEUUID &uuid) |
Set a single service to advertise as a complete list of services. | |
bool | setCompleteServices16 (const std::vector< NimBLEUUID > &uuids) |
Set the complete list of 16 bit services to advertise. | |
bool | setCompleteServices32 (const std::vector< NimBLEUUID > &uuids) |
Set the complete list of 32 bit services to advertise. | |
bool | setFlags (uint8_t flag) |
Set the advertisement flags. | |
bool | setManufacturerData (const uint8_t *data, size_t length) |
Set manufacturer specific data. | |
bool | setManufacturerData (const std::string &data) |
Set manufacturer specific data. | |
bool | setManufacturerData (const std::vector< uint8_t > &data) |
Set manufacturer specific data. | |
bool | setURI (const std::string &uri) |
Set the URI to advertise. | |
bool | setName (const std::string &name, bool isComplete=true) |
Set the complete name of this device. | |
bool | setPartialServices (const NimBLEUUID &uuid) |
Set a single service to advertise as a partial list of services. | |
bool | setPartialServices16 (const std::vector< NimBLEUUID > &uuids) |
Set the partial list of services to advertise. | |
bool | setPartialServices32 (const std::vector< NimBLEUUID > &uuids) |
Set the partial list of services to advertise. | |
bool | setServiceData (const NimBLEUUID &uuid, const uint8_t *data, size_t length) |
Set the service data advertised for the UUID. | |
bool | setServiceData (const NimBLEUUID &uuid, const std::string &data) |
Set the service data (UUID + data) | |
bool | setServiceData (const NimBLEUUID &uuid, const std::vector< uint8_t > &data) |
Set the service data advertised for the UUID. | |
bool | setShortName (const std::string &name) |
Set the short name. | |
bool | setData (const uint8_t *data, size_t length) |
Set the advertisement data. | |
bool | addData (const uint8_t *data, size_t length) |
Add data to the payload to be advertised. | |
bool | addData (const std::string &data) |
Add data to the payload to be advertised. | |
bool | setPreferredParams (uint16_t min, uint16_t max) |
Set the preferred min and max connection intervals to advertise. | |
void | addTxPower () |
Adds Tx power level to the advertisement data. | |
void | setLegacyAdvertising (bool enable) |
Sets wether the advertisement should use legacy (BLE 4.0, 31 bytes max) advertising. | |
void | setConnectable (bool enable) |
Sets wether this advertisement should advertise as a connectable device. | |
void | setScannable (bool enable) |
Sets wether the advertisement has scan response data available. | |
void | setMinInterval (uint32_t mininterval) |
Set the minimum advertising interval. | |
void | setMaxInterval (uint32_t maxinterval) |
Set the maximum advertising interval. | |
void | setPrimaryPhy (uint8_t phy) |
Set the primary advertising PHY to use. | |
void | setSecondaryPhy (uint8_t phy) |
Set the secondary advertising PHY to use. | |
void | setScanFilter (bool scanRequestWhitelistOnly, bool connectWhitelistOnly) |
Set the filtering for the scan filter. | |
void | setDirectedPeer (const NimBLEAddress &addr) |
Sets the peer to directly advertise to. | |
void | setDirected (bool enable, bool high_duty=true) |
Enable or disable direct advertisements to the peer set with NimBLEExtAdvertisement::setDirectedPeer | |
void | setAnonymous (bool enable) |
Sets whether the advertisement should be anonymous. | |
void | setPrimaryChannels (bool ch37, bool ch38, bool ch39) |
Sets The primary channels to advertise on. | |
void | setTxPower (int8_t dbm) |
Sets the transmission power level for this advertisement. | |
void | setAddress (const NimBLEAddress &addr) |
Set the address to use for this advertisement. | |
void | enableScanRequestCallback (bool enable) |
Sets whether the scan response request callback should be called. | |
void | clearData () |
Clears the data stored in this instance, does not change settings. | |
int | getDataLocation (uint8_t type) const |
Get the location of the data in the payload. | |
bool | removeData (uint8_t type) |
Remove data from the advertisement data. | |
size_t | getDataSize () const |
Get the size of the current data. | |
std::string | toString () const |
Get the string representation of the advertisement data. | |
Extended advertisement data.
NimBLEExtAdvertisement::NimBLEExtAdvertisement | ( | uint8_t | priPhy = BLE_HCI_LE_PHY_1M , |
uint8_t | secPhy = BLE_HCI_LE_PHY_1M |
||
) |
Construct a BLE extended advertisement.
[in] | priPhy | The primary Phy to advertise on, can be one of:
|
[in] | secPhy | The secondary Phy to advertise on, can be one of:
|
bool NimBLEExtAdvertisement::addData | ( | const std::string & | data | ) |
Add data to the payload to be advertised.
[in] | data | The data to be added to the payload. |
bool NimBLEExtAdvertisement::addData | ( | const uint8_t * | data, |
size_t | length | ||
) |
Add data to the payload to be advertised.
[in] | data | The data to be added to the payload. |
[in] | length | The size of data to be added to the payload. |
bool NimBLEExtAdvertisement::addServiceUUID | ( | const char * | serviceUUID | ) |
Add a service uuid to exposed list of services.
[in] | serviceUUID | The string representation of the service to expose. |
bool NimBLEExtAdvertisement::addServiceUUID | ( | const NimBLEUUID & | serviceUUID | ) |
Add a service uuid to exposed list of services.
[in] | serviceUUID | The UUID of the service to expose. |
void NimBLEExtAdvertisement::clearData | ( | ) |
Clears the data stored in this instance, does not change settings.
This will clear all data but preserves advertising parameter settings.
void NimBLEExtAdvertisement::enableScanRequestCallback | ( | bool | enable | ) |
Sets whether the scan response request callback should be called.
[in] | enable | If true the scan response request callback will be called for this advertisement. |
int NimBLEExtAdvertisement::getDataLocation | ( | uint8_t | type | ) | const |
Get the location of the data in the payload.
[in] | type | The type of data to search for. |
bool NimBLEExtAdvertisement::removeData | ( | uint8_t | type | ) |
Remove data from the advertisement data.
[in] | type | The type of data to remove. |
bool NimBLEExtAdvertisement::removeServiceUUID | ( | const char * | serviceUUID | ) |
Remove a service UUID from the advertisement.
[in] | serviceUUID | The UUID of the service to remove. |
bool NimBLEExtAdvertisement::removeServiceUUID | ( | const NimBLEUUID & | serviceUUID | ) |
Remove a service UUID from the advertisement.
[in] | serviceUUID | The UUID of the service to remove. |
void NimBLEExtAdvertisement::setAddress | ( | const NimBLEAddress & | addr | ) |
Set the address to use for this advertisement.
[in] | addr | The address to use. |
void NimBLEExtAdvertisement::setAnonymous | ( | bool | enable | ) |
Sets whether the advertisement should be anonymous.
[in] | enable | Set to true to enable anonymous advertising. |
Anonymous advertising omits the device's address from the advertisement.
bool NimBLEExtAdvertisement::setAppearance | ( | uint16_t | appearance | ) |
Set the appearance.
[in] | appearance | The appearance code value. |
If the appearance value is 0 then it will be removed from the advertisement if set previously.
bool NimBLEExtAdvertisement::setCompleteServices | ( | const NimBLEUUID & | uuid | ) |
Set a single service to advertise as a complete list of services.
[in] | uuid | The service to advertise. |
bool NimBLEExtAdvertisement::setCompleteServices16 | ( | const std::vector< NimBLEUUID > & | v_uuid | ) |
Set the complete list of 16 bit services to advertise.
[in] | v_uuid | A vector of 16 bit UUID's to advertise. |
bool NimBLEExtAdvertisement::setCompleteServices32 | ( | const std::vector< NimBLEUUID > & | v_uuid | ) |
Set the complete list of 32 bit services to advertise.
[in] | v_uuid | A vector of 32 bit UUID's to advertise. |
void NimBLEExtAdvertisement::setConnectable | ( | bool | enable | ) |
Sets wether this advertisement should advertise as a connectable device.
[in] | enable | True = connectable. |
bool NimBLEExtAdvertisement::setData | ( | const uint8_t * | data, |
size_t | length | ||
) |
Set the advertisement data.
[in] | data | The data to be set as the payload. |
[in] | length | The size of data. |
This will completely replace any data that was previously set.
void NimBLEExtAdvertisement::setDirected | ( | bool | enable, |
bool | high_duty = true |
||
) |
Enable or disable direct advertisements to the peer set with NimBLEExtAdvertisement::setDirectedPeer
[in] | enable | true = send directed advertisements to peer. |
[in] | high_duty | true = use fast advertising rate, default - true. |
void NimBLEExtAdvertisement::setDirectedPeer | ( | const NimBLEAddress & | addr | ) |
Sets the peer to directly advertise to.
[in] | addr | The address of the peer to direct the advertisements. |
bool NimBLEExtAdvertisement::setFlags | ( | uint8_t | flag | ) |
Set the advertisement flags.
[in] | flag | The flags to be set in the advertisement.
|
If the flag value is 0 then it will be removed from the advertisement if set previously.
void NimBLEExtAdvertisement::setLegacyAdvertising | ( | bool | enable | ) |
Sets wether the advertisement should use legacy (BLE 4.0, 31 bytes max) advertising.
[in] | enable | true = using legacy advertising. |
bool NimBLEExtAdvertisement::setManufacturerData | ( | const std::string & | data | ) |
Set manufacturer specific data.
[in] | data | The manufacturer data to advertise. |
bool NimBLEExtAdvertisement::setManufacturerData | ( | const std::vector< uint8_t > & | data | ) |
Set manufacturer specific data.
[in] | data | The manufacturer data to advertise. |
bool NimBLEExtAdvertisement::setManufacturerData | ( | const uint8_t * | data, |
size_t | length | ||
) |
Set manufacturer specific data.
[in] | data | The manufacturer data to advertise. |
[in] | length | The length of the data. |
void NimBLEExtAdvertisement::setMaxInterval | ( | uint32_t | maxinterval | ) |
Set the maximum advertising interval.
[in] | maxinterval | Maximum value for advertising interval in 0.625ms units, 0 = use default. |
void NimBLEExtAdvertisement::setMinInterval | ( | uint32_t | mininterval | ) |
Set the minimum advertising interval.
[in] | mininterval | Minimum value for advertising interval in 0.625ms units, 0 = use default. |
bool NimBLEExtAdvertisement::setName | ( | const std::string & | name, |
bool | isComplete = true |
||
) |
Set the complete name of this device.
[in] | name | The name to advertise. |
[in] | isComplete | If true the name is complete, if false it is shortened. |
bool NimBLEExtAdvertisement::setPartialServices | ( | const NimBLEUUID & | uuid | ) |
Set a single service to advertise as a partial list of services.
[in] | uuid | The service to advertise. |
bool NimBLEExtAdvertisement::setPartialServices16 | ( | const std::vector< NimBLEUUID > & | v_uuid | ) |
Set the partial list of services to advertise.
[in] | v_uuid | A vector of 16 bit UUID's to advertise. |
bool NimBLEExtAdvertisement::setPartialServices32 | ( | const std::vector< NimBLEUUID > & | v_uuid | ) |
Set the partial list of services to advertise.
[in] | v_uuid | A vector of 32 bit UUID's to advertise. |
bool NimBLEExtAdvertisement::setPreferredParams | ( | uint16_t | minInterval, |
uint16_t | maxInterval | ||
) |
Set the preferred min and max connection intervals to advertise.
[in] | minInterval | The minimum preferred connection interval. |
[in] | maxInterval | The Maximum preferred connection interval. |
Range = 0x0006(7.5ms) to 0x0C80(4000ms), values not within the range will be limited to this range.
void NimBLEExtAdvertisement::setPrimaryChannels | ( | bool | ch37, |
bool | ch38, | ||
bool | ch39 | ||
) |
Sets The primary channels to advertise on.
[in] | ch37 | Advertise on channel 37. |
[in] | ch38 | Advertise on channel 38. |
[in] | ch39 | Advertise on channel 39. |
This will set a bitmask using the input parameters to allow different
combinations. If all inputs are false then all 3 channels will be used.
void NimBLEExtAdvertisement::setPrimaryPhy | ( | uint8_t | phy | ) |
Set the primary advertising PHY to use.
[in] | phy | Can be one of following constants:
|
void NimBLEExtAdvertisement::setScanFilter | ( | bool | scanRequestWhitelistOnly, |
bool | connectWhitelistOnly | ||
) |
Set the filtering for the scan filter.
[in] | scanRequestWhitelistOnly | If true, only allow scan requests from those on the white list. |
[in] | connectWhitelistOnly | If true, only allow connections from those on the white list. |
void NimBLEExtAdvertisement::setScannable | ( | bool | enable | ) |
Sets wether the advertisement has scan response data available.
[in] | enable | true = scan response is available. |
void NimBLEExtAdvertisement::setSecondaryPhy | ( | uint8_t | phy | ) |
Set the secondary advertising PHY to use.
[in] | phy | Can be one of following constants:
|
bool NimBLEExtAdvertisement::setServiceData | ( | const NimBLEUUID & | uuid, |
const std::string & | data | ||
) |
Set the service data (UUID + data)
[in] | uuid | The UUID to set with the service data. |
[in] | data | The data to be associated with the service data advertised. |
bool NimBLEExtAdvertisement::setServiceData | ( | const NimBLEUUID & | uuid, |
const std::vector< uint8_t > & | data | ||
) |
Set the service data advertised for the UUID.
[in] | uuid | The UUID the service data belongs to. |
[in] | data | The data to advertise. |
bool NimBLEExtAdvertisement::setServiceData | ( | const NimBLEUUID & | uuid, |
const uint8_t * | data, | ||
size_t | length | ||
) |
Set the service data advertised for the UUID.
[in] | uuid | The UUID the service data belongs to. |
[in] | data | The data to advertise. |
[in] | length | The length of the data. |
bool NimBLEExtAdvertisement::setShortName | ( | const std::string & | name | ) |
Set the short name.
[in] | name | The short name of the device. |
void NimBLEExtAdvertisement::setTxPower | ( | int8_t | dbm | ) |
Sets the transmission power level for this advertisement.
[in] | dbm | the transmission power to use in dbm. |
The allowable value range depends on device hardware.
bool NimBLEExtAdvertisement::setURI | ( | const std::string & | uri | ) |
Set the URI to advertise.
[in] | uri | The uri to advertise. |
std::string NimBLEExtAdvertisement::toString | ( | ) | const |
Get the string representation of the advertisement data.