ESPHome
2026.10.0-dev
Loading...
Searching...
No Matches
esphome
components
airthings_ble
airthings_listener.cpp
Go to the documentation of this file.
1
#include "
airthings_listener.h
"
2
#include "
esphome/core/log.h
"
3
#include <cinttypes>
4
5
namespace
esphome::airthings_ble
{
6
7
static
const
char
*
const
TAG =
"airthings_ble"
;
8
9
bool
AirthingsListener::parse_device
(
const
ble_device_base::ESPBTDevice
&device) {
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
airthings_listener.h
esphome::airthings_ble::AirthingsListener::parse_device
bool parse_device(const ble_device_base::ESPBTDevice &device) override
Definition
airthings_listener.cpp:9
esphome::ble_device_base::ESPBTDevice
Definition
ble_device.h:178
esphome::ble_device_base::ESPBTDevice::address_str_to
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.
Definition
ble_device.cpp:418
esphome::ble_device_base::ESPBTDevice::get_manufacturer_datas
const std::vector< ServiceData > & get_manufacturer_datas() const
Definition
ble_device.h:224
esphome::ble_device_base::ESPBTUUID::from_uint32
static ESPBTUUID from_uint32(uint32_t uuid)
Definition
ble_device.cpp:36
log.h
esphome::airthings_ble
Definition
airthings_listener.cpp:5
uint32_t
static void uint32_t
Definition
crash_handler.cpp:141
Generated by
1.12.0