diff --git a/CHANGELOG.md b/CHANGELOG.md index e02b4675..f1bcb76d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - `NimBLEAdvertising::setManufacturerData` new overload method that accepts a vector of `uint8_t`. - `NimBLEAdvertisementData::setManufacturerData` new overload method that accepts a vector of `uint8_t`. - `NimBLEAdvertisedDevice` new method: `getPayloadByType`, to get data from generic data types advertised. + - `NimBLEAdvertisementData::clearData` clears the data for updating/reuse. ### Changed - `NimBLEAdvertisedDevice::getManufacturerData`, now takes an index value parameter to use when there is more than 1 instance of manufacturer data. diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index 0492e94b..abe471d9 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -1067,4 +1067,12 @@ std::string NimBLEAdvertisementData::getPayload() { return m_payload; } // getPayload + +/** + * @brief Clear the advertisement data for reuse. + */ +void NimBLEAdvertisementData::clearData() { + m_payload.clear(); +} + #endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV */ diff --git a/src/NimBLEAdvertising.h b/src/NimBLEAdvertising.h index 14c34662..907f7110 100644 --- a/src/NimBLEAdvertising.h +++ b/src/NimBLEAdvertising.h @@ -72,6 +72,7 @@ class NimBLEAdvertisementData { void addTxPower(); void setPreferredParams(uint16_t min, uint16_t max); std::string getPayload(); // Retrieve the current advert payload. + void clearData(); // Clear the advertisement data. private: friend class NimBLEAdvertising;