Backport of bugfix (#259) in repeaters when forwarding signed messages
This commit is contained in:
@@ -396,7 +396,9 @@ boolean MySensor::sendRoute(MyMessage &message) {
|
|||||||
}
|
}
|
||||||
// After this point, only the 'last' member of the message structure is allowed to be altered if the message has been signed,
|
// After this point, only the 'last' member of the message structure is allowed to be altered if the message has been signed,
|
||||||
// or signature will become invalid and the message rejected by the receiver
|
// or signature will become invalid and the message rejected by the receiver
|
||||||
} else mSetSigned(message, 0); // Message is not supposed to be signed, make sure it is marked unsigned
|
} else if (nc.nodeId == message.sender) {
|
||||||
|
mSetSigned(message, 0); // Message is not supposed to be signed, make sure it is marked unsigned
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dest == GATEWAY_ADDRESS || !repeaterMode) {
|
if (dest == GATEWAY_ADDRESS || !repeaterMode) {
|
||||||
@@ -588,11 +590,18 @@ boolean MySensor::process() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add string termination, good if we later would want to print it.
|
if (msg.destination == nc.nodeId) {
|
||||||
msg.data[mGetLength(msg)] = '\0';
|
debug(PSTR("read: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n"),
|
||||||
debug(PSTR("read: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n"),
|
msg.sender, msg.last, msg.destination, msg.sensor, mGetCommand(msg), msg.type, mGetPayloadType(msg), mGetLength(msg), mGetSigned(msg), msg.getString(convBuf));
|
||||||
|
} else {
|
||||||
|
if (repeaterMode && nc.nodeId != AUTO) {
|
||||||
|
debug(PSTR("read and forward: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n"),
|
||||||
msg.sender, msg.last, msg.destination, msg.sensor, mGetCommand(msg), msg.type, mGetPayloadType(msg), mGetLength(msg), mGetSigned(msg), msg.getString(convBuf));
|
msg.sender, msg.last, msg.destination, msg.sensor, mGetCommand(msg), msg.type, mGetPayloadType(msg), mGetLength(msg), mGetSigned(msg), msg.getString(convBuf));
|
||||||
mSetSigned(msg,0); // Clear the sign-flag now as verification (and debug printing) is completed
|
} else {
|
||||||
|
debug(PSTR("read and drop: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n"),
|
||||||
|
msg.sender, msg.last, msg.destination, msg.sensor, mGetCommand(msg), msg.type, mGetPayloadType(msg), mGetLength(msg), mGetSigned(msg), msg.getString(convBuf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!(mGetVersion(msg) == PROTOCOL_VERSION)) {
|
if(!(mGetVersion(msg) == PROTOCOL_VERSION)) {
|
||||||
debug(PSTR("ver mismatch\n"));
|
debug(PSTR("ver mismatch\n"));
|
||||||
@@ -610,6 +619,7 @@ boolean MySensor::process() {
|
|||||||
|
|
||||||
if (destination == nc.nodeId) {
|
if (destination == nc.nodeId) {
|
||||||
// This message is addressed to this node
|
// This message is addressed to this node
|
||||||
|
mSetSigned(msg,0);
|
||||||
|
|
||||||
if (repeaterMode && last != nc.parentNodeId) {
|
if (repeaterMode && last != nc.parentNodeId) {
|
||||||
// Message is from one of the child nodes. Add it to routing table.
|
// Message is from one of the child nodes. Add it to routing table.
|
||||||
|
|||||||
Reference in New Issue
Block a user