Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions 23_ble_scan/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,25 @@ static esp_ble_scan_params_t ble_scan_params = {
};

// check if the device was already discovered
bool alreadyDiscovered(esp_bd_addr_t address) {
bool alreadyDiscovered(esp_bd_addr_t address){

bool found = false;

for(int i = 0; i < discovered_devices_num; i++) {

for(int j = 0; j < ESP_BD_ADDR_LEN; j++)
found = (discovered_devices[i][j] == address[j]);


uint8_t alreadyFound[6] = {
discovered_devices[i][0],
discovered_devices[i][1],
discovered_devices[i][2],
discovered_devices[i][3],
discovered_devices[i][4],
discovered_devices[i][5]};
// this way checks for all possible combinations of MAC addresses, instead of only last byte.
if(memcmp(alreadyFound,address,6) == 0) found = true;

if(found) break;
}

return found;
}

Expand Down Expand Up @@ -139,4 +146,4 @@ void app_main() {

// configure scan parameters
esp_ble_gap_set_scan_params(&ble_scan_params);
}
}