-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
miot_cwbs01_api.h
39 lines (30 loc) · 1.15 KB
/
miot_cwbs01_api.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
#pragma once
#include "miot_cwbs01_data.h"
namespace esphome {
namespace miot_cwbs01 {
class MiotCWBS01ApiListener {
public:
virtual void read(const state_t &state) = 0;
virtual void read(const datetime_sync_t &dts) = 0;
};
class MiotCWBS01Api {
public:
void add_listener(MiotCWBS01ApiListener *listener) { listeners_.push_back(listener); }
bool read_frame(const uint8_t *data, uint8_t size);
virtual bool send_frame(const void *data, uint8_t size) const = 0;
bool request_state() const;
bool sync_time(const ESPTime &tm) const;
bool set_cycle(bool enabled) const;
bool set_power(bool enabled) const;
bool set_mode(Mode mode) const;
bool set_scene(Scene scene) const;
bool set_schedule(const schedule_t &schedule, Scene scene, Mode mode) const;
protected:
std::vector<MiotCWBS01ApiListener *> listeners_;
bool read_command_(Command cmd, const void *data, uint8_t size);
bool send_command_(Command cmd, const void *data, uint8_t size) const;
bool read_packet_(Packet type, const void *data, uint8_t size);
bool send_packet_(Packet type, const void *data, uint8_t size) const;
};
} // namespace miot_cwbs01
} // namespace esphome