File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,15 @@ int BLELocalDevice::begin()
133133 * Force both MSB bits to b00 in order to define Static Random Address
134134 */
135135 randomNumber[5 ] |= 0xC0 ;
136+
137+ // Copy the random address in private variable as it will be sent to the BLE chip
138+ randomAddress [0 ] = randomNumber[0 ];
139+ randomAddress [1 ] = randomNumber[1 ];
140+ randomAddress [2 ] = randomNumber[2 ];
141+ randomAddress [3 ] = randomNumber[3 ];
142+ randomAddress [4 ] = randomNumber[4 ];
143+ randomAddress [5 ] = randomNumber[5 ];
144+
136145 if (HCI.leSetRandomAddress ((uint8_t *)randomNumber) != 0 ) {
137146 end ();
138147 return 0 ;
@@ -247,6 +256,16 @@ void BLELocalDevice::end()
247256 _scanResponseData.clear ();
248257}
249258
259+ void BLELocalDevice::getRandomAddress (uint8_t buff[6 ])
260+ {
261+ buff [0 ] = randomAddress[0 ];
262+ buff [1 ] = randomAddress[1 ];
263+ buff [2 ] = randomAddress[2 ];
264+ buff [3 ] = randomAddress[3 ];
265+ buff [4 ] = randomAddress[4 ];
266+ buff [5 ] = randomAddress[5 ];
267+ }
268+
250269void BLELocalDevice::poll ()
251270{
252271 HCI.poll ();
Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ class BLELocalDevice {
9191
9292 virtual void setTimeout (unsigned long timeout);
9393
94+ virtual void getRandomAddress (uint8_t buff[6 ]);
95+
9496 virtual void debug (Stream& stream);
9597 virtual void noDebug ();
9698
@@ -122,6 +124,7 @@ class BLELocalDevice {
122124 virtual BLEAdvertisingData& getScanResponseData ();
123125
124126private:
127+ uint8_t randomAddress[6 ];
125128 BLEAdvertisingData _advertisingData;
126129 BLEAdvertisingData _scanResponseData;
127130 uint8_t _ownBdaddrType;
You can’t perform that action at this time.
0 commit comments