Skip to content

Commit

Permalink
Update inchanet_wallbox.cpp
Browse files Browse the repository at this point in the history
Read First than write. No delay.
  • Loading branch information
koleo9am authored Mar 28, 2024
1 parent d4c9c0c commit 3e41216
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions components/inchanet_wallbox/inchanet_wallbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,9 @@ void InchanetWallboxComponent::update() {
// vycistime buffer
for (int i = 0; i < sizeof(buffer); i++) {buffer[i] = 0;}

// odesleme zpravu
uint8_t USART_buffer_out[SMALL_PACKET_OUT_SIZE];

uint8_t max_Amps;
uint8_t third_rele;
uint8_t charging_type;
uint8_t default_Amps;

if (this->enabled_3_phase_) {
// 3-phase
charging_type = 3;
max_Amps = static_cast<uint8_t>(this->max_charging_current_);
third_rele = 0;
default_Amps = static_cast<uint8_t>(this->default_charging_current_);
}
else {
// 1-phase
charging_type = 2;
max_Amps = static_cast<uint8_t>(this->max_charging_current_);
third_rele = 0;
default_Amps = static_cast<uint8_t>(this->default_charging_current_) | 0x80;
}

create_packet(USART_buffer_out, this->evse_id_, charging_type, max_Amps, third_rele, default_Amps);

write_array(USART_buffer_out, SMALL_PACKET_OUT_SIZE);


// delay
delay(10);
// delay(10);

// cteme dokud je co cist
bool byl_5x = false;
Expand Down Expand Up @@ -155,6 +129,33 @@ void InchanetWallboxComponent::update() {
else {
ESP_LOGW(TAG, "Too short packet");
}

// odesleme zpravu
uint8_t USART_buffer_out[SMALL_PACKET_OUT_SIZE];

uint8_t max_Amps;
uint8_t third_rele;
uint8_t charging_type;
uint8_t default_Amps;

if (this->enabled_3_phase_) {
// 3-phase
charging_type = 3;
max_Amps = static_cast<uint8_t>(this->max_charging_current_);
third_rele = 0;
default_Amps = static_cast<uint8_t>(this->default_charging_current_);
}
else {
// 1-phase
charging_type = 2;
max_Amps = static_cast<uint8_t>(this->max_charging_current_);
third_rele = 0;
default_Amps = static_cast<uint8_t>(this->default_charging_current_) | 0x80;
}

create_packet(USART_buffer_out, this->evse_id_, charging_type, max_Amps, third_rele, default_Amps);

write_array(USART_buffer_out, SMALL_PACKET_OUT_SIZE);
}

void InchanetWallboxComponent::dump_config() {
Expand Down Expand Up @@ -356,4 +357,4 @@ std::string InchanetWallboxComponent::decode_errors(uint8_t state) {
}

} // inchanet_wallbox
} // esphome
} // esphome

0 comments on commit 3e41216

Please sign in to comment.