ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
airthings_listener.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3#include <cinttypes>
4
5#ifdef USE_ESP32
6
8
9static const char *const TAG = "airthings_ble";
10
12 for (auto &it : device.get_manufacturer_datas()) {
13 if (it.uuid == esp32_ble_tracker::ESPBTUUID::from_uint32(0x0334)) {
14 if (it.data.size() < 4)
15 continue;
16
17 uint32_t sn = it.data[0];
18 sn |= ((uint32_t) it.data[1] << 8);
19 sn |= ((uint32_t) it.data[2] << 16);
20 sn |= ((uint32_t) it.data[3] << 24);
21
22 char addr_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
23 ESP_LOGD(TAG, "Found AirThings device Serial:%" PRIu32 " (MAC: %s)", sn, device.address_str_to(addr_buf));
24 return true;
25 }
26 }
27
28 return false;
29}
30
31} // namespace esphome::airthings_ble
32
33#endif
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override
const char * address_str_to(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf) const
Format MAC address into provided buffer, returns pointer to buffer for convenience.
const std::vector< ServiceData > & get_manufacturer_datas() const
static void uint32_t