From bd84167ae955ec9ccc999184fc4c056e80d5653e Mon Sep 17 00:00:00 2001 From: Thomas Popp Date: Mon, 11 Nov 2024 19:01:46 +0100 Subject: [PATCH] fix(protocol): do not try to parse yet unknown error message --- AquaMQTT/include/message/MessageConstants.h | 2 +- AquaMQTT/src/buffer/FrameBuffer.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AquaMQTT/include/message/MessageConstants.h b/AquaMQTT/include/message/MessageConstants.h index e5650d2..8edb588 100644 --- a/AquaMQTT/include/message/MessageConstants.h +++ b/AquaMQTT/include/message/MessageConstants.h @@ -34,7 +34,7 @@ constexpr uint8_t ENERGY_MESSAGE_LENGTH_LEGACY = 31; constexpr uint8_t ERROR_MESSAGE_IDENTIFIER = 74; // TODO: analyze serial protocol for error messages -constexpr uint8_t ERROR_MESSAGE_LENGTH_NEXT = 255; +constexpr uint8_t ERROR_MESSAGE_LENGTH_NEXT = 0; constexpr uint8_t ERROR_MESSAGE_LENGTH_LEGACY = 35; // this will work as long as they will always differ in length diff --git a/AquaMQTT/src/buffer/FrameBuffer.cpp b/AquaMQTT/src/buffer/FrameBuffer.cpp index 312e04d..52596c2 100644 --- a/AquaMQTT/src/buffer/FrameBuffer.cpp +++ b/AquaMQTT/src/buffer/FrameBuffer.cpp @@ -195,7 +195,8 @@ bool FrameBuffer::isSync() return ((mBuffer[0] == HMI_MESSAGE_IDENTIFIER && mBuffer[1] == HMI_MESSAGE_LENGTH_NEXT) || (mBuffer[0] == MAIN_MESSAGE_IDENTIFIER && mBuffer[1] == MAIN_MESSAGE_LENGTH_NEXT) || (mBuffer[0] == ENERGY_MESSAGE_IDENTIFIER && mBuffer[1] == ENERGY_MESSAGE_LENGTH_NEXT) - || (mBuffer[0] == ERROR_MESSAGE_IDENTIFIER && mBuffer[1] == ERROR_MESSAGE_LENGTH_NEXT)); + // TODO: reenable as soon as we know the length of the NEXT error message + /*|| (mBuffer[0] == ERROR_MESSAGE_IDENTIFIER && mBuffer[1] == ERROR_MESSAGE_LENGTH_NEXT)*/); default: case PROTOCOL_UNKNOWN: return ((mBuffer[0] == HMI_MESSAGE_IDENTIFIER && mBuffer[1] == HMI_MESSAGE_LENGTH_NEXT) @@ -203,9 +204,11 @@ bool FrameBuffer::isSync() || (mBuffer[0] == ENERGY_MESSAGE_IDENTIFIER && mBuffer[1] == ENERGY_MESSAGE_LENGTH_NEXT) || (mBuffer[0] == ERROR_MESSAGE_IDENTIFIER && mBuffer[1] == ERROR_MESSAGE_LENGTH_NEXT) || (mBuffer[0] == HMI_MESSAGE_IDENTIFIER && mBuffer[1] == HMI_MESSAGE_LENGTH_LEGACY) - || (mBuffer[0] == MAIN_MESSAGE_IDENTIFIER && mBuffer[1] == MAIN_MESSAGE_LENGTH_LEGACY) + || (mBuffer[0] == MAIN_MESSAGE_IDENTIFIER && mBuffer[1] == HMI_MESSAGE_LENGTH_LEGACY) || (mBuffer[0] == ENERGY_MESSAGE_IDENTIFIER && mBuffer[1] == ENERGY_MESSAGE_LENGTH_LEGACY) - || (mBuffer[0] == ERROR_MESSAGE_IDENTIFIER && mBuffer[1] == ERROR_MESSAGE_LENGTH_LEGACY)); + // TODO: reenable as soon as we know the length of the NEXT error message + //|| (mBuffer[0] == ERROR_MESSAGE_IDENTIFIER && mBuffer[1] == ENERGY_MESSAGE_LENGTH_LEGACY) + ); } } uint64_t FrameBuffer::getDroppedCount() const