ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
bthome_ble.h
Go to the documentation of this file.
1#pragma once
2
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.
15
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:
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
bool handle_service_data_(const ble_device_base::ServiceData &service_data, const ble_device_base::ESPBTDevice &device)
bool decrypt_bthome_payload_(const std::vector< uint8_t > &data, uint64_t source_address, std::vector< uint8_t > &payload) const
uint16_t temperature
Definition sun_gtil2.cpp:12