File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -25,18 +25,25 @@ static esp_ble_scan_params_t ble_scan_params = {
2525 };
2626
2727// check if the device was already discovered
28- bool alreadyDiscovered (esp_bd_addr_t address ) {
28+ bool alreadyDiscovered (esp_bd_addr_t address ){
2929
3030 bool found = false;
31-
31+
3232 for (int i = 0 ; i < discovered_devices_num ; i ++ ) {
33-
34- for (int j = 0 ; j < ESP_BD_ADDR_LEN ; j ++ )
35- found = (discovered_devices [i ][j ] == address [j ]);
36-
33+
34+ uint8_t alreadyFound [6 ] = {
35+ discovered_devices [i ][0 ],
36+ discovered_devices [i ][1 ],
37+ discovered_devices [i ][2 ],
38+ discovered_devices [i ][3 ],
39+ discovered_devices [i ][4 ],
40+ discovered_devices [i ][5 ]};
41+ // this way checks for all possible combinations of MAC addresses, instead of only last byte.
42+ if (memcmp (alreadyFound ,address ,6 ) == 0 ) found = true;
43+
3744 if (found ) break ;
3845 }
39-
46+
4047 return found ;
4148}
4249
@@ -139,4 +146,4 @@ void app_main() {
139146
140147 // configure scan parameters
141148 esp_ble_gap_set_scan_params (& ble_scan_params );
142- }
149+ }
You can’t perform that action at this time.
0 commit comments