The RF12 driver has been extended with the ability to send and receive packets from any net group. This feature was long overdue – it allows a node to listen to packets coming from different net groups, and could be used to implement a packet forwarding “relay” or a mesh network.
The way to activate this “any net-group” mode, is to initialize the RF12 driver with net group zero:
rf12_initialize(12, RFM_868MHZ, 0);
This puts the RFM12B in a special 1-byte sync mode. The new rf12_grp variable will contain the net group whenever a packet is received, i.e. whenever rf12_recDone() returns true.
To send a packet to a specific netgroup, say 34, you can now use the following code:
if (rf12_canSend()) {
...
rf12_grp = 34;
rf12_sendStart(...);
}
The RF12demo.pde has been extended to support this “any net-group” mode – simply set the group as “0g”.
When use in this special mode, the format of the reported lines changes slightly: “OK” becomes “OKG” plus the net group number – followed by the header byte + data bytes, as usual.
Here is some sample output, first normal mode, then any net-group mode:
Current configuration:
A i1* g5 @ 868 MHz
OK 3 215 66 0 0
OK 61 7 23 83 97 7 0 155 79
OK 61 52 239 0 218 39
OK 61 9 2 8 68 161 75 15 0 16 0
OK 3 217 66 0 0
OK 61 52 240 0 222 39
> 0g
?G 45 25 37 209 155 76 99 138 66 247 140 29 251 47 157 163 51 158
?G 7 133
?G 144 133 255 220 119 254 229 249 92 225 94 213 221 102 160 1 233 59 251
?G 255 185 205 23 165 55 175 172 161 229 207 108 141 152 56 127 208 134
> 1q
OKG 15 4 248 48
OKG 15 4 250 48
OKG 5 61 7 23 83 97 7 0 155 79
OKG 15 4 251 48
OKG 15 4 252 48
OKG 15 4 7 49
OKG 15 4 255 48
There is however a serious problem with the promiscuous / any net-group mode: the RFM12B module will report a lot of garbage. I added a “quiet” option to RF12demo to be able to suppress the reporting of bad packets, i.e. dropping “?…” lines. That’s why no “?…” lines were reported once the “1q” command was entered.
As you can see in the output, packets from both net-groups 5 and 15 are picked up and reported. Yippie!
The new version of the RF12 library has been checked into subversion and is also available as a ZIP file, see the software page for details.
There is a bit more to say about these changes… so stay tuned!