From cb3994912fe00dfab2bb2794d5a42269e8ed3fa3 Mon Sep 17 00:00:00 2001 From: Laurence Bank Date: Sat, 27 Feb 2021 19:39:35 -0500 Subject: [PATCH] Added missing method to access raw scan advertisement data --- src/BLEDevice.cpp | 10 ++++++++++ src/BLEDevice.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/BLEDevice.cpp b/src/BLEDevice.cpp index fa806104..32783cd7 100644 --- a/src/BLEDevice.cpp +++ b/src/BLEDevice.cpp @@ -184,6 +184,16 @@ String BLEDevice::advertisedServiceUuid(int index) const return serviceUuid; } +int BLEDevice::getRawAdvertisement(uint8_t *value, int max_length) +{ + if (_eirDataLength <= max_length) { + memcpy(value, _eirData, _eirDataLength); + return _eirDataLength; + } + + return 0; // buffer too small +} + int BLEDevice::rssi() { uint16_t handle = ATT.connectionHandle(_addressType, _address); diff --git a/src/BLEDevice.h b/src/BLEDevice.h index cbe79c71..59cc5272 100644 --- a/src/BLEDevice.h +++ b/src/BLEDevice.h @@ -84,6 +84,7 @@ class BLEDevice { BLECharacteristic characteristic(int index) const; BLECharacteristic characteristic(const char * uuid) const; BLECharacteristic characteristic(const char * uuid, int index) const; + int getRawAdvertisement(uint8_t *value, int length); protected: friend class ATTClass;