@@ -44,34 +44,34 @@ void setup() {
4444
4545 // IRKs are keys that identify the true owner of a random mac address.
4646 // Add IRKs of devices you are bonded with.
47- BLE.setGetIRKs ([](uint8_t * nIRKs, uint8_t ** BADDR_TYPES , uint8_t *** BDAddrs, uint8_t *** IRKs){
47+ BLE.setGetIRKs ([](uint8_t * nIRKs, uint8_t ** BDaddrTypes , uint8_t *** BDAddrs, uint8_t *** IRKs){
4848 // Set to number of devices
4949 *nIRKs = 2 ;
5050
5151 *BDAddrs = new uint8_t *[*nIRKs];
5252 *IRKs = new uint8_t *[*nIRKs];
53- *BADDR_TYPES = new uint8_t [*nIRKs];
53+ *BDaddrTypes = new uint8_t [*nIRKs];
5454
5555 // Set these to the mac and IRK for your bonded devices as printed in the serial console after bonding.
56- uint8_t iPhoneMac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
57- uint8_t iPhoneIRK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
56+ uint8_t device1Mac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
57+ uint8_t device1IRK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
5858
59- uint8_t iPadMac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
60- uint8_t iPadIRK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , };
59+ uint8_t device2Mac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
60+ uint8_t device2IRK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
6161
6262
63- (*BADDR_TYPES)[0 ] = 0 ;
64- (*IRKs)[0 ] = new uint8_t [16 ];
65- memcpy ((*IRKs)[0 ],iPhoneIRK,16 );
63+ (*BDaddrTypes)[0 ] = 0 ; // Type 0 is for pubc address, type 1 is for static random
6664 (*BDAddrs)[0 ] = new uint8_t [6 ];
67- memcpy ((*BDAddrs)[0 ], iPhoneMac, 6 );
65+ (*IRKs)[0 ] = new uint8_t [16 ];
66+ memcpy ((*IRKs)[0 ] , device1IRK,16 );
67+ memcpy ((*BDAddrs)[0 ], device1Mac, 6 );
6868
6969
70- (*BADDR_TYPES)[1 ] = 0 ;
71- (*IRKs)[1 ] = new uint8_t [16 ];
72- memcpy ((*IRKs)[1 ],iPadIRK,16 );
70+ (*BDaddrTypes)[1 ] = 0 ;
7371 (*BDAddrs)[1 ] = new uint8_t [6 ];
74- memcpy ((*BDAddrs)[1 ], iPadMac, 6 );
72+ (*IRKs)[1 ] = new uint8_t [16 ];
73+ memcpy ((*IRKs)[1 ] , device2IRK,16 );
74+ memcpy ((*BDAddrs)[1 ], device2Mac, 6 );
7575
7676
7777 return 1 ;
@@ -83,17 +83,18 @@ void setup() {
8383 btct.printBytes (address,6 );
8484
8585 // Set these to the MAC and LTK of your devices after bonding.
86- uint8_t iPhoneMac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
87- uint8_t iPhoneLTK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
88- uint8_t iPadMac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
89- uint8_t iPadLTK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
86+ uint8_t device1Mac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
87+ uint8_t device1LTK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
88+ uint8_t device2Mac [6 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
89+ uint8_t device2LTK [16 ] = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
9090
9191
92- if (memcmp (iPhoneMac, address, 6 )==0 ){
93- memcpy (LTK, iPhoneLTK, 16 );
92+ if (memcmp (device1Mac, address, 6 ) == 0 ) {
93+ memcpy (LTK, device1LTK, 16 );
94+ return 1 ;
95+ }else if (memcmp (device2Mac, address, 6 ) == 0 ) {
96+ memcpy (LTK, device2LTK, 16 );
9497 return 1 ;
95- }else if (memcmp (iPadMac, address, 6 )==0 ){
96- memcpy (LTK, iPadLTK, 16 );
9798 }
9899 return 0 ;
99100 });
@@ -112,7 +113,8 @@ void setup() {
112113 return 1 ;
113114 });
114115
115- while (1 ){// begin initialization
116+ while (1 ){
117+ // begin initialization
116118 if (!BLE.begin ()) {
117119 Serial.println (" starting BLE failed!" );
118120 delay (200 );
@@ -135,7 +137,7 @@ void setup() {
135137 batteryService.addCharacteristic (stringcharacteristic);
136138 batteryService.addCharacteristic (secretValue);
137139
138- BLE.addService (batteryService); // Add the battery service
140+ BLE.addService (batteryService); // Add the battery service
139141 batteryLevelChar.writeValue (oldBatteryLevel); // set initial value for this characteristic
140142 char * stringCharValue = new char [32 ];
141143 stringCharValue = " string" ;
0 commit comments