Skip to content

Commit

Permalink
fix(protocol): do not try to parse yet unknown error message
Browse files Browse the repository at this point in the history
  • Loading branch information
tspopp committed Nov 11, 2024
1 parent 6c43451 commit bd84167
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AquaMQTT/include/message/MessageConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions AquaMQTT/src/buffer/FrameBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,20 @@ 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)
|| (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)
|| (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
Expand Down

0 comments on commit bd84167

Please sign in to comment.