| 38 | } |
| 39 | |
| 40 | void ScannerData::addDevice( |
| 41 | const String &name, const String &address, int rssi, bool fastPair, bool hasHFP, uint8_t type |
| 42 | ) { |
| 43 | if (xSemaphoreTake(mutex, portMAX_DELAY)) { |
| 44 | bool isDuplicate = false; |
| 45 | for (size_t i = 0; i < deviceAddresses.size(); i++) { |
| 46 | if (deviceAddresses[i] == address) { |
| 47 | isDuplicate = true; |
| 48 | deviceRssi[i] = rssi; |
| 49 | break; |
| 50 | } |
| 51 | } |
| 52 | if (!isDuplicate) { |
| 53 | deviceNames.push_back(name); |
| 54 | deviceAddresses.push_back(address); |
| 55 | deviceRssi.push_back(rssi); |
| 56 | deviceFastPair.push_back(fastPair); |
| 57 | deviceHasHFP.push_back(hasHFP); |
| 58 | deviceTypes.push_back(type); |
| 59 | foundCount++; |
| 60 | } |
| 61 | xSemaphoreGive(mutex); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void ScannerData::clear() { |
| 66 | if (xSemaphoreTake(mutex, portMAX_DELAY)) { |
no test coverage detected