File tree 2 files changed +72
-0
lines changed
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
184
184
return serviceUuid;
185
185
}
186
186
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
+
187
251
int BLEDevice::rssi ()
188
252
{
189
253
uint16_t handle = ATT.connectionHandle (_addressType, _address);
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ class BLEDevice {
59
59
String advertisedServiceUuid () const ;
60
60
String advertisedServiceUuid (int index) const ;
61
61
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
+
62
70
virtual int rssi ();
63
71
64
72
bool connect ();
You can’t perform that action at this time.
0 commit comments