Skip to content

Commit

Permalink
Add clearData method to NimBLEAdvertisementData.
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Jun 13, 2024
1 parent 5b2d72a commit 6eda06f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/NimBLEAdvertising.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
1 change: 1 addition & 0 deletions src/NimBLEAdvertising.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6eda06f

Please sign in to comment.