first version of aircon response msg.
This commit is contained in:
parent
14802abf0f
commit
565f96ef33
@ -101,6 +101,10 @@ void TrumaiNetBoxApp::lin_reset_device() {
|
||||
this->update_status_heater_unsubmitted_ = false;
|
||||
this->update_status_heater_stale_ = false;
|
||||
|
||||
this->update_status_aircon_prepared_ = false;
|
||||
this->update_status_aircon_unsubmitted_ = false;
|
||||
this->update_status_aircon_stale_ = false;
|
||||
|
||||
this->update_status_timer_prepared_ = false;
|
||||
this->update_status_timer_unsubmitted_ = false;
|
||||
this->update_status_timer_stale_ = false;
|
||||
@ -188,6 +192,19 @@ StatusFrameTimerResponse *TrumaiNetBoxApp::update_timer_prepare() {
|
||||
return &this->update_status_timer_;
|
||||
}
|
||||
|
||||
StatusFrameAirconResponse *TrumaiNetBoxApp::update_aircon_prepare() {
|
||||
// An update is currently going on.
|
||||
if (this->update_status_aircon_prepared_ || this->update_status_aircon_stale_) {
|
||||
return &this->update_status_aircon_;
|
||||
}
|
||||
|
||||
// prepare status response
|
||||
this->update_status_aircon_ = {};
|
||||
|
||||
this->update_status_aircon_prepared_ = true;
|
||||
return &this->update_status_aircon_;
|
||||
}
|
||||
|
||||
bool TrumaiNetBoxApp::answer_lin_order_(const u_int8_t pid) {
|
||||
// Alive message
|
||||
if (pid == LIN_PID_TRUMA_INET_BOX) {
|
||||
@ -278,6 +295,36 @@ const u_int8_t *TrumaiNetBoxApp::lin_multiframe_recieved(const u_int8_t *message
|
||||
this->update_status_timer_unsubmitted_ = false;
|
||||
this->update_status_timer_stale_ = true;
|
||||
return response;
|
||||
} else if (this->update_status_aircon_unsubmitted_) {
|
||||
ESP_LOGD(TAG, "Requested read: Sending aircon update");
|
||||
|
||||
status_frame_create_empty(response_frame, STATUS_FRAME_AIRCON_RESPONSE, sizeof(StatusFrameAirconResponse),
|
||||
this->message_counter++);
|
||||
|
||||
response_frame->inner.airconResponse.unknown_01 = this->update_status_aircon_.unknown_01;
|
||||
response_frame->inner.airconResponse.unknown_02 = this->update_status_aircon_.unknown_02;
|
||||
response_frame->inner.airconResponse.unknown_03 = this->update_status_aircon_.unknown_03;
|
||||
response_frame->inner.airconResponse.unknown_04 = this->update_status_aircon_.unknown_04;
|
||||
response_frame->inner.airconResponse.target_temp_room = this->update_status_aircon_.target_temp_room;
|
||||
response_frame->inner.airconResponse.unknown_07 = this->update_status_aircon_.unknown_07;
|
||||
response_frame->inner.airconResponse.unknown_08 = this->update_status_aircon_.unknown_08;
|
||||
response_frame->inner.airconResponse.current_temp_aircon = this->update_status_aircon_.current_temp_aircon;
|
||||
response_frame->inner.airconResponse.unknown_11 = this->update_status_aircon_.unknown_11;
|
||||
response_frame->inner.airconResponse.unknown_12 = this->update_status_aircon_.unknown_12;
|
||||
response_frame->inner.airconResponse.unknown_13 = this->update_status_aircon_.unknown_13;
|
||||
response_frame->inner.airconResponse.unknown_14 = this->update_status_aircon_.unknown_14;
|
||||
response_frame->inner.airconResponse.unknown_15 = this->update_status_aircon_.unknown_15;
|
||||
response_frame->inner.airconResponse.unknown_16 = this->update_status_aircon_.unknown_16;
|
||||
response_frame->inner.airconResponse.current_temp_room = this->update_status_aircon_.current_temp_room;
|
||||
|
||||
status_frame_calculate_checksum(response_frame);
|
||||
(*return_len) = sizeof(StatusFrameHeader) + sizeof(StatusFrameAirconResponse);
|
||||
|
||||
this->update_time_ = 0;
|
||||
this->update_status_aircon_prepared_ = false;
|
||||
this->update_status_aircon_unsubmitted_ = false;
|
||||
this->update_status_aircon_stale_ = true;
|
||||
return response;
|
||||
#ifdef USE_TIME
|
||||
} else if (this->update_status_clock_unsubmitted_) {
|
||||
if (this->time_ != nullptr) {
|
||||
@ -358,8 +405,7 @@ const u_int8_t *TrumaiNetBoxApp::lin_multiframe_recieved(const u_int8_t *message
|
||||
// SID<---------PREAMBLE---------->|<---MSG_HEAD---->|
|
||||
// BB.00.1F.00.1E.00.00.22.FF.FF.FF.54.01.16.3F.00.E2.00.00.71.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00
|
||||
return response;
|
||||
} else if (header->message_type == STATUS_FRAME_AIRCON2 &&
|
||||
header->message_length == sizeof(StatusFrameAircon2)) {
|
||||
} else if (header->message_type == STATUS_FRAME_AIRCON2 && header->message_length == sizeof(StatusFrameAircon2)) {
|
||||
ESP_LOGI(TAG, "StatusFrameAircon2");
|
||||
// Example:
|
||||
// SID<---------PREAMBLE---------->|<---MSG_HEAD---->|
|
||||
@ -510,7 +556,7 @@ bool TrumaiNetBoxApp::has_update_to_submit_() {
|
||||
return true;
|
||||
}
|
||||
} else if (this->update_status_heater_unsubmitted_ || this->update_status_timer_unsubmitted_ ||
|
||||
this->update_status_clock_unsubmitted_) {
|
||||
this->update_status_clock_unsubmitted_ || this->update_status_aircon_unsubmitted_) {
|
||||
if (this->update_time_ == 0) {
|
||||
// ESP_LOGD(TAG, "Notify CP Plus I got updates.");
|
||||
this->update_time_ = micros();
|
||||
|
||||
@ -237,13 +237,13 @@ struct StatusFrameAircon { // NOLINT(altera-struct-pack-align)
|
||||
u_int8_t unknown_03;
|
||||
// 0x01
|
||||
u_int8_t unknown_04;
|
||||
u_int16_t target_temp_room;
|
||||
TargetTemp target_temp_room;
|
||||
// 0x00
|
||||
u_int8_t unknown_07;
|
||||
// 0x00
|
||||
u_int8_t unknown_08;
|
||||
// No idea why two current_temp
|
||||
u_int16_t current_temp_aircon;
|
||||
TargetTemp current_temp_aircon;
|
||||
// 0x00
|
||||
u_int8_t unknown_11;
|
||||
// 0x00
|
||||
@ -256,12 +256,39 @@ struct StatusFrameAircon { // NOLINT(altera-struct-pack-align)
|
||||
u_int8_t unknown_15;
|
||||
// 0x00
|
||||
u_int8_t unknown_16;
|
||||
u_int16_t current_temp_room;
|
||||
TargetTemp current_temp_room;
|
||||
} __attribute__((packed));
|
||||
|
||||
// TODO
|
||||
struct StatusFrameAirconResponse { // NOLINT(altera-struct-pack-align)
|
||||
// TODO
|
||||
// Mode? 00 - OFF, 04 - AC Ventilation, 05 - AC Cooling
|
||||
u_int8_t unknown_01;
|
||||
// 0x00
|
||||
u_int8_t unknown_02;
|
||||
// 0x71
|
||||
u_int8_t unknown_03;
|
||||
// 0x01
|
||||
u_int8_t unknown_04;
|
||||
TargetTemp target_temp_room;
|
||||
// 0x00
|
||||
u_int8_t unknown_07;
|
||||
// 0x00
|
||||
u_int8_t unknown_08;
|
||||
// No idea why two current_temp
|
||||
TargetTemp current_temp_aircon;
|
||||
// 0x00
|
||||
u_int8_t unknown_11;
|
||||
// 0x00
|
||||
u_int8_t unknown_12;
|
||||
// 0x00
|
||||
u_int8_t unknown_13;
|
||||
// 0x00
|
||||
u_int8_t unknown_14;
|
||||
// 0x00
|
||||
u_int8_t unknown_15;
|
||||
// 0x00
|
||||
u_int8_t unknown_16;
|
||||
TargetTemp current_temp_room;
|
||||
} __attribute__((packed));
|
||||
|
||||
// Length 24 (0x18)
|
||||
@ -424,8 +451,8 @@ struct StatusFrameAircon2 { // NOLINT(altera-struct-pack-align)
|
||||
u_int8_t unknown_12; // 0x00
|
||||
u_int8_t unknown_13; // 0x00
|
||||
u_int8_t unknown_14; // 0x00
|
||||
u_int16_t current_temp;
|
||||
u_int16_t target_temp;
|
||||
TargetTemp current_temp;
|
||||
TargetTemp target_temp;
|
||||
} __attribute__((packed));
|
||||
|
||||
union StatusFrame { // NOLINT(altera-struct-pack-align)
|
||||
@ -434,7 +461,6 @@ union StatusFrame { // NOLINT(altera-struct-pack-align)
|
||||
StatusFrameHeader genericHeader;
|
||||
union { // NOLINT(altera-struct-pack-align)
|
||||
StatusFrameHeater heater;
|
||||
StatusFrameAircon aircon;
|
||||
StatusFrameHeaterResponse heaterResponse;
|
||||
StatusFrameTimer timer;
|
||||
StatusFrameTimerResponse timerResponse;
|
||||
@ -442,6 +468,8 @@ union StatusFrame { // NOLINT(altera-struct-pack-align)
|
||||
StatusFrameClock clock;
|
||||
StatusFrameConfig config;
|
||||
StatusFrameDevice device;
|
||||
StatusFrameAircon aircon;
|
||||
StatusFrameAirconResponse airconResponse;
|
||||
StatusFrameAirconInit airconInit;
|
||||
StatusFrameAircon2 aircon2;
|
||||
} __attribute__((packed));
|
||||
@ -485,6 +513,10 @@ class TrumaiNetBoxApp : public LinBusProtocol {
|
||||
StatusFrameHeaterResponse *update_heater_prepare();
|
||||
void update_heater_submit() { this->update_status_heater_unsubmitted_ = true; }
|
||||
|
||||
bool truma_aircon_can_update() { return this->status_aircon_valid_; }
|
||||
StatusFrameAirconResponse *update_aircon_prepare();
|
||||
void update_aircon_submit() { this->update_status_aircon_unsubmitted_ = true; }
|
||||
|
||||
bool truma_timer_can_update() { return this->status_timer_valid_; }
|
||||
StatusFrameTimerResponse *update_timer_prepare();
|
||||
void update_timer_submit() { this->update_status_timer_unsubmitted_ = true; }
|
||||
@ -564,7 +596,10 @@ class TrumaiNetBoxApp : public LinBusProtocol {
|
||||
bool update_status_heater_stale_ = false;
|
||||
StatusFrameHeaterResponse update_status_heater_;
|
||||
|
||||
bool update_status_aircon_prepared_ = false;
|
||||
bool update_status_aircon_unsubmitted_ = false;
|
||||
bool update_status_aircon_stale_ = false;
|
||||
StatusFrameAirconResponse update_status_aircon_;
|
||||
|
||||
// Prepared means `update_status_timer_` was copied from `status_timer_`.
|
||||
bool update_status_timer_prepared_ = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user