mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-24 22:20:55 +01:00
Advertising: Add overloaded method for addData.
* Implements addData(char * data, size_t length) as an alternative to passing a std::string.
This commit is contained in:
parent
4723b1cc53
commit
f1a13d5949
2 changed files with 14 additions and 0 deletions
|
@ -451,6 +451,19 @@ void NimBLEAdvertisementData::addData(const std::string &data) {
|
||||||
} // addData
|
} // addData
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add data to the payload to be advertised.
|
||||||
|
* @param [in] data The data to be added to the payload.
|
||||||
|
* @param [in] length The size of data to be added to the payload.
|
||||||
|
*/
|
||||||
|
void NimBLEAdvertisementData::addData(char * data, size_t length){
|
||||||
|
if ((m_payload.length() + length) > BLE_HS_ADV_MAX_SZ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_payload.append(data,length);
|
||||||
|
} // addData
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the appearance.
|
* @brief Set the appearance.
|
||||||
* @param [in] appearance The appearance code value.
|
* @param [in] appearance The appearance code value.
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
void setServiceData(const NimBLEUUID &uuid, const std::string &data);
|
void setServiceData(const NimBLEUUID &uuid, const std::string &data);
|
||||||
void setShortName(const std::string &name);
|
void setShortName(const std::string &name);
|
||||||
void addData(const std::string &data); // Add data to the payload.
|
void addData(const std::string &data); // Add data to the payload.
|
||||||
|
void addData(char * data, size_t length);
|
||||||
std::string getPayload(); // Retrieve the current advert payload.
|
std::string getPayload(); // Retrieve the current advert payload.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue