mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-23 05:30:54 +01:00
Add overload for NimBLEAdvertising::setManufacturerData
.
Adds an overload for `NimBLEAdvertising::setManufacturerData` that takes a `const uint8_t*` and , size_t` paramter.
This commit is contained in:
parent
d3ae7153a3
commit
fab7106bce
2 changed files with 13 additions and 6 deletions
|
@ -151,23 +151,29 @@ void NimBLEAdvertising::setName(const std::string& name) {
|
||||||
/**
|
/**
|
||||||
* @brief Set the advertised manufacturer data.
|
* @brief Set the advertised manufacturer data.
|
||||||
* @param [in] data The data to advertise.
|
* @param [in] data The data to advertise.
|
||||||
|
* @param [in] length The length of the data.
|
||||||
*/
|
*/
|
||||||
void NimBLEAdvertising::setManufacturerData(const std::string& data) {
|
void NimBLEAdvertising::setManufacturerData(const uint8_t* data, size_t length) {
|
||||||
std::vector<uint8_t>(data.begin(), data.end()).swap(m_mfgData);
|
std::vector<uint8_t>(data, data + length).swap(m_mfgData);
|
||||||
m_advData.mfg_data = &m_mfgData[0];
|
m_advData.mfg_data = &m_mfgData[0];
|
||||||
m_advData.mfg_data_len = m_mfgData.size();
|
m_advData.mfg_data_len = m_mfgData.size();
|
||||||
m_advDataSet = false;
|
m_advDataSet = false;
|
||||||
} // setManufacturerData
|
} // setManufacturerData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the advertised manufacturer data.
|
||||||
|
* @param [in] data The data to advertise.
|
||||||
|
*/
|
||||||
|
void NimBLEAdvertising::setManufacturerData(const std::string& data) {
|
||||||
|
setManufacturerData(reinterpret_cast<const uint8_t*>(data.data()), data.length());
|
||||||
|
} // setManufacturerData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the advertised manufacturer data.
|
* @brief Set the advertised manufacturer data.
|
||||||
* @param [in] data The data to advertise.
|
* @param [in] data The data to advertise.
|
||||||
*/
|
*/
|
||||||
void NimBLEAdvertising::setManufacturerData(const std::vector<uint8_t>& data) {
|
void NimBLEAdvertising::setManufacturerData(const std::vector<uint8_t>& data) {
|
||||||
std::vector<uint8_t>(data.begin(), data.end()).swap(m_mfgData);
|
setManufacturerData(&data[0], data.size());
|
||||||
m_advData.mfg_data = &m_mfgData[0];
|
|
||||||
m_advData.mfg_data_len = m_mfgData.size();
|
|
||||||
m_advDataSet = false;
|
|
||||||
} // setManufacturerData
|
} // setManufacturerData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -94,6 +94,7 @@ class NimBLEAdvertising {
|
||||||
bool stop();
|
bool stop();
|
||||||
void setAppearance(uint16_t appearance);
|
void setAppearance(uint16_t appearance);
|
||||||
void setName(const std::string& name);
|
void setName(const std::string& name);
|
||||||
|
void setManufacturerData(const uint8_t* data, size_t length);
|
||||||
void setManufacturerData(const std::string& data);
|
void setManufacturerData(const std::string& data);
|
||||||
void setManufacturerData(const std::vector<uint8_t>& data);
|
void setManufacturerData(const std::vector<uint8_t>& data);
|
||||||
void setURI(const std::string& uri);
|
void setURI(const std::string& uri);
|
||||||
|
|
Loading…
Reference in a new issue