8 #ifndef MAIN_BLEEXTADVERTISING_H_
9 #define MAIN_BLEEXTADVERTISING_H_
11 #if defined(CONFIG_BT_ENABLED) && \
12 defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && \
13 CONFIG_BT_NIMBLE_EXT_ADV
15 # if defined(CONFIG_NIMBLE_CPP_IDF)
16 # include "host/ble_gap.h"
18 # include "nimble/nimble/host/include/host/ble_gap.h"
26 #include "NimBLEAddress.h"
27 #include "NimBLEUUID.h"
40 uint8_t secPhy = BLE_HCI_LE_PHY_1M);
47 void setURI(
const std::string &uri);
48 void setName(
const std::string &name);
54 void setData(
const uint8_t * data,
size_t length);
55 void addData(
const std::string &data);
56 void addData(
const uint8_t * data,
size_t length);
66 void setScanFilter(
bool scanRequestWhitelistOnly,
bool connectWhitelistOnly);
80 void setServices(
const bool complete,
const uint8_t size,
81 const std::vector<NimBLEUUID> &v_uuid);
83 std::vector<uint8_t> m_payload;
84 ble_gap_ext_adv_params m_params;
99 bool start(uint8_t inst_id,
int duration = 0,
int max_events = 0);
104 bool stop(uint8_t inst_id);
109 bool deleteCallbacks =
true);
116 static int handleGapEvent(
struct ble_gap_event *event,
void *arg);
119 bool m_deleteCallbacks;
121 ble_gap_ext_adv_params m_advParams;
122 std::vector<bool> m_advStatus;
A BLE device address.
Definition: NimBLEAddress.h:39
A model of a BLE Device from which all the BLE roles are created.
Definition: NimBLEDevice.h:96
Extended advertisement data.
Definition: NimBLEExtAdvertising.h:37
void setCompleteServices(const NimBLEUUID &uuid)
Set a single service to advertise as a complete list of services.
Definition: NimBLEExtAdvertising.cpp:694
void setAddress(const NimBLEAddress &addr)
Set the address to use for this advertisement.
Definition: NimBLEExtAdvertising.cpp:446
void setScannable(bool val)
Sets wether the advertisement has scan response data available.
Definition: NimBLEExtAdvertising.cpp:414
void setData(const uint8_t *data, size_t length)
Set the advertisement data.
Definition: NimBLEExtAdvertising.cpp:599
void setCompleteServices16(const std::vector< NimBLEUUID > &v_uuid)
Set the complete list of 16 bit services to advertise.
Definition: NimBLEExtAdvertising.cpp:703
void clearData()
Clears the data stored in this instance, does not change settings.
Definition: NimBLEExtAdvertising.cpp:579
void setServiceData(const NimBLEUUID &uuid, const std::string &data)
Set the service data (UUID + data)
Definition: NimBLEExtAdvertising.cpp:801
void setScanFilter(bool scanRequestWhitelistOnly, bool connectWhitelistOnly)
Set the filtering for the scan filter.
Definition: NimBLEExtAdvertising.cpp:471
void setDirected(bool val, bool high_duty=true)
Enable or disable direct advertisements to the peer set with NimBLEExtAdvertisement::setDirectedPeer
Definition: NimBLEExtAdvertising.cpp:508
void setCompleteServices32(const std::vector< NimBLEUUID > &v_uuid)
Set the complete list of 32 bit services to advertise.
Definition: NimBLEExtAdvertising.cpp:712
void setAnonymous(bool val)
Sets whether the advertisement should be anonymous.
Definition: NimBLEExtAdvertising.cpp:561
void setMaxInterval(uint32_t maxinterval)
Set the maximum advertising interval.
Definition: NimBLEExtAdvertising.cpp:527
void setDirectedPeer(const NimBLEAddress &addr)
Sets the peer to directly advertise to.
Definition: NimBLEExtAdvertising.cpp:495
void setFlags(uint8_t flag)
Set the advertisement flags.
Definition: NimBLEExtAdvertising.cpp:645
void setManufacturerData(const std::string &data)
Set manufacturer specific data.
Definition: NimBLEExtAdvertising.cpp:658
void setConnectable(bool val)
Sets wether this advertisement should advertise as a connectable device.
Definition: NimBLEExtAdvertising.cpp:435
void setShortName(const std::string &name)
Set the short name.
Definition: NimBLEExtAdvertising.cpp:838
void setTxPower(int8_t dbm)
Sets the transmission power level for this advertisement.
Definition: NimBLEExtAdvertising.cpp:426
void setLegacyAdvertising(bool val)
Sets wether the advertisement should use legacy (BLE 4.0, 31 bytes max) advertising.
Definition: NimBLEExtAdvertising.cpp:405
void setPartialServices16(const std::vector< NimBLEUUID > &v_uuid)
Set the partial list of services to advertise.
Definition: NimBLEExtAdvertising.cpp:730
void addData(const std::string &data)
Add data to the payload to be advertised.
Definition: NimBLEExtAdvertising.cpp:608
void setName(const std::string &name)
Set the complete name of this device.
Definition: NimBLEExtAdvertising.cpp:682
void setAppearance(uint16_t appearance)
Set the appearance.
Definition: NimBLEExtAdvertising.cpp:630
NimBLEExtAdvertisement(uint8_t priPhy=BLE_HCI_LE_PHY_1M, uint8_t secPhy=BLE_HCI_LE_PHY_1M)
Construct a BLE extended advertisement.
Definition: NimBLEExtAdvertising.cpp:390
void setSecondaryPhy(uint8_t phy)
Set the secondary advertising PHY to use.
Definition: NimBLEExtAdvertising.cpp:550
void enableScanRequestCallback(bool enable)
Sets whether the scan response request callback should be called.
Definition: NimBLEExtAdvertising.cpp:570
void setPrimaryChannels(bool ch37, bool ch38, bool ch39)
Sets The primary channels to advertise on.
Definition: NimBLEExtAdvertising.cpp:461
void setPartialServices(const NimBLEUUID &uuid)
Set a single service to advertise as a partial list of services.
Definition: NimBLEExtAdvertising.cpp:721
void setPreferredParams(uint16_t min, uint16_t max)
Set the preferred connection interval parameters.
Definition: NimBLEExtAdvertising.cpp:859
void addTxPower()
Adds Tx power level to the advertisement data.
Definition: NimBLEExtAdvertising.cpp:849
void setPartialServices32(const std::vector< NimBLEUUID > &v_uuid)
Set the partial list of services to advertise.
Definition: NimBLEExtAdvertising.cpp:739
void setPrimaryPhy(uint8_t phy)
Set the primary advertising PHY to use.
Definition: NimBLEExtAdvertising.cpp:538
void setMinInterval(uint32_t mininterval)
Set the minimum advertising interval.
Definition: NimBLEExtAdvertising.cpp:518
size_t getDataSize()
Get the size of the current data.
Definition: NimBLEExtAdvertising.cpp:588
void setURI(const std::string &uri)
Set the URI to advertise.
Definition: NimBLEExtAdvertising.cpp:670
Callbacks associated with NimBLEExtAdvertising class.
Definition: NimBLEExtAdvertising.h:129
virtual void onStopped(NimBLEExtAdvertising *pAdv, int reason, uint8_t inst_id)
Handle an advertising stop event.
Definition: NimBLEExtAdvertising.cpp:368
virtual void onScanRequest(NimBLEExtAdvertising *pAdv, uint8_t inst_id, NimBLEAddress addr)
Handle a scan response request. This is called when a scanning device requests a scan response.
Definition: NimBLEExtAdvertising.cpp:374
Extended advertising class.
Definition: NimBLEExtAdvertising.h:92
bool setInstanceData(uint8_t inst_id, NimBLEExtAdvertisement &adv)
Register the extended advertisement data.
Definition: NimBLEExtAdvertising.cpp:44
bool stop()
Stop all advertisements.
Definition: NimBLEExtAdvertising.cpp:257
~NimBLEExtAdvertising()
Destructor: deletes callback instances if requested.
Definition: NimBLEExtAdvertising.cpp:31
bool start(uint8_t inst_id, int duration=0, int max_events=0)
Start extended advertising.
Definition: NimBLEExtAdvertising.cpp:154
bool isActive(uint8_t inst_id)
Check if currently advertising.
Definition: NimBLEExtAdvertising.cpp:294
bool removeAll()
Stop and remove all advertising instance data.
Definition: NimBLEExtAdvertising.cpp:220
bool setScanResponseData(uint8_t inst_id, NimBLEExtAdvertisement &data)
Set the scan response data for a legacy advertisement.
Definition: NimBLEExtAdvertising.cpp:128
bool isAdvertising()
Check if any instances are currently advertising.
Definition: NimBLEExtAdvertising.cpp:303
void setCallbacks(NimBLEExtAdvertisingCallbacks *callbacks, bool deleteCallbacks=true)
Set a callback to call when the advertisement stops.
Definition: NimBLEExtAdvertising.cpp:278
bool removeInstance(uint8_t inst_id)
Stop and remove this instance data from the advertisement set.
Definition: NimBLEExtAdvertising.cpp:201
NimBLEExtAdvertising()
Construct an extended advertising object.
Definition: NimBLEExtAdvertising.h:97
The model of a BLE server.
Definition: NimBLEServer.h:46
A model of a BLE UUID.
Definition: NimBLEUUID.h:37