diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index 40e94556..50a9e898 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -156,6 +156,18 @@ void NimBLEAdvertising::setManufacturerData(const std::string &data) { } // setManufacturerData +/** + * @brief Set the advertised manufacturer data. + * @param [in] data The data to advertise. + */ +void NimBLEAdvertising::setManufacturerData(const std::vector &data) { + m_mfgData = data; + m_advData.mfg_data = &m_mfgData[0]; + m_advData.mfg_data_len = m_mfgData.size(); + m_advDataSet = false; +} // setManufacturerData + + /** * @brief Set the advertised URI. * @param [in] uri The URI to advertise. @@ -828,6 +840,18 @@ void NimBLEAdvertisementData::setManufacturerData(const std::string &data) { } // setManufacturerData +/** + * @brief Set manufacturer specific data. + * @param [in] data The manufacturer data to advertise. + */ +void NimBLEAdvertisementData::setManufacturerData(const std::vector &data) { + char cdata[2]; + cdata[0] = data.size() + 1; + cdata[1] = BLE_HS_ADV_TYPE_MFG_DATA ; // 0xff + addData(std::string(cdata, 2) + std::string((char*)&data[0], data.size())); +} // setManufacturerData + + /** * @brief Set the URI to advertise. * @param [in] uri The uri to advertise. diff --git a/src/NimBLEAdvertising.h b/src/NimBLEAdvertising.h index 4d054706..14c34662 100644 --- a/src/NimBLEAdvertising.h +++ b/src/NimBLEAdvertising.h @@ -59,6 +59,7 @@ class NimBLEAdvertisementData { void setCompleteServices32(const std::vector &v_uuid); void setFlags(uint8_t); void setManufacturerData(const std::string &data); + void setManufacturerData(const std::vector &data); void setURI(const std::string &uri); void setName(const std::string &name); void setPartialServices(const NimBLEUUID &uuid); @@ -96,6 +97,7 @@ class NimBLEAdvertising { void setAppearance(uint16_t appearance); void setName(const std::string &name); void setManufacturerData(const std::string &data); + void setManufacturerData(const std::vector &data); void setURI(const std::string &uri); void setServiceData(const NimBLEUUID &uuid, const std::string &data); void setAdvertisementType(uint8_t adv_type);