mirror of
https://github.com/geoffdavis/esphome-mitsubishiheatpump
synced 2024-08-30 18:12:13 +00:00
feat: Add callback to log raw packets
- Write raw packet hex to verbose log for debug/RE work
This commit is contained in:
parent
980271337a
commit
945b376663
@ -444,6 +444,8 @@ void MitsubishiHeatPump::setup() {
|
||||
this->hpStatusChanged(currentStatus);
|
||||
}
|
||||
);
|
||||
|
||||
hp->setPacketCallback(this->log_packet);
|
||||
#endif
|
||||
|
||||
ESP_LOGCONFIG(
|
||||
@ -513,3 +515,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());
|
||||
}
|
@ -129,6 +129,8 @@ class MitsubishiHeatPump : public PollingComponent, public climate::Climate {
|
||||
static void save(float value, ESPPreferenceObject& storage);
|
||||
static optional<float> load(ESPPreferenceObject& storage);
|
||||
|
||||
static void log_packet(byte* packet, unsigned int length, char* packetDirection);
|
||||
|
||||
private:
|
||||
// Retrieve the HardwareSerial pointer from friend and subclasses.
|
||||
HardwareSerial *hw_serial_;
|
||||
|
Loading…
Reference in New Issue
Block a user