ESPHome  2024.12.2
xiaomi_ble.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <vector>
7 
8 #ifdef USE_ESP32
9 
10 namespace esphome {
11 namespace xiaomi_ble {
12 
14  enum {
33  } type;
34  std::string name;
48  bool has_data; // 0x40
49  bool has_capability; // 0x20
50  bool has_encryption; // 0x08
53 };
54 
56  uint8_t key[16];
57  uint8_t plaintext[16];
58  uint8_t ciphertext[16];
59  uint8_t authdata[16];
60  uint8_t iv[16];
61  uint8_t tag[16];
62  size_t keysize;
63  size_t authsize;
64  size_t datasize;
65  size_t tagsize;
66  size_t ivsize;
67 };
68 
69 bool parse_xiaomi_value(uint16_t value_type, const uint8_t *data, uint8_t value_length, XiaomiParseResult &result);
70 bool parse_xiaomi_message(const std::vector<uint8_t> &message, XiaomiParseResult &result);
72 bool decrypt_xiaomi_payload(std::vector<uint8_t> &raw, const uint8_t *bindkey, const uint64_t &address);
73 bool report_xiaomi_results(const optional<XiaomiParseResult> &result, const std::string &address);
74 
76  public:
77  bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
78 };
79 
80 } // namespace xiaomi_ble
81 } // namespace esphome
82 
83 #endif
uint8_t raw[35]
Definition: bl0939.h:19
bool parse_xiaomi_value(uint16_t value_type, const uint8_t *data, uint8_t value_length, XiaomiParseResult &result)
Definition: xiaomi_ble.cpp:15
bool decrypt_xiaomi_payload(std::vector< uint8_t > &raw, const uint8_t *bindkey, const uint64_t &address)
Definition: xiaomi_ble.cpp:251
bool parse_xiaomi_message(const std::vector< uint8_t > &message, XiaomiParseResult &result)
Definition: xiaomi_ble.cpp:101
optional< XiaomiParseResult > parse_xiaomi_header(const esp32_ble_tracker::ServiceData &service_data)
Definition: xiaomi_ble.cpp:150
bool report_xiaomi_results(const optional< XiaomiParseResult > &result, const std::string &address)
Definition: xiaomi_ble.cpp:339
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint8_t address
Definition: bl0906.h:211
enum esphome::xiaomi_ble::XiaomiParseResult::@142 type