File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,70 @@ String BLEDevice::advertisedServiceUuid(int index) const
184184 return serviceUuid;
185185}
186186
187+ bool BLEDevice::hasAdvertisementData () const
188+ {
189+ return (_eirDataLength > 0 );
190+ }
191+
192+ int BLEDevice::advertisementDataLength () const
193+ {
194+ return _eirDataLength;
195+ }
196+
197+ int BLEDevice::advertisementData (uint8_t value[], int length) const
198+ {
199+ if (length > _eirDataLength) length = _eirDataLength;
200+
201+ if (length) {
202+ memcpy (value, _eirData, length);
203+ }
204+
205+ return length;
206+ }
207+
208+ bool BLEDevice::hasManufacturerData () const
209+ {
210+ return (manufacturerDataLength () > 0 );
211+ }
212+
213+ int BLEDevice::manufacturerDataLength () const
214+ {
215+ int length = 0 ;
216+
217+ for (int i = 0 ; i < _eirDataLength;) {
218+ int eirLength = _eirData[i++];
219+ int eirType = _eirData[i++];
220+
221+ if (eirType == 0xFF ) {
222+ length = (eirLength - 1 );
223+ break ;
224+ }
225+
226+ i += (eirLength - 1 );
227+ }
228+
229+ return length;
230+ }
231+
232+ int BLEDevice::manufacturerData (uint8_t value[], int length) const
233+ {
234+ for (int i = 0 ; i < _eirDataLength;) {
235+ int eirLength = _eirData[i++];
236+ int eirType = _eirData[i++];
237+
238+ if (eirType == 0xFF ) {
239+ if (length > (eirLength - 1 )) length = (eirLength - 1 );
240+
241+ memcpy (value, &_eirData[i], length);
242+ break ;
243+ }
244+
245+ i += (eirLength - 1 );
246+ }
247+
248+ return length;
249+ }
250+
187251int BLEDevice::rssi ()
188252{
189253 uint16_t handle = ATT.connectionHandle (_addressType, _address);
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ class BLEDevice {
5959 String advertisedServiceUuid () const ;
6060 String advertisedServiceUuid (int index) const ;
6161
62+ bool hasAdvertisementData () const ;
63+ int advertisementDataLength () const ;
64+ int advertisementData (uint8_t value[], int length) const ;
65+
66+ bool hasManufacturerData () const ;
67+ int manufacturerDataLength () const ;
68+ int manufacturerData (uint8_t value[], int length) const ;
69+
6270 virtual int rssi ();
6371
6472 bool connect ();
You can’t perform that action at this time.
0 commit comments