From 7d3363bf49babbd14ddebca48da0ec735b1cffe4 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 10 Jul 2015 12:41:10 +0100 Subject: [PATCH 1/2] qualify command 'i' value before setting node id A stray "i" can attempt to set a node id of "0" and result in a "config save failed" although setting the node id to "0" will of succeeded and the result is no further packets will be processed until a valid node id is set. --- examples/RF12/RF12demo/RF12demo.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/RF12/RF12demo/RF12demo.ino b/examples/RF12/RF12demo/RF12demo.ino index 0868efe6..ba1231fd 100644 --- a/examples/RF12/RF12demo/RF12demo.ino +++ b/examples/RF12/RF12demo/RF12demo.ino @@ -370,8 +370,10 @@ static void handleInput (char c) { switch (c) { case 'i': // set node id - config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F); - saveConfig(); + if ((value > 0) && (value < 31)) { + config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F); + saveConfig(); + } break; case 'b': // set band: 4 = 433, 8 = 868, 9 = 915 From e363728f508853694a345625cb0759486aaf705f Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 12 Jul 2015 11:29:36 +0100 Subject: [PATCH 2/2] accept "32i" as a command setting node id == 0 is used to disable interupts from the radio module, using 32i has the same effect due to bit masking without the vulnerability of accidental activation by value omission assumed to be 0. --- examples/RF12/RF12demo/RF12demo.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/RF12/RF12demo/RF12demo.ino b/examples/RF12/RF12demo/RF12demo.ino index ba1231fd..67d78977 100644 --- a/examples/RF12/RF12demo/RF12demo.ino +++ b/examples/RF12/RF12demo/RF12demo.ino @@ -370,7 +370,7 @@ static void handleInput (char c) { switch (c) { case 'i': // set node id - if ((value > 0) && (value < 31)) { + if ((value > 0) && (value < 33)) { config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F); saveConfig(); }