Skip to content

Commit 47c3cd5

Browse files
committed
Refresh advertising data dynamically
1 parent 2de3c31 commit 47c3cd5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/NimBLEAdvertising.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,22 @@ void NimBLEAdvertising::clearData() {
385385
m_advDataSet = false;
386386
} // clearData
387387

388+
/**
389+
* @brief Refresh advertsing data dynamically without stop/start cycle.
390+
* For instance allows refreshing manufacturer data dynamically.
391+
*
392+
* @return True if the data was set successfully.
393+
* @details If scan response is enabled it will be refreshed as well.
394+
*/
395+
bool NimBLEAdvertising::refreshAdvertisingData() {
396+
bool success = setAdvertisementData(m_advData);
397+
if (m_scanResp) {
398+
success = setScanResponseData(m_scanData);
399+
}
400+
401+
return success;
402+
} // refreshAdvertisingData
403+
388404
/**
389405
* @brief Add a service uuid to exposed list of services.
390406
* @param [in] serviceUUID The UUID of the service to expose.

src/NimBLEAdvertising.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class NimBLEAdvertising {
6767
const NimBLEAdvertisementData& getAdvertisementData();
6868
const NimBLEAdvertisementData& getScanData();
6969
void clearData();
70+
bool refreshAdvertisingData();
7071

7172
bool addServiceUUID(const NimBLEUUID& serviceUUID);
7273
bool addServiceUUID(const char* serviceUUID);

0 commit comments

Comments
 (0)