ESPHome  2024.3.1
airthings_listener.cpp
Go to the documentation of this file.
1 #include "airthings_listener.h"
2 #include "esphome/core/log.h"
3 #include <cinttypes>
4 
5 #ifdef USE_ESP32
6 
7 namespace esphome {
8 namespace airthings_ble {
9 
10 static const char *const TAG = "airthings_ble";
11 
13  for (auto &it : device.get_manufacturer_datas()) {
14  if (it.uuid == esp32_ble_tracker::ESPBTUUID::from_uint32(0x0334)) {
15  if (it.data.size() < 4)
16  continue;
17 
18  uint32_t sn = it.data[0];
19  sn |= ((uint32_t) it.data[1] << 8);
20  sn |= ((uint32_t) it.data[2] << 16);
21  sn |= ((uint32_t) it.data[3] << 24);
22 
23  ESP_LOGD(TAG, "Found AirThings device Serial:%" PRIu32 " (MAC: %s)", sn, device.address_str().c_str());
24  return true;
25  }
26  }
27 
28  return false;
29 }
30 
31 } // namespace airthings_ble
32 } // namespace esphome
33 
34 #endif
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override
const std::vector< ServiceData > & get_manufacturer_datas() const
static ESPBTUUID from_uint32(uint32_t uuid)
Definition: ble_uuid.cpp:22
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7