diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index fbe88ae..f626cc7 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -451,6 +451,19 @@ void NimBLEAdvertisementData::addData(const std::string &data) { } // 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. * @param [in] appearance The appearance code value. diff --git a/src/NimBLEAdvertising.h b/src/NimBLEAdvertising.h index 4ac013a..ed0ffc1 100644 --- a/src/NimBLEAdvertising.h +++ b/src/NimBLEAdvertising.h @@ -57,6 +57,7 @@ public: void setServiceData(const NimBLEUUID &uuid, const std::string &data); void setShortName(const std::string &name); 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. private: