Speed up communication by sending smaller frames.
This commit is contained in:
parent
ced79a4af9
commit
e8b65fdcfe
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,3 +5,5 @@
|
|||||||
/secrets.yaml
|
/secrets.yaml
|
||||||
|
|
||||||
**/__pycache__/**
|
**/__pycache__/**
|
||||||
|
|
||||||
|
/local_*
|
||||||
@ -24,14 +24,17 @@ void status_frame_calculate_checksum(StatusFrame *response) {
|
|||||||
response->inner.genericHeader.checksum = data_checksum(&response->raw[10], sizeof(StatusFrame) - 10, 0);
|
response->inner.genericHeader.checksum = data_checksum(&response->raw[10], sizeof(StatusFrame) - 10, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_frame_create_init(StatusFrame *response, u_int8_t command_counter) {
|
void status_frame_create_init(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter) {
|
||||||
status_frame_create_empty(response, STATUS_FRAME_RESPONSE_INIT_REQUEST, 0, command_counter);
|
status_frame_create_empty(response, STATUS_FRAME_RESPONSE_INIT_REQUEST, 0, command_counter);
|
||||||
|
|
||||||
|
// Init frame is empty.
|
||||||
|
|
||||||
status_frame_calculate_checksum(response);
|
status_frame_calculate_checksum(response);
|
||||||
|
(*response_len) = sizeof(StatusFrameHeader) + 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_frame_create_update_clock(StatusFrame *response, u_int8_t command_counter, u_int8_t hour, u_int8_t minute,
|
void status_frame_create_update_clock(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter,
|
||||||
u_int8_t second, ClockMode clockMode) {
|
u_int8_t hour, u_int8_t minute, u_int8_t second, ClockMode clockMode) {
|
||||||
status_frame_create_empty(response, STATUS_FRAME_CLOCK_RESPONSE, sizeof(StatusFrameClock), command_counter);
|
status_frame_create_empty(response, STATUS_FRAME_CLOCK_RESPONSE, sizeof(StatusFrameClock), command_counter);
|
||||||
|
|
||||||
response->inner.clock.clock_hour = hour;
|
response->inner.clock.clock_hour = hour;
|
||||||
@ -42,12 +45,13 @@ void status_frame_create_update_clock(StatusFrame *response, u_int8_t command_co
|
|||||||
response->inner.clock.clock_mode = clockMode;
|
response->inner.clock.clock_mode = clockMode;
|
||||||
|
|
||||||
status_frame_calculate_checksum(response);
|
status_frame_calculate_checksum(response);
|
||||||
|
(*response_len) = sizeof(StatusFrameHeader) + sizeof(StatusFrameClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_frame_create_update_timer(StatusFrame *response, u_int8_t command_counter, TimerActive active,
|
void status_frame_create_update_timer(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter,
|
||||||
u_int8_t start_hour, u_int8_t start_minute, u_int8_t stop_hour,
|
TimerActive active, u_int8_t start_hour, u_int8_t start_minute,
|
||||||
u_int8_t stop_minute, TargetTemp room, TargetTemp water, HeatingMode mode,
|
u_int8_t stop_hour, u_int8_t stop_minute, TargetTemp room, TargetTemp water,
|
||||||
EnergyMix energy, ElectricPowerLevel elPower) {
|
HeatingMode mode, EnergyMix energy, ElectricPowerLevel elPower) {
|
||||||
status_frame_create_empty(response, STATUS_FRAME_TIMER_RESPONSE, sizeof(StatusFrameTimerResponse), command_counter);
|
status_frame_create_empty(response, STATUS_FRAME_TIMER_RESPONSE, sizeof(StatusFrameTimerResponse), command_counter);
|
||||||
|
|
||||||
response->inner.timerResponse.timer_target_temp_room = room;
|
response->inner.timerResponse.timer_target_temp_room = room;
|
||||||
@ -64,10 +68,11 @@ void status_frame_create_update_timer(StatusFrame *response, u_int8_t command_co
|
|||||||
response->inner.timerResponse.timer_resp_stop_minutes = stop_minute;
|
response->inner.timerResponse.timer_resp_stop_minutes = stop_minute;
|
||||||
|
|
||||||
status_frame_calculate_checksum(response);
|
status_frame_calculate_checksum(response);
|
||||||
|
(*response_len) = sizeof(StatusFrameHeader) + sizeof(StatusFrameTimerResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_frame_create_update_heater(StatusFrame *response, u_int8_t command_counter, TargetTemp room,
|
void status_frame_create_update_heater(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter,
|
||||||
TargetTemp water, HeatingMode mode, EnergyMix energy,
|
TargetTemp room, TargetTemp water, HeatingMode mode, EnergyMix energy,
|
||||||
ElectricPowerLevel elPower) {
|
ElectricPowerLevel elPower) {
|
||||||
status_frame_create_empty(response, STATUS_FRAME_HEATER_RESPONSE, sizeof(StatusFrameHeaterResponse), command_counter);
|
status_frame_create_empty(response, STATUS_FRAME_HEATER_RESPONSE, sizeof(StatusFrameHeaterResponse), command_counter);
|
||||||
|
|
||||||
@ -80,6 +85,7 @@ void status_frame_create_update_heater(StatusFrame *response, u_int8_t command_c
|
|||||||
response->inner.heaterResponse.el_power_level_b = elPower;
|
response->inner.heaterResponse.el_power_level_b = elPower;
|
||||||
|
|
||||||
status_frame_calculate_checksum(response);
|
status_frame_calculate_checksum(response);
|
||||||
|
(*response_len) = sizeof(StatusFrameHeader) + sizeof(StatusFrameHeaterResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace truma_inetbox
|
} // namespace truma_inetbox
|
||||||
|
|||||||
@ -10,18 +10,18 @@ void status_frame_create_empty(StatusFrame *response, u_int8_t message_type, u_i
|
|||||||
|
|
||||||
void status_frame_calculate_checksum(StatusFrame *response);
|
void status_frame_calculate_checksum(StatusFrame *response);
|
||||||
|
|
||||||
void status_frame_create_init(StatusFrame *response, u_int8_t command_counter);
|
void status_frame_create_init(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter);
|
||||||
|
|
||||||
void status_frame_create_update_clock(StatusFrame *response, u_int8_t command_counter, u_int8_t hour, u_int8_t minute,
|
void status_frame_create_update_clock(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter,
|
||||||
u_int8_t second, ClockMode clockMode);
|
u_int8_t hour, u_int8_t minute, u_int8_t second, ClockMode clockMode);
|
||||||
|
|
||||||
void status_frame_create_update_timer(StatusFrame *response, u_int8_t command_counter, TimerActive active,
|
void status_frame_create_update_timer(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter,
|
||||||
u_int8_t start_hour, u_int8_t start_minute, u_int8_t stop_hour,
|
TimerActive active, u_int8_t start_hour, u_int8_t start_minute,
|
||||||
u_int8_t stop_minute, TargetTemp room, TargetTemp water, HeatingMode mode,
|
u_int8_t stop_hour, u_int8_t stop_minute, TargetTemp room, TargetTemp water,
|
||||||
EnergyMix energy, ElectricPowerLevel elPower);
|
HeatingMode mode, EnergyMix energy, ElectricPowerLevel elPower);
|
||||||
|
|
||||||
void status_frame_create_update_heater(StatusFrame *response, u_int8_t command_counter, TargetTemp room,
|
void status_frame_create_update_heater(StatusFrame *response, u_int8_t *response_len, u_int8_t command_counter,
|
||||||
TargetTemp water, HeatingMode mode, EnergyMix energy,
|
TargetTemp room, TargetTemp water, HeatingMode mode, EnergyMix energy,
|
||||||
ElectricPowerLevel elPower);
|
ElectricPowerLevel elPower);
|
||||||
|
|
||||||
} // namespace truma_inetbox
|
} // namespace truma_inetbox
|
||||||
|
|||||||
@ -47,6 +47,7 @@ void TrumaiNetBoxApp::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::array<uint8_t, 4> TrumaiNetBoxApp::lin_identifier() {
|
const std::array<uint8_t, 4> TrumaiNetBoxApp::lin_identifier() {
|
||||||
|
// Supplier Id: 0x4617 - Truma (Phone: +49 (0)89 4617-0)
|
||||||
// Unkown:
|
// Unkown:
|
||||||
// 17.46.01.03 - Unkown more comms required for init.
|
// 17.46.01.03 - Unkown more comms required for init.
|
||||||
// 17.46.10.03 - Unkown more comms required for init.
|
// 17.46.10.03 - Unkown more comms required for init.
|
||||||
@ -235,14 +236,12 @@ const u_int8_t *TrumaiNetBoxApp::lin_multiframe_recieved(const u_int8_t *message
|
|||||||
|
|
||||||
// The order must match with the method 'has_update_to_submit_'.
|
// The order must match with the method 'has_update_to_submit_'.
|
||||||
if (this->init_recieved_ == 0) {
|
if (this->init_recieved_ == 0) {
|
||||||
status_frame_create_init(response_frame, this->message_counter++);
|
status_frame_create_init(response_frame, return_len, this->message_counter++);
|
||||||
// TODO: can I create a shorter (quicker) messsage here?
|
|
||||||
(*return_len) = sizeof(StatusFrame);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if (this->update_status_heater_unsubmitted_) {
|
if (this->update_status_heater_unsubmitted_) {
|
||||||
status_frame_create_update_heater(
|
status_frame_create_update_heater(
|
||||||
response_frame, this->message_counter++, this->update_status_heater_.target_temp_room,
|
response_frame, return_len, this->message_counter++, this->update_status_heater_.target_temp_room,
|
||||||
this->update_status_heater_.target_temp_water, this->update_status_heater_.heating_mode,
|
this->update_status_heater_.target_temp_water, this->update_status_heater_.heating_mode,
|
||||||
this->update_status_heater_.energy_mix_a, this->update_status_heater_.el_power_level_a);
|
this->update_status_heater_.energy_mix_a, this->update_status_heater_.el_power_level_a);
|
||||||
|
|
||||||
@ -250,14 +249,11 @@ const u_int8_t *TrumaiNetBoxApp::lin_multiframe_recieved(const u_int8_t *message
|
|||||||
this->update_status_heater_prepared_ = false;
|
this->update_status_heater_prepared_ = false;
|
||||||
this->update_status_heater_unsubmitted_ = false;
|
this->update_status_heater_unsubmitted_ = false;
|
||||||
this->update_status_heater_stale_ = true;
|
this->update_status_heater_stale_ = true;
|
||||||
// Remove last 12 bytes (2 Frames), because they are always 0.
|
|
||||||
// This cannot be done on the first message, but later messages it is fine.
|
|
||||||
(*return_len) = sizeof(StatusFrame);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if (this->update_status_timer_unsubmitted_) {
|
if (this->update_status_timer_unsubmitted_) {
|
||||||
status_frame_create_update_timer(
|
status_frame_create_update_timer(
|
||||||
response_frame, this->message_counter++, this->update_status_timer_.timer_resp_active,
|
response_frame, return_len, this->message_counter++, this->update_status_timer_.timer_resp_active,
|
||||||
this->update_status_timer_.timer_resp_start_hours, this->update_status_timer_.timer_resp_start_minutes,
|
this->update_status_timer_.timer_resp_start_hours, this->update_status_timer_.timer_resp_start_minutes,
|
||||||
this->update_status_timer_.timer_resp_stop_hours, this->update_status_timer_.timer_resp_stop_minutes,
|
this->update_status_timer_.timer_resp_stop_hours, this->update_status_timer_.timer_resp_stop_minutes,
|
||||||
this->update_status_timer_.timer_target_temp_room, this->update_status_timer_.timer_target_temp_water,
|
this->update_status_timer_.timer_target_temp_room, this->update_status_timer_.timer_target_temp_water,
|
||||||
@ -268,18 +264,16 @@ const u_int8_t *TrumaiNetBoxApp::lin_multiframe_recieved(const u_int8_t *message
|
|||||||
this->update_status_timer_prepared_ = false;
|
this->update_status_timer_prepared_ = false;
|
||||||
this->update_status_timer_unsubmitted_ = false;
|
this->update_status_timer_unsubmitted_ = false;
|
||||||
this->update_status_timer_stale_ = true;
|
this->update_status_timer_stale_ = true;
|
||||||
(*return_len) = sizeof(StatusFrame);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if (this->update_status_clock_unsubmitted_) {
|
if (this->update_status_clock_unsubmitted_) {
|
||||||
// read time live
|
// read time live
|
||||||
auto now = this->time_->now();
|
auto now = this->time_->now();
|
||||||
|
|
||||||
status_frame_create_update_clock(response_frame, this->message_counter++, now.hour, now.minute, now.second,
|
status_frame_create_update_clock(response_frame, return_len, this->message_counter++, now.hour, now.minute,
|
||||||
this->status_clock_.clock_mode);
|
now.second, this->status_clock_.clock_mode);
|
||||||
|
|
||||||
this->update_status_clock_unsubmitted_ = false;
|
this->update_status_clock_unsubmitted_ = false;
|
||||||
(*return_len) = sizeof(StatusFrame);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,7 @@ enum class OperatingStatus : u_int8_t {
|
|||||||
OPERATING_STATUS_OFF = 0x0,
|
OPERATING_STATUS_OFF = 0x0,
|
||||||
OPERATING_STATUS_WARNING = 0x1,
|
OPERATING_STATUS_WARNING = 0x1,
|
||||||
OPERATING_STATUS_START_OR_COOL_DOWN = 0x4,
|
OPERATING_STATUS_START_OR_COOL_DOWN = 0x4,
|
||||||
// ON - Heater off
|
// ? Gas Heating mode ?
|
||||||
OPERATING_STATUS_ON_5 = 0x5,
|
OPERATING_STATUS_ON_5 = 0x5,
|
||||||
OPERATING_STATUS_ON_6 = 0x6,
|
OPERATING_STATUS_ON_6 = 0x6,
|
||||||
OPERATING_STATUS_ON_7 = 0x7,
|
OPERATING_STATUS_ON_7 = 0x7,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user