@@ -44,34 +44,34 @@ void setup() {
44
44
45
45
// IRKs are keys that identify the true owner of a random mac address.
46
46
// 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){
48
48
// Set to number of devices
49
49
*nIRKs = 2 ;
50
50
51
51
*BDAddrs = new uint8_t *[*nIRKs];
52
52
*IRKs = new uint8_t *[*nIRKs];
53
- *BADDR_TYPES = new uint8_t [*nIRKs];
53
+ *BDaddrTypes = new uint8_t [*nIRKs];
54
54
55
55
// 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 };
58
58
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 };
61
61
62
62
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
66
64
(*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 );
68
68
69
69
70
- (*BADDR_TYPES)[1 ] = 0 ;
71
- (*IRKs)[1 ] = new uint8_t [16 ];
72
- memcpy ((*IRKs)[1 ],iPadIRK,16 );
70
+ (*BDaddrTypes)[1 ] = 0 ;
73
71
(*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 );
75
75
76
76
77
77
return 1 ;
@@ -83,17 +83,18 @@ void setup() {
83
83
btct.printBytes (address,6 );
84
84
85
85
// 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 };
90
90
91
91
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 );
94
97
return 1 ;
95
- }else if (memcmp (iPadMac, address, 6 )==0 ){
96
- memcpy (LTK, iPadLTK, 16 );
97
98
}
98
99
return 0 ;
99
100
});
@@ -112,7 +113,8 @@ void setup() {
112
113
return 1 ;
113
114
});
114
115
115
- while (1 ){// begin initialization
116
+ while (1 ){
117
+ // begin initialization
116
118
if (!BLE.begin ()) {
117
119
Serial.println (" starting BLE failed!" );
118
120
delay (200 );
@@ -135,7 +137,7 @@ void setup() {
135
137
batteryService.addCharacteristic (stringcharacteristic);
136
138
batteryService.addCharacteristic (secretValue);
137
139
138
- BLE.addService (batteryService); // Add the battery service
140
+ BLE.addService (batteryService); // Add the battery service
139
141
batteryLevelChar.writeValue (oldBatteryLevel); // set initial value for this characteristic
140
142
char * stringCharValue = new char [32 ];
141
143
stringCharValue = " string" ;
0 commit comments