From 1b2ac4a8c27d6c3b26749dbaaf68fb886d2c7b60 Mon Sep 17 00:00:00 2001 From: Felix Rusu Date: Thu, 6 Jun 2019 19:06:01 -0400 Subject: [PATCH] fix broadcast address notes per issue #122 --- Examples/Node/Node.ino | 32 +++++++++++++++++----- Examples/SwitchMote/SwitchMote.ino | 4 +-- Examples/SwitchMote/SwitchMoteR2.ino | 4 +-- Examples/SwitchMote/SwitchMote_withPIR.ino | 4 +-- RFM69.h | 2 +- keywords.txt | 1 + 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Examples/Node/Node.ino b/Examples/Node/Node.ino index 41bf254..190c21f 100644 --- a/Examples/Node/Node.ino +++ b/Examples/Node/Node.ino @@ -27,18 +27,30 @@ #include //get it here: https://www.github.com/lowpowerlab/rfm69 #include //get it here: https://www.github.com/lowpowerlab/rfm69 #include //get it here: https://www.github.com/lowpowerlab/spiflash -#include //included with Arduino IDE install (www.arduino.cc) //********************************************************************************************* //************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE ************ //********************************************************************************************* -#define NODEID 2 //must be unique for each node on same network (range up to 254, 255 is used for broadcast) -#define NETWORKID 100 //the same on all nodes that talk to each other (range up to 255) -#define GATEWAYID 1 -//Match frequency to the hardware version of the radio on your Moteino (uncomment one): +// Address IDs are 10bit, meaning usable ID range is 1..1023 +// Address 0 is special (broadcast), messages to address 0 are received by all *listening* nodes (ie. active RX mode) +// Gateway ID should be kept at ID=1 for simplicity, although this is not a hard constraint +//********************************************************************************************* +#define NODEID 2 // keep UNIQUE for each node on same network +#define NETWORKID 100 // keep IDENTICAL on all nodes that talk to each other +#define GATEWAYID 1 // "central" node + +//********************************************************************************************* +// Frequency should be set to match the radio module hardware tuned frequency, +// otherwise if say a "433mhz" module is set to work at 915, it will work but very badly. +// Moteinos and RF modules from LowPowerLab are marked with a colored dot to help identify their tuned frequency band, +// see this link for details: https://lowpowerlab.com/guide/moteino/transceivers/ +// The below examples are predefined "center" frequencies for the radio's tuned "ISM frequency band". +// You can always set the frequency anywhere in the "frequency band", ex. the 915mhz ISM band is 902..928mhz. +//********************************************************************************************* //#define FREQUENCY RF69_433MHZ //#define FREQUENCY RF69_868MHZ #define FREQUENCY RF69_915MHZ +//#define FREQUENCY_EXACT 916000000 // you may define an exact frequency/channel in Hz #define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes! #define IS_RFM69HW_HCW //uncomment only for RFM69HW/HCW! Leave out if you have RFM69W/CW! //********************************************************************************************* @@ -75,9 +87,15 @@ void setup() { #ifdef IS_RFM69HW_HCW radio.setHighPower(); //must include this only for RFM69HW/HCW! #endif - radio.encrypt(ENCRYPTKEY); - //radio.setFrequency(919000000); //set frequency to some custom frequency +#ifdef ENCRYPTKEY + radio.encrypt(ENCRYPTKEY); +#endif + +#ifdef FREQUENCY_EXACT + radio.setFrequency(FREQUENCY_EXACT); //set frequency to some custom frequency +#endif + //Auto Transmission Control - dials down transmit power to save battery (-100 is the noise floor, -90 is still pretty good) //For indoor nodes that are pretty static and at pretty stable temperatures (like a MotionMote) -90dBm is quite safe //For more variable nodes that can expect to move or experience larger temp drifts a lower margin like -70 to -80 would probably be better diff --git a/Examples/SwitchMote/SwitchMote.ino b/Examples/SwitchMote/SwitchMote.ino index bae6bed..bb7e9d7 100644 --- a/Examples/SwitchMote/SwitchMote.ino +++ b/Examples/SwitchMote/SwitchMote.ino @@ -108,8 +108,8 @@ struct configuration { byte frequency; byte isHW; - byte nodeID; - byte networkID; + byte nodeID; // 8bit address (up to 255) + byte networkID; // 8bit address (up to 255) char encryptionKey[16]; byte separator1; char description[10]; diff --git a/Examples/SwitchMote/SwitchMoteR2.ino b/Examples/SwitchMote/SwitchMoteR2.ino index eed5a73..96fa344 100644 --- a/Examples/SwitchMote/SwitchMoteR2.ino +++ b/Examples/SwitchMote/SwitchMoteR2.ino @@ -106,8 +106,8 @@ struct configuration { byte frequency; byte isHW; - byte nodeID; - byte networkID; + byte nodeID; // 8bit address (up to 255) + byte networkID; // 8bit address (up to 255) char encryptionKey[16]; byte separator1; char description[10]; diff --git a/Examples/SwitchMote/SwitchMote_withPIR.ino b/Examples/SwitchMote/SwitchMote_withPIR.ino index 36f6b2c..6c3d69d 100644 --- a/Examples/SwitchMote/SwitchMote_withPIR.ino +++ b/Examples/SwitchMote/SwitchMote_withPIR.ino @@ -119,8 +119,8 @@ struct configuration { byte frequency; byte isHW; - byte nodeID; - byte networkID; + byte nodeID; // 8bit address (up to 255) + byte networkID; // 8bit address (up to 255) char encryptionKey[16]; byte separator1; char description[10]; diff --git a/RFM69.h b/RFM69.h index e82dd6a..e20fddb 100644 --- a/RFM69.h +++ b/RFM69.h @@ -143,7 +143,7 @@ #define null 0 #define COURSE_TEMP_COEF -90 // puts the temperature reading in the ballpark, user can fine tune the returned value -#define RF69_BROADCAST_ADDR 0 +#define RF69_BROADCAST_ADDR RF_BROADCASTADDRESS_VALUE //0x0 #define RF69_CSMA_LIMIT_MS 1000 #define RF69_TX_LIMIT_MS 1000 #define RF69_FSTEP 61.03515625 // == FXOSC / 2^19 = 32MHz / 2^19 (p13 in datasheet) diff --git a/keywords.txt b/keywords.txt index 49782d5..48381d0 100644 --- a/keywords.txt +++ b/keywords.txt @@ -11,6 +11,7 @@ ####################################### RFM69 KEYWORD2 RFM69_ATC KEYWORD2 +RFM69Registers KEYWORD2 RFM69_OTA KEYWORD2 #######################################