ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
airthings_listener.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4#include <cinttypes>
5
7
8ESPHOME_LOG_TAG(TAG, "airthings_ble");
9
11 for (auto &it : device.get_manufacturer_datas()) {
12 if (it.uuid == ble_device_base::ESPBTUUID::from_uint32(0x0334)) {
13 if (it.data.size() < 4)
14 continue;
15
16 uint32_t sn = encode_value_le<uint32_t>(it.data.data());
17
18 char addr_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
19 ESP_LOGD(TAG, "Found AirThings device Serial:%" PRIu32 " (MAC: %s)", sn, device.address_str_to(addr_buf));
20 return true;
21 }
22 }
23
24 return false;
25}
26
27} // 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)
ESPHOME_LOG_TAG(TAG, "airthings_ble")
constexpr T encode_value_le(const uint8_t *bytes)
Encode a value from its constituent bytes (from least to most significant) in an array with length si...
Definition helpers.h:1056
static void uint32_t