diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index d9e8d666..4638f578 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -820,9 +820,32 @@ bool ChainedMessage::checkId(SymbolString& master, unsigned char* index) bool ChainedMessage::checkId(Message& other) { unsigned char idLen = getIdLength(); - if (idLen != other.getIdLength() || other.getCount() == 1) // only equal for chained messages + if (idLen != other.getIdLength() || other.getCount() == 1) { // only equal for chained messages return false; - return other.checkIdPrefix(m_id); + } + if (!other.checkIdPrefix(m_id)) { + return false; // chain prefix mismatch + } + vector< vector > otherIds = ((ChainedMessage&)other).m_ids; + unsigned char chainPrefixLength = (unsigned char)m_id.size(); + for (unsigned char checkIndex=0; checkIndex id = m_ids[checkIndex]; + for (unsigned char otherIndex=0; otherIndex otherId = otherIds[otherIndex]; + bool found = false; + for (unsigned char pos=chainPrefixLength; possecond, *message); if (other != NULL) { - if (!conditional) + if (!conditional) { return RESULT_ERR_DUPLICATE; // duplicate key + } if (!other->isConditional()) return RESULT_ERR_DUPLICATE; // duplicate key }