-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
miot_ylxx0xyl_node.h
45 lines (33 loc) · 1.26 KB
/
miot_ylxx0xyl_node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include "esphome/components/ble_client/ble_client.h"
#include "../miot_client/miot_client.h"
#include "../miot_client/miot_legacy_bond_client.h"
namespace esphome {
namespace miot_ylxx0xyl {
class YLxx0xYLPublisher {
public:
virtual void publish_bindkey(const std::string &value) = 0;
virtual void publish_version(const std::string &value) = 0;
};
class MiotYLxx0xYLNode : public miot_client::MiotClient, public miot_client::AuthClientListener {
public:
MiotYLxx0xYLNode(YLxx0xYLPublisher *publisher) : publisher_(publisher) {}
void on_disconnect(const esp_ble_gattc_cb_param_t::gattc_disconnect_evt_param ¶m) override;
void on_search_complete(const esp_ble_gattc_cb_param_t::gattc_search_cmpl_evt_param ¶m) override;
void on_read_char(const esp_ble_gattc_cb_param_t::gattc_read_char_evt_param ¶m) override;
void on_auth_complete() override;
void start_pairing();
protected:
struct {
uint16_t ver;
uint16_t key;
} char_{};
YLxx0xYLPublisher *publisher_;
// void (MiotYLxx0xYLNode::*step)();
// uint16_t step_handle_ {};
// void do_step_(uint16_t handle);
void on_read_ver_(const uint8_t *data, int size);
void on_read_key_(const uint8_t *data, int size);
};
} // namespace miot_ylxx0xyl
} // namespace esphome