ESPHome 2026.10.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
6
7static const char *const TAG = "airthings_ble";
8
10 for (auto &it : device.get_manufacturer_datas()) {
11 if (it.uuid == ble_device_base::ESPBTUUID::from_uint32(0x0334)) {
12 if (it.data.size() < 4)
13 continue;
14
15 uint32_t sn = it.data[0];
16 sn |= ((uint32_t) it.data[1] << 8);
17 sn |= ((uint32_t) it.data[2] << 16);
18 sn |= ((uint32_t) it.data[3] << 24);
19
20 char addr_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
21 ESP_LOGD(TAG, "Found AirThings device Serial:%" PRIu32 " (MAC: %s)", sn, device.address_str_to(addr_buf));
22 return true;
23 }
24 }
25
26 return false;
27}
28
29} // namespace esphome::airthings_ble
bool parse_device(const ble_device_base::ESPBTDevice &device) override
ESPDEPRECATED("Use address_str_to() instead. Removed in 2027.2.0.", "2026.8.0") std const char * address_str_to(char *buf) const
Return MAC as "XX:XX:XX:XX:XX:XX" string.
const std::vector< ServiceData > & get_manufacturer_datas() const
Definition ble_device.h:224
static ESPBTUUID from_uint32(uint32_t uuid)
static void uint32_t