24
24
25
25
#ifdef MY_SIGNING_FEATURE
26
26
// Macros for manipulating signing requirement table
27
- #define DO_SIGN (node ) (node == 0 ? (~doSign[ 0 ]& 1 ) : (~doSign[ node>>4 ]&(node%16 )))
28
- #define SET_SIGN (node ) (node == 0 ? (doSign[ 0 ]&=~ 1 ) : (doSign[ node>>4 ]&=~(node%16 )))
29
- #define CLEAR_SIGN (node ) (node == 0 ? (doSign[ 0 ]|= 1 ) : (doSign[ node>>4 ]|=(node%16 )))
27
+ #define DO_SIGN (node ) (~_doSign[ node>>3 ]&(1 <<( node%8 )))
28
+ #define SET_SIGN (node ) (_doSign[ node>>3 ]&=~(1 <<( node%8 )))
29
+ #define CLEAR_SIGN (node ) (_doSign[ node>>3 ]|=(1 <<( node%8 )))
30
30
#endif
31
31
32
32
// Inline function and macros
@@ -268,6 +268,9 @@ void MySensor::setupNode() {
268
268
if (signer.requestSignatures ()) {
269
269
wait (2000 );
270
270
}
271
+ #else
272
+ // We do not support signing, make sure gateway knows this
273
+ sendRoute (build (msg, nc.nodeId , GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false ).set (false ));
271
274
#endif
272
275
273
276
// Send presentation for this radio node (attach
@@ -393,7 +396,9 @@ boolean MySensor::sendRoute(MyMessage &message) {
393
396
}
394
397
// After this point, only the 'last' member of the message structure is allowed to be altered if the message has been signed,
395
398
// or signature will become invalid and the message rejected by the receiver
396
- } else mSetSigned (message, 0 ); // Message is not supposed to be signed, make sure it is marked unsigned
399
+ } else if (nc.nodeId == message.sender ) {
400
+ mSetSigned (message, 0 ); // Message is not supposed to be signed, make sure it is marked unsigned
401
+ }
397
402
#endif
398
403
399
404
if (dest == GATEWAY_ADDRESS || !repeaterMode) {
@@ -585,11 +590,18 @@ boolean MySensor::process() {
585
590
}
586
591
#endif
587
592
588
- // Add string termination, good if we later would want to print it.
589
- msg.data [mGetLength (msg)] = ' \0 ' ;
590
- debug (PSTR (" read: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n " ),
593
+ if (msg.destination == nc.nodeId ) {
594
+ debug (PSTR (" read: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n " ),
595
+ msg.sender , msg.last , msg.destination , msg.sensor , mGetCommand (msg), msg.type , mGetPayloadType (msg), mGetLength (msg), mGetSigned (msg), msg.getString (convBuf));
596
+ } else {
597
+ if (repeaterMode && nc.nodeId != AUTO) {
598
+ debug (PSTR (" read and forward: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n " ),
599
+ msg.sender , msg.last , msg.destination , msg.sensor , mGetCommand (msg), msg.type , mGetPayloadType (msg), mGetLength (msg), mGetSigned (msg), msg.getString (convBuf));
600
+ } else {
601
+ debug (PSTR (" read and drop: %d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n " ),
591
602
msg.sender , msg.last , msg.destination , msg.sensor , mGetCommand (msg), msg.type , mGetPayloadType (msg), mGetLength (msg), mGetSigned (msg), msg.getString (convBuf));
592
- mSetSigned (msg,0 ); // Clear the sign-flag now as verification (and debug printing) is completed
603
+ }
604
+ }
593
605
594
606
if (!(mGetVersion (msg) == PROTOCOL_VERSION)) {
595
607
debug (PSTR (" ver mismatch\n " ));
@@ -607,6 +619,7 @@ boolean MySensor::process() {
607
619
608
620
if (destination == nc.nodeId ) {
609
621
// This message is addressed to this node
622
+ mSetSigned (msg,0 );
610
623
611
624
if (repeaterMode && last != nc.parentNodeId ) {
612
625
// Message is from one of the child nodes. Add it to routing table.
0 commit comments