format with clang-formatter

This commit is contained in:
ElVit 2026-03-26 21:57:33 +01:00
parent ab7a8f2cd0
commit d1717adcbc
3 changed files with 14 additions and 8 deletions

View File

@ -5,12 +5,12 @@ namespace panasonic_heatpump {
static const char* const TAG = "panasonic_heatpump"; static const char* const TAG = "panasonic_heatpump";
void PanasonicHelpers::write_uart_log(UartLogDirection direction, const std::vector<uint8_t>& data, void PanasonicHelpers::write_uart_log(UartLogDirection direction, const std::vector<uint8_t>& data,
const char separator, bool logBytes) { const char separator, bool logBytes) {
PanasonicHelpers::write_uart_log(direction, &data[0], data.size(), separator, logBytes); PanasonicHelpers::write_uart_log(direction, &data[0], data.size(), separator, logBytes);
} }
void PanasonicHelpers::write_uart_log(UartLogDirection direction, const uint8_t* data, const size_t length, void PanasonicHelpers::write_uart_log(UartLogDirection direction, const uint8_t* data, const size_t length,
const char separator, bool logBytes) { const char separator, bool logBytes) {
std::string logStr = ""; std::string logStr = "";
std::string msgDir = direction == UART_LOG_TX ? ">>>" : "<<<"; std::string msgDir = direction == UART_LOG_TX ? ">>>" : "<<<";
std::string msgType = direction == UART_LOG_TX ? "request" : "response"; std::string msgType = direction == UART_LOG_TX ? "request" : "response";

View File

@ -18,8 +18,10 @@ enum UartLogDirection : uint8_t {
class PanasonicHelpers { class PanasonicHelpers {
public: public:
static void write_uart_log(UartLogDirection direction, const std::vector<uint8_t>& data, const char separator, bool logBytes); static void write_uart_log(UartLogDirection direction, const std::vector<uint8_t>& data, const char separator,
static void write_uart_log(UartLogDirection direction, const uint8_t* data, const size_t length, const char separator, bool logBytes); bool logBytes);
static void write_uart_log(UartLogDirection direction, const uint8_t* data, const size_t length, const char separator,
bool logBytes);
static std::string byte_array_to_hex_string(const std::vector<uint8_t>& data, const char separator); static std::string byte_array_to_hex_string(const std::vector<uint8_t>& data, const char separator);
static std::string byte_array_to_hex_string(const uint8_t* data, const size_t length, const char separator); static std::string byte_array_to_hex_string(const uint8_t* data, const size_t length, const char separator);
}; };

View File

@ -195,17 +195,20 @@ void PanasonicHeatpumpComponent::send_request(RequestType requestType) {
break; break;
case RequestType::INITIAL: case RequestType::INITIAL:
// Probably not necessary but CZ-TAW1 sends this query on boot // Probably not necessary but CZ-TAW1 sends this query on boot
PanasonicHelpers::write_uart_log(UART_LOG_TX, PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE, ',', this->log_uart_msg_); PanasonicHelpers::write_uart_log(UART_LOG_TX, PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE, ',',
this->log_uart_msg_);
this->write_array(PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE); this->write_array(PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE);
this->flush(); this->flush();
break; break;
case RequestType::POLLING: case RequestType::POLLING:
PanasonicHelpers::write_uart_log(UART_LOG_TX, PanasonicCommand::PollingMessage, DATA_MESSAGE_SIZE, ',', this->log_uart_msg_); PanasonicHelpers::write_uart_log(UART_LOG_TX, PanasonicCommand::PollingMessage, DATA_MESSAGE_SIZE, ',',
this->log_uart_msg_);
this->write_array(PanasonicCommand::PollingMessage, DATA_MESSAGE_SIZE); this->write_array(PanasonicCommand::PollingMessage, DATA_MESSAGE_SIZE);
this->flush(); this->flush();
break; break;
case RequestType::POLLING_EXTRA: case RequestType::POLLING_EXTRA:
PanasonicHelpers::write_uart_log(UART_LOG_TX, PanasonicCommand::PollingExtraMessage, DATA_MESSAGE_SIZE, ',', this->log_uart_msg_); PanasonicHelpers::write_uart_log(UART_LOG_TX, PanasonicCommand::PollingExtraMessage, DATA_MESSAGE_SIZE, ',',
this->log_uart_msg_);
this->write_array(PanasonicCommand::PollingExtraMessage, DATA_MESSAGE_SIZE); this->write_array(PanasonicCommand::PollingExtraMessage, DATA_MESSAGE_SIZE);
this->flush(); this->flush();
break; break;
@ -315,7 +318,8 @@ ResponseType PanasonicHeatpumpComponent::check_response(const std::vector<uint8_
return ResponseType::UNKNOWN; return ResponseType::UNKNOWN;
} }
this->send_extra_request_ = message[3] == 0x10 && message[199] > 0x02 && this->send_extra_request_ == false ? true : false; this->send_extra_request_ =
message[3] == 0x10 && message[199] > 0x02 && this->send_extra_request_ == false ? true : false;
// Get response type and save the response // Get response type and save the response
auto responseType = ResponseType::UNKNOWN; auto responseType = ResponseType::UNKNOWN;