ESPHome 2026.3.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
7namespace esphome {
8namespace airthings_ble {
9
10static 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 char addr_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
24 ESP_LOGD(TAG, "Found AirThings device Serial:%" PRIu32 " (MAC: %s)", sn, device.address_str_to(addr_buf));
25 return true;
26 }
27 }
28
29 return false;
30}
31
32} // namespace airthings_ble
33} // namespace esphome
34
35#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
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7