File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,18 @@ void NimBLEAdvertising::setManufacturerData(const std::string &data) {
156156} // setManufacturerData
157157
158158
159+ /* *
160+ * @brief Set the advertised manufacturer data.
161+ * @param [in] data The data to advertise.
162+ */
163+ void NimBLEAdvertising::setManufacturerData (const std::vector<uint8_t > &data) {
164+ m_mfgData = data;
165+ m_advData.mfg_data = &m_mfgData[0 ];
166+ m_advData.mfg_data_len = m_mfgData.size ();
167+ m_advDataSet = false ;
168+ } // setManufacturerData
169+
170+
159171/* *
160172 * @brief Set the advertised URI.
161173 * @param [in] uri The URI to advertise.
@@ -831,6 +843,18 @@ void NimBLEAdvertisementData::setManufacturerData(const std::string &data) {
831843} // setManufacturerData
832844
833845
846+ /* *
847+ * @brief Set manufacturer specific data.
848+ * @param [in] data The manufacturer data to advertise.
849+ */
850+ void NimBLEAdvertisementData::setManufacturerData (const std::vector<uint8_t > &data) {
851+ char cdata[2 ];
852+ cdata[0 ] = data.size () + 1 ;
853+ cdata[1 ] = BLE_HS_ADV_TYPE_MFG_DATA ; // 0xff
854+ addData (std::string (cdata, 2 ) + std::string ((char *)&data[0 ], data.size ()));
855+ } // setManufacturerData
856+
857+
834858/* *
835859 * @brief Set the URI to advertise.
836860 * @param [in] uri The uri to advertise.
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ class NimBLEAdvertisementData {
5959 void setCompleteServices32 (const std::vector<NimBLEUUID> &v_uuid);
6060 void setFlags (uint8_t );
6161 void setManufacturerData (const std::string &data);
62+ void setManufacturerData (const std::vector<uint8_t > &data);
6263 void setURI (const std::string &uri);
6364 void setName (const std::string &name);
6465 void setPartialServices (const NimBLEUUID &uuid);
@@ -96,6 +97,7 @@ class NimBLEAdvertising {
9697 void setAppearance (uint16_t appearance);
9798 void setName (const std::string &name);
9899 void setManufacturerData (const std::string &data);
100+ void setManufacturerData (const std::vector<uint8_t > &data);
99101 void setURI (const std::string &uri);
100102 void setServiceData (const NimBLEUUID &uuid, const std::string &data);
101103 void setAdvertisementType (uint8_t adv_type);
You can’t perform that action at this time.
0 commit comments