91 void setup()
override;
93 void dump_config()
override;
94 void register_listener(uint8_t datapoint_id,
const std::function<
void(
TuyaDatapoint)> &func);
95 void set_raw_datapoint_value(uint8_t datapoint_id,
const std::vector<uint8_t> &value);
96 void set_boolean_datapoint_value(uint8_t datapoint_id,
bool value);
97 void set_integer_datapoint_value(uint8_t datapoint_id, uint32_t value);
99 void set_string_datapoint_value(uint8_t datapoint_id,
const std::string &value);
100 void set_enum_datapoint_value(uint8_t datapoint_id, uint8_t value);
101 void set_bitmask_datapoint_value(uint8_t datapoint_id, uint32_t value, uint8_t
length);
102 void force_set_raw_datapoint_value(uint8_t datapoint_id,
const std::vector<uint8_t> &value);
103 void force_set_boolean_datapoint_value(uint8_t datapoint_id,
bool value);
104 void force_set_integer_datapoint_value(uint8_t datapoint_id, uint32_t value);
105 void force_set_string_datapoint_value(uint8_t datapoint_id,
const std::string &value);
106 void force_set_enum_datapoint_value(uint8_t datapoint_id, uint8_t value);
107 void force_set_bitmask_datapoint_value(uint8_t datapoint_id, uint32_t value, uint8_t length);
113 this->ignore_mcu_update_on_datapoints_.push_back(ignore_mcu_update_on_datapoints);
116 this->initialized_callback_.add(std::move(callback));
120 void handle_char_(uint8_t c);
121 void handle_datapoints_(
const uint8_t *buffer,
size_t len);
123 bool validate_message_();
125 void handle_command_(uint8_t command, uint8_t
version,
const uint8_t *buffer,
size_t len);
127 void process_command_queue_();
130 void set_numeric_datapoint_value_(uint8_t datapoint_id,
TuyaDatapointType datapoint_type, uint32_t value,
131 uint8_t length,
bool forced);
132 void set_string_datapoint_value_(uint8_t datapoint_id,
const std::string &value,
bool forced);
133 void set_raw_datapoint_value_(uint8_t datapoint_id,
const std::vector<uint8_t> &value,
bool forced);
134 void send_datapoint_command_(uint8_t datapoint_id,
TuyaDatapointType datapoint_type, std::vector<uint8_t> data);
135 void set_status_pin_();
136 void send_wifi_status_();
137 uint8_t get_wifi_status_code_();
138 uint8_t get_wifi_rssi_();
141 void send_local_time_();
143 bool time_sync_callback_registered_{
false};
146 bool init_failed_{
false};
147 int init_retries_{0};
148 uint8_t protocol_version_ = -1;
150 int status_pin_reported_ = -1;
151 int reset_pin_reported_ = -1;
152 uint32_t last_command_timestamp_ = 0;
153 uint32_t last_rx_char_timestamp_ = 0;
154 std::string product_ =
"";
158 std::vector<uint8_t> ignore_mcu_update_on_datapoints_{};
161 uint8_t wifi_status_ = -1;
TuyaExtendedServicesCommandType
float get_setup_priority() const override
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock...
const float LATE
For components that should be initialized at the very end of the setup process.
void set_time_id(time::RealTimeClock *time_id)
std::vector< TuyaDatapointListener > listeners_
void add_on_initialized_callback(std::function< void()> callback)
std::vector< TuyaDatapoint > datapoints_
std::vector< uint8_t > rx_message_
std::function< void(TuyaDatapoint)> on_datapoint
std::vector< uint8_t > payload
void set_status_pin(InternalGPIOPin *status_pin)
Implementation of SPI Controller mode.
std::vector< TuyaCommand > command_queue_
std::vector< uint8_t > value_raw
void add_ignore_mcu_update_on_datapoints(uint8_t ignore_mcu_update_on_datapoints)