Skip to content

Commit 34e08af

Browse files
committed
Add overload for NimBLEAdvertising::setManufacturerData.
Adds an overload for `NimBLEAdvertising::setManufacturerData` that takes a `const uint8_t*` and , size_t` paramter.
1 parent b21b15f commit 34e08af

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/NimBLEAdvertising.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ void NimBLEAdvertising::setName(const std::string& name) {
152152
m_advDataSet = false;
153153
} // setName
154154

155+
/**
156+
* @brief Set the advertised manufacturer data.
157+
* @param [in] data The data to advertise.
158+
* @param [in] length The length of the data.
159+
*/
160+
void NimBLEAdvertising::setManufacturerData(const uint8_t* data, size_t length) {
161+
std::vector<uint8_t>(data, data + length).swap(m_mfgData);
162+
m_advData.mfg_data = &m_mfgData[0];
163+
m_advData.mfg_data_len = m_mfgData.size();
164+
m_advDataSet = false;
165+
} // setManufacturerData
166+
155167
/**
156168
* @brief Set the advertised manufacturer data.
157169
* @param [in] data The data to advertise.

src/NimBLEAdvertising.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class NimBLEAdvertising {
9494
bool stop();
9595
void setAppearance(uint16_t appearance);
9696
void setName(const std::string& name);
97+
void setManufacturerData(const uint8_t* data, size_t length);
9798
void setManufacturerData(const std::string& data);
9899
void setManufacturerData(const std::vector<uint8_t>& data);
99100
void setURI(const std::string& uri);

0 commit comments

Comments
 (0)