18#ifndef NIMBLE_CPP_ADVERTISING_H_
19#define NIMBLE_CPP_ADVERTISING_H_
22#if (defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_EXT_ADV) || \
25# if defined(CONFIG_NIMBLE_CPP_IDF)
26# include "host/ble_gap.h"
28# include "nimble/nimble/host/include/host/ble_gap.h"
36# include "NimBLEUUID.h"
37# include "NimBLEAddress.h"
38# include "NimBLEAdvertisementData.h"
62 void setScanFilter(
bool scanRequestWhitelistOnly,
bool connectWhitelistOnly);
83 bool setName(
const std::string& name);
87 bool setURI(
const std::string& uri);
97 static int handleGapEvent(ble_gap_event* event,
void* arg);
101 ble_gap_adv_params m_advParams;
102 advCompleteCB_t m_advCompCb;
103 uint8_t m_slaveItvl[4];
106 bool m_advDataSet : 1;
A BLE device address.
Definition NimBLEAddress.h:41
Advertisement data set by the programmer to be published by the BLE server.
Definition NimBLEAdvertisementData.h:33
Perform and manage BLE advertising.
Definition NimBLEAdvertising.h:52
bool addTxPower()
Add the transmission power level to the advertisement packet.
Definition NimBLEAdvertising.cpp:501
const NimBLEAdvertisementData & getAdvertisementData()
Get the current advertisement data.
Definition NimBLEAdvertising.cpp:348
bool setAppearance(uint16_t appearance)
Set the device appearance in the advertising data.
Definition NimBLEAdvertising.cpp:468
void setAdvertisingInterval(uint16_t interval)
Set the advertising interval.
Definition NimBLEAdvertising.cpp:123
bool stop()
Stop advertising.
Definition NimBLEAdvertising.cpp:249
void setAdvertisingCompleteCallback(advCompleteCB_t callback)
Set the callback to be invoked when advertising stops.
Definition NimBLEAdvertising.cpp:263
bool addServiceUUID(const NimBLEUUID &serviceUUID)
Add a service uuid to exposed list of services.
Definition NimBLEAdvertising.cpp:410
void setMinInterval(uint16_t minInterval)
Set the minimum advertising interval.
Definition NimBLEAdvertising.cpp:132
void enableScanResponse(bool enable)
Enable scan response data.
Definition NimBLEAdvertising.cpp:149
bool setDiscoverableMode(uint8_t mode)
Set the discoverable mode to use.
Definition NimBLEAdvertising.cpp:99
bool setName(const std::string &name)
Set the advertised name of the device.
Definition NimBLEAdvertising.cpp:519
bool setServiceData(const NimBLEUUID &uuid, const uint8_t *data, size_t length)
Set the service data advertised for the UUID.
Definition NimBLEAdvertising.cpp:592
bool start(uint32_t duration=0, const NimBLEAddress *dirAddr=nullptr)
Start advertising.
Definition NimBLEAdvertising.cpp:184
bool reset()
Stops the current advertising and resets the advertising data to the default values.
Definition NimBLEAdvertising.cpp:60
bool setScanResponseData(const NimBLEAdvertisementData &advertisementData)
Set the data that is to be provided in a scan response.
Definition NimBLEAdvertising.cpp:359
void setMaxInterval(uint16_t maxInterval)
Set the maximum advertising interval.
Definition NimBLEAdvertising.cpp:140
bool setPreferredParams(uint16_t minInterval, uint16_t maxInterval)
Set the preferred min and max connection intervals to advertise.
Definition NimBLEAdvertising.cpp:486
bool setURI(const std::string &uri)
Set the advertised URI.
Definition NimBLEAdvertising.cpp:573
void setScanFilter(bool scanRequestWhitelistOnly, bool connectWhitelistOnly)
Set the filtering for the scan filter.
Definition NimBLEAdvertising.cpp:159
bool setAdvertisementData(const NimBLEAdvertisementData &advertisementData)
Set the advertisement data that is to be broadcast in a regular advertisement.
Definition NimBLEAdvertising.cpp:331
bool removeServiceUUID(const NimBLEUUID &serviceUUID)
Remove a service UUID from the advertisement.
Definition NimBLEAdvertising.cpp:435
NimBLEAdvertising()
Construct a default advertising object.
Definition NimBLEAdvertising.cpp:38
bool isAdvertising()
Check if currently advertising.
Definition NimBLEAdvertising.cpp:271
bool setManufacturerData(const uint8_t *data, size_t length)
Set the advertised manufacturer data.
Definition NimBLEAdvertising.cpp:539
bool removeServices()
Remove all service UUIDs from the advertisement.
Definition NimBLEAdvertising.cpp:455
bool refreshAdvertisingData()
Refresh advertsing data dynamically without stop/start cycle. For instance allows refreshing manufact...
Definition NimBLEAdvertising.cpp:396
const NimBLEAdvertisementData & getScanData()
Get the current scan response data.
Definition NimBLEAdvertising.cpp:375
bool setConnectableMode(uint8_t mode)
Set the type of connectable mode to advertise.
Definition NimBLEAdvertising.cpp:77
void clearData()
Clear the advertisement and scan response data and set the flags to BLE_HS_ADV_F_DISC_GEN.
Definition NimBLEAdvertising.cpp:382
A model of a BLE Device from which all the BLE roles are created.
Definition NimBLEDevice.h:109
The model of a BLE server.
Definition NimBLEServer.h:60
A model of a BLE UUID.
Definition NimBLEUUID.h:41