ESPHome 2025.5.2
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 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
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7