ESPHome  2022.8.0
xiaomi_ble.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #ifdef USE_ESP32
7 
8 namespace esphome {
9 namespace xiaomi_ble {
10 
12  enum {
30  } type;
31  std::string name;
45  bool has_data; // 0x40
46  bool has_capability; // 0x20
47  bool has_encryption; // 0x08
50 };
51 
53  uint8_t key[16];
54  uint8_t plaintext[16];
55  uint8_t ciphertext[16];
56  uint8_t authdata[16];
57  uint8_t iv[16];
58  uint8_t tag[16];
59  size_t keysize;
60  size_t authsize;
61  size_t datasize;
62  size_t tagsize;
63  size_t ivsize;
64 };
65 
66 bool parse_xiaomi_value(uint16_t value_type, const uint8_t *data, uint8_t value_length, XiaomiParseResult &result);
67 bool parse_xiaomi_message(const std::vector<uint8_t> &message, XiaomiParseResult &result);
69 bool decrypt_xiaomi_payload(std::vector<uint8_t> &raw, const uint8_t *bindkey, const uint64_t &address);
70 bool report_xiaomi_results(const optional<XiaomiParseResult> &result, const std::string &address);
71 
73  public:
74  bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
75 };
76 
77 } // namespace xiaomi_ble
78 } // namespace esphome
79 
80 #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:234
enum esphome::xiaomi_ble::XiaomiParseResult::@77 type
bool parse_xiaomi_message(const std::vector< uint8_t > &message, XiaomiParseResult &result)
Definition: xiaomi_ble.cpp:90
optional< XiaomiParseResult > parse_xiaomi_header(const esp32_ble_tracker::ServiceData &service_data)
Definition: xiaomi_ble.cpp:138
bool report_xiaomi_results(const optional< XiaomiParseResult > &result, const std::string &address)
Definition: xiaomi_ble.cpp:322
Definition: a4988.cpp:4