From 240590a0f52da596fa24a042e1fa2956a931c61c Mon Sep 17 00:00:00 2001 From: Lorenzo Bini Date: Tue, 14 Mar 2023 17:19:12 +0100 Subject: [PATCH 1/2] Add API to get random address --- src/local/BLELocalDevice.cpp | 19 +++++++++++++++++++ src/local/BLELocalDevice.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/local/BLELocalDevice.cpp b/src/local/BLELocalDevice.cpp index b5869b5a..60519dc6 100644 --- a/src/local/BLELocalDevice.cpp +++ b/src/local/BLELocalDevice.cpp @@ -60,6 +60,15 @@ int BLELocalDevice::begin() * Force both MSB bits to b00 in order to define Static Random Address */ randomNumber[5] |= 0xC0; + + // Copy the random address in private variable as it will be sent to the BLE chip + randomAddress [0] = randomNumber[0]; + randomAddress [1] = randomNumber[1]; + randomAddress [2] = randomNumber[2]; + randomAddress [3] = randomNumber[3]; + randomAddress [4] = randomNumber[4]; + randomAddress [5] = randomNumber[5]; + if (HCI.leSetRandomAddress((uint8_t*)randomNumber) != 0) { end(); return 0; @@ -105,6 +114,16 @@ void BLELocalDevice::end() HCI.end(); } +void BLELocalDevice::getRandomAddress(uint8_t buff[6]) +{ + buff [0] = randomAddress[0]; + buff [1] = randomAddress[1]; + buff [2] = randomAddress[2]; + buff [3] = randomAddress[3]; + buff [4] = randomAddress[4]; + buff [5] = randomAddress[5]; +} + void BLELocalDevice::poll() { HCI.poll(); diff --git a/src/local/BLELocalDevice.h b/src/local/BLELocalDevice.h index beddb0ee..f0cc345c 100644 --- a/src/local/BLELocalDevice.h +++ b/src/local/BLELocalDevice.h @@ -84,6 +84,8 @@ class BLELocalDevice { virtual void setTimeout(unsigned long timeout); + virtual void getRandomAddress(uint8_t buff[6]); + virtual void debug(Stream& stream); virtual void noDebug(); @@ -92,6 +94,7 @@ class BLELocalDevice { virtual BLEAdvertisingData& getScanResponseData(); private: + uint8_t randomAddress[6]; HCITransportInterface *_HCITransport; BLEAdvertisingData _advertisingData; BLEAdvertisingData _scanResponseData; From b0a1849df65d570672be178dffdbcfa7aa144b09 Mon Sep 17 00:00:00 2001 From: Carlo Parata Date: Fri, 17 Mar 2023 09:57:50 +0100 Subject: [PATCH 2/2] Update library.properties Signed-off-by: Carlo Parata --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index e36e566c..16bc2da4 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duinoBLE -version=1.2.2 +version=1.2.3 author=Arduino, SRA maintainer=stm32duino sentence=Fork of ArduinoBLE library to add the support of STM32WB, SPBTLE-RF, SPBTLE-1S, BLUENRG-M2SP and BLUENRG-M0 BLE modules. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy