ESPHome  2024.10.2
radon_eye_listener.cpp
Go to the documentation of this file.
1 #include "radon_eye_listener.h"
2 #include "esphome/core/log.h"
3 #include <algorithm>
4 #include <vector>
5 
6 #ifdef USE_ESP32
7 
8 namespace esphome {
9 namespace radon_eye_ble {
10 
11 static const char *const TAG = "radon_eye_ble";
12 
14  if (not device.get_name().empty()) {
15  // Vector containing the prefixes to search for
16  std::vector<std::string> prefixes = {"FR:R", "FR:I", "FR:H"};
17 
18  // Check if the device name starts with any of the prefixes
19  if (std::any_of(prefixes.begin(), prefixes.end(),
20  [&](const std::string &prefix) { return device.get_name().rfind(prefix, 0) == 0; })) {
21  // Device found
22  ESP_LOGD(TAG, "Found Radon Eye device Name: %s (MAC: %s)", device.get_name().c_str(),
23  device.address_str().c_str());
24  }
25  }
26  return false;
27 }
28 
29 } // namespace radon_eye_ble
30 } // namespace esphome
31 
32 #endif
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
const std::string & get_name() const