Skip to content

Commit 6eda06f

Browse files
committed
Add clearData method to NimBLEAdvertisementData.
1 parent 5b2d72a commit 6eda06f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
1818
- `NimBLEAdvertising::setManufacturerData` new overload method that accepts a vector of `uint8_t`.
1919
- `NimBLEAdvertisementData::setManufacturerData` new overload method that accepts a vector of `uint8_t`.
2020
- `NimBLEAdvertisedDevice` new method: `getPayloadByType`, to get data from generic data types advertised.
21+
- `NimBLEAdvertisementData::clearData` clears the data for updating/reuse.
2122

2223
### Changed
2324
- `NimBLEAdvertisedDevice::getManufacturerData`, now takes an index value parameter to use when there is more than 1 instance of manufacturer data.

src/NimBLEAdvertising.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,4 +1067,12 @@ std::string NimBLEAdvertisementData::getPayload() {
10671067
return m_payload;
10681068
} // getPayload
10691069

1070+
1071+
/**
1072+
* @brief Clear the advertisement data for reuse.
1073+
*/
1074+
void NimBLEAdvertisementData::clearData() {
1075+
m_payload.clear();
1076+
}
1077+
10701078
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV */

src/NimBLEAdvertising.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class NimBLEAdvertisementData {
7272
void addTxPower();
7373
void setPreferredParams(uint16_t min, uint16_t max);
7474
std::string getPayload(); // Retrieve the current advert payload.
75+
void clearData(); // Clear the advertisement data.
7576

7677
private:
7778
friend class NimBLEAdvertising;

0 commit comments

Comments
 (0)