ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
bthome_mithermometer
bthome_ble.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/components/ble_device_base/ble_device.h
"
4
#include "
esphome/components/sensor/sensor.h
"
5
#include "
esphome/core/component.h
"
6
7
#include <cstdint>
8
#include <initializer_list>
9
#include <vector>
10
11
// No platform #ifdef: ble_device_base provides the BLE types on every platform; this
12
// component is only compiled when configured (which requires a BLE hub). bindkey (AES-CCM)
13
// decryption availability is selected per platform in the .cpp.
14
namespace
esphome::bthome_mithermometer
{
15
16
class
BTHomeMiThermometer
final :
public
ble_device_base::ESPBTDeviceListener
,
public
Component
{
17
SUB_SENSOR(
temperature
)
18
SUB_SENSOR(humidity)
19
SUB_SENSOR(battery_level)
20
SUB_SENSOR(battery_voltage)
21
SUB_SENSOR(signal_strength)
22
23
public
:
24
void
set_address(uint64_t
address
) { this->
address_
=
address
; }
25
void
set_bindkey(std::initializer_list<uint8_t> bindkey);
26
27
void
dump_config()
override
;
28
bool
parse_device(
const
ble_device_base::ESPBTDevice
&device)
override
;
29
30
protected
:
31
bool
handle_service_data_
(
const
ble_device_base::ServiceData
&service_data,
32
const
ble_device_base::ESPBTDevice
&device);
33
bool
decrypt_bthome_payload_
(
const
std::vector<uint8_t> &data, uint64_t source_address,
34
std::vector<uint8_t> &payload)
const
;
35
36
uint64_t
address_
{0};
37
optional<uint8_t>
last_packet_id_
{};
38
bool
has_bindkey_
{
false
};
39
uint8_t
bindkey_
[16];
40
};
41
42
}
// namespace esphome::bthome_mithermometer
ble_device.h
esphome::Component
Definition
component.h:147
esphome::ble_device_base::ESPBTDevice
Definition
ble_device.h:178
esphome::ble_device_base::ESPBTDeviceListener
Definition
ble_device.h:284
esphome::bthome_mithermometer::BTHomeMiThermometer
Definition
bthome_ble.h:16
esphome::bthome_mithermometer::BTHomeMiThermometer::last_packet_id_
optional< uint8_t > last_packet_id_
Definition
bthome_ble.h:37
esphome::bthome_mithermometer::BTHomeMiThermometer::bindkey_
uint8_t bindkey_[16]
Definition
bthome_ble.h:39
esphome::bthome_mithermometer::BTHomeMiThermometer::handle_service_data_
bool handle_service_data_(const ble_device_base::ServiceData &service_data, const ble_device_base::ESPBTDevice &device)
Definition
bthome_ble.cpp:256
esphome::bthome_mithermometer::BTHomeMiThermometer::has_bindkey_
bool has_bindkey_
Definition
bthome_ble.h:38
esphome::bthome_mithermometer::BTHomeMiThermometer::decrypt_bthome_payload_
bool decrypt_bthome_payload_(const std::vector< uint8_t > &data, uint64_t source_address, std::vector< uint8_t > &payload) const
Definition
bthome_ble.cpp:189
esphome::bthome_mithermometer::BTHomeMiThermometer::address_
uint64_t address_
Definition
bthome_ble.h:36
component.h
esphome::bthome_mithermometer
Definition
bthome_ble.cpp:27
esphome::libretiny::address
uint32_t address
Definition
crash_handler.cpp:375
sensor.h
esphome::ble_device_base::ServiceData
Definition
ble_device.h:120
temperature
uint16_t temperature
Definition
sun_gtil2.cpp:12
Generated by
1.12.0