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 @@ -60,6 +60,15 @@ int BLELocalDevice::begin()
6060   * Force both MSB bits to b00 in order to define Static Random Address 
6161   */  
6262  randomNumber[5 ] |= 0xC0 ;
63+ 
64+   //  Copy the random address in private variable as it will be sent to the BLE chip
65+   randomAddress [0 ] = randomNumber[0 ];
66+   randomAddress [1 ] = randomNumber[1 ];
67+   randomAddress [2 ] = randomNumber[2 ];
68+   randomAddress [3 ] = randomNumber[3 ];
69+   randomAddress [4 ] = randomNumber[4 ];
70+   randomAddress [5 ] = randomNumber[5 ];
71+ 
6372  if  (HCI.leSetRandomAddress ((uint8_t *)randomNumber) != 0 ) {
6473    end ();
6574    return  0 ;
@@ -105,6 +114,16 @@ void BLELocalDevice::end()
105114  HCI.end ();
106115}
107116
117+ void  BLELocalDevice::getRandomAddress (uint8_t  buff[6 ])
118+ {
119+   buff [0 ] = randomAddress[0 ];
120+   buff [1 ] = randomAddress[1 ];
121+   buff [2 ] = randomAddress[2 ];
122+   buff [3 ] = randomAddress[3 ];
123+   buff [4 ] = randomAddress[4 ];
124+   buff [5 ] = randomAddress[5 ];
125+ }
126+ 
108127void  BLELocalDevice::poll ()
109128{
110129  HCI.poll ();
Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ class BLELocalDevice {
8484
8585  virtual  void  setTimeout (unsigned  long  timeout);
8686
87+   virtual  void  getRandomAddress (uint8_t  buff[6 ]);
88+ 
8789  virtual  void  debug (Stream& stream);
8890  virtual  void  noDebug ();
8991
@@ -92,6 +94,7 @@ class BLELocalDevice {
9294  virtual  BLEAdvertisingData& getScanResponseData ();
9395
9496private: 
97+   uint8_t  randomAddress[6 ];
9598  HCITransportInterface *_HCITransport;
9699  BLEAdvertisingData _advertisingData;
97100  BLEAdvertisingData _scanResponseData;
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments