Merge pull request #116 from KazWolfe/feat/packet-logger

feat: Add callback to log raw packets
This commit is contained in:
Geoff Davis 2023-10-13 19:08:16 -07:00 committed by GitHub
commit b1938e1bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -538,6 +538,8 @@ void MitsubishiHeatPump::setup() {
this->hpStatusChanged(currentStatus);
}
);
hp->setPacketCallback(this->log_packet);
#endif
ESP_LOGCONFIG(
@ -606,3 +608,16 @@ void MitsubishiHeatPump::dump_state() {
LOG_CLIMATE("", "MitsubishiHeatPump Climate", this);
ESP_LOGI(TAG, "HELLO");
}
void MitsubishiHeatPump::log_packet(byte* packet, unsigned int length, char* packetDirection) {
String packetHex;
char textBuf[15];
for (int i = 0; i < length; i++) {
memset(textBuf, 0, 15);
sprintf(textBuf, "%02X ", packet[i]);
packetHex += textBuf;
}
ESP_LOGV(TAG, "PKT: [%s] %s", packetDirection, packetHex.c_str());
}

View File

@ -148,6 +148,8 @@ class MitsubishiHeatPump : public esphome::PollingComponent, public esphome::cli
static void save(float value, esphome::ESPPreferenceObject& storage);
static esphome::optional<float> load(esphome::ESPPreferenceObject& storage);
static void log_packet(byte* packet, unsigned int length, char* packetDirection);
private:
void enforce_remote_temperature_sensor_timeout();