Simplify dumpBuf method in HoymilesRadio

This commit is contained in:
Thomas Basler 2023-03-09 21:51:31 +01:00
parent 83c623708f
commit 46036eb958
4 changed files with 9 additions and 12 deletions

View File

@ -51,16 +51,14 @@ void HoymilesRadio::sendLastPacketAgain()
sendEsbPacket(cmd);
}
void HoymilesRadio::dumpBuf(const char* info, uint8_t buf[], uint8_t len)
void HoymilesRadio::dumpBuf(const uint8_t buf[], uint8_t len, bool appendNewline)
{
if (NULL != info)
Hoymiles.getMessageOutput()->print(String(info));
for (uint8_t i = 0; i < len; i++) {
Hoymiles.getMessageOutput()->printf("%02X ", buf[i]);
}
Hoymiles.getMessageOutput()->println("");
if (appendNewline) {
Hoymiles.getMessageOutput()->println("");
}
}
bool HoymilesRadio::isInitialized()

View File

@ -23,7 +23,7 @@ public:
protected:
static serial_u convertSerialToRadioId(serial_u serial);
void dumpBuf(const char* info, uint8_t buf[], uint8_t len);
void dumpBuf(const uint8_t buf[], uint8_t len, bool appendNewline = true);
bool checkFragmentCrc(fragment_t* fragment);
virtual void sendEsbPacket(CommandAbstract* cmd) = 0;

View File

@ -112,7 +112,7 @@ bool HoymilesRadio_CMT::cmtSwitchInvAndDtuFreq(const uint64_t inv_serial, const
cmtTxBuffer[14] = crc8(cmtTxBuffer, 14);
Hoymiles.getMessageOutput()->printf("TX CMD56 %s --> ", cmtChToFreq(cmtCurrentCh).c_str());
dumpBuf("", cmtTxBuffer, 15);
dumpBuf(cmtTxBuffer, 15);
cmtTxLength = 15;
cmtTxTimeout = 100;
@ -371,7 +371,7 @@ void HoymilesRadio_CMT::loop()
if (nullptr != inv) {
// Save packet in inverter rx buffer
Hoymiles.getMessageOutput()->printf("RX %s --> ", cmtChToFreq(f.channel).c_str());
dumpBuf("", f.fragment, f.len);
dumpBuf(f.fragment, f.len, false);
Hoymiles.getMessageOutput()->printf("| %d dBm", f.rssi);
inv->addRxFragment(f.fragment, f.len);

View File

@ -75,9 +75,8 @@ void HoymilesRadio_NRF::loop()
if (nullptr != inv) {
// Save packet in inverter rx buffer
char buf[30];
snprintf(buf, sizeof(buf), "RX Channel: %d --> ", f.channel);
dumpBuf(buf, f.fragment, f.len);
Hoymiles.getMessageOutput()->printf("RX Channel: %d --> ", f.channel);
dumpBuf(f.fragment, f.len);
inv->addRxFragment(f.fragment, f.len);
} else {
Hoymiles.getMessageOutput()->println("Inverter Not found!");