ESPHome 2026.8.0b4
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 public:
18 void set_address(uint64_t address) { this->address_ = address; }
19 void set_bindkey(std::initializer_list<uint8_t> bindkey);
20
22 void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; }
23 void set_battery_level(sensor::Sensor *battery_level) { this->battery_level_ = battery_level; }
24 void set_battery_voltage(sensor::Sensor *battery_voltage) { this->battery_voltage_ = battery_voltage; }
25 void set_signal_strength(sensor::Sensor *signal_strength) { this->signal_strength_ = signal_strength; }
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
46};
47
48} // namespace esphome::bthome_mithermometer
uint8_t address
Definition bl0906.h:4
void set_temperature(sensor::Sensor *temperature)
Definition bthome_ble.h:21
bool parse_device(const ble_device_base::ESPBTDevice &device) override
void set_battery_voltage(sensor::Sensor *battery_voltage)
Definition bthome_ble.h:24
void set_humidity(sensor::Sensor *humidity)
Definition bthome_ble.h:22
void set_bindkey(std::initializer_list< uint8_t > bindkey)
void set_signal_strength(sensor::Sensor *signal_strength)
Definition bthome_ble.h:25
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
void set_battery_level(sensor::Sensor *battery_level)
Definition bthome_ble.h:23
Base-class for all sensors.
Definition sensor.h:47
uint16_t temperature
Definition sun_gtil2.cpp:12