The RF24Mesh Users Guide
How to manage & administer RF24Mesh based networks
If you are reading this, it is assumed you are using are or interested in using the RF24 Communication stack at some level, including the RF24Mesh library. This guide should apply whether you are using RF24Mesh directly, or using the RF24Ethernet/RF24Gateway libraries and attempts to provide a good general understanding of the basic concepts RF24Mesh was built around.
What is RF24Mesh?
RF24Mesh is a wireless networking library designed to automate the mundane networking tasks that don't require user intervention, including addressing assignment & reassignment, DNS style lookups and general communication tasks. The underlying libraries, RF24 and RF24Network provide many wireless networking and communication features, and RF24Mesh ties them all together with automation.
The RF24Mesh library works using pre-assigned and unique NodeIDs, which can be thought of similar to static IP addresses. These NodeIDs are statically assigned, so any individual node can be identified for communication purposes. At a lower layer, the system uses RF24Network addresses, which are dynamic, changing regularly to accommodate nodes at any level of the network. These addresses represent the physical placement in the network, and are used for direct communication after completing a NodeID lookup, which returns the RF24Network address.
The overall goal of RF24Mesh is to allow users to create and deploy wireless networks based on RF24, RF52 and/or RF54 radios, in short order, and to have them communicate on an ongoing basis, changing physical locations and/or distance as required. Networking tasks are automated to a degree that human intervention should not be required for very long periods of time.
Everything is configured around a central "Master" node, which needs to remain online and active, since it keeps track of all nodes on the network and handles addressing look-ups, which are similar to DNS requests on a purely TCP/IP based network.
How to set it up?
Arduino: Just download and install the RF24Mesh library via the Arduino Library Manager. As mentioned above, each device must be assigned a static NodeID, but once that is done, everything else can be automated. The network will support NodeIDs ranging from 2 to 253, with nodeID 1 and 0 typically reserved for the "Master" node, which keeps track of all NodeIDs and related addresses.
Linux: See the documentation link below, there is an installer available for Linux based devices which streamlines the installation process.
Nodes do not need to be in range of the Master node for operation, they just need to be in range of another node that does have connectivity to the Master node. Operating nodes will automatically route traffic on behalf of other nodes. The network is built in layers, with the master at layer 0, and subsequent layers 1 to 4. This means that a given node can be as far away as 4 hops from the master, with traffic routed automatically through other nodes.
What can I do with RF24Mesh?
The RF24Mesh library can handle many different communication scenarios, but was built with a focus on IoT systems, allowing users to create large-scale sensor networks or command & control scenarios. When using RF52 based radios, users can incorporate encryption into their networks directly as well. When using the RF24Ethernet or RF24Gateway libraries with RF24Mesh, encryption must be implemented at a higher level, using technologies like SSL, SSH, TLS, etc.
Users can securely and reliably receive data from multiple sensors and control devices with a simple API and interface, customizing their system to the Nth degree.
Tips & Tricks
When using RF24Mesh, there is a need to continuously verify connectivity and renew addresses when nodes move around or simply lose wireless connectivity, and these features are incorporated into the examples. Nodes typically verify connectivity with a direct parent node, assuming that if the parent node remains connected, it has connectivity to the Master node.
No matter what layer users are working at, RF24Mesh or RF24Ethernet/RF24Gateway, the mesh library generally works the same. With RF24Ethernet/RF24Gateway, users can utilize standard networking tools over the wireless network, including TCP/IP, UDP etc, making use of protocols like MQTT, SSH or HTTP. The network still functions using the underlying communication protocols, allowing users to send very small RF24Mesh or RF24Network messages, while handling large TCP/IP or UDP packets at the same time.
This configuration allows the smallest of devices, including ATTiny devices, to be configured as routing nodes, with more powerful devices like Arduino Uno, Nano, Mega etc functioning as fully operational RF24Mesh or RF24Ethernet nodes. Larger devices capable of running Linux would make use of the RF24Gateway and/or RF24Mesh libraries directly.
RF24Mesh also allocates memory on the Master node dynamically for storing NodeID & RF24Network address combinations. The default is to configure the memory space for up to 10 nodes. Users can edit the RF24Mesh_config.h file, and set #define MESH_MEM_ALLOC_SIZE 10 to a higher number to increase the memory allocated for storing node information. This is typically recommended when running the master node on a non-linux device so that memory is not continuously being allocated and re-allocated as nodes join the network.
In the case of devices that only receive data, and don't verify
connectivity that often, users can un-comment #define
RF24MESH_CONN_CHECK_TYPE RF24MESH_CONN_CHECK_MASTER in the
RF24Mesh_config.h file, to ensure they are verifying connectivity with
the Master node, instead of just a parent node. This also prevents some
temporary DOS attacks from being possible, but does increase network
traffic.
In the case of users that require static nodes, RF24Network can be used directly at the same time as RF24Mesh. On the master node, users just need to define a static address for the static nodes, and they will function as RF24Network nodes on the RF24Mesh network, but will need to remain in the same physical location/maintain connectivity themselves.
Linux vs Arduino
The code-base for Linux devices is a little more advanced than the Arduino code-base, but functions very similarly. The main difference is that on Linux devices, the default behaviour is to save the Address list (NodeIDs and RF24Network addresses) to file periodically. On Arduino devices the list is not saved by default, but this can be implemented quite easily if desired. This is important to understand, because on reboot, a Linux based network (Linux Master Node) will resume operations using the preexisting address assignments. An Arduino based network (Arduino Master Node) will resume operations using blank address assignments, meaning every node will need to re-join the network. Typically, nodes should verify connectivity every 30 seconds or so at least, so the Master node should remain off for at least 30-seconds in that case, to ensure all nodes refresh/renew their addresses. On a Linux based master node, a file dhcplist.txt is created, and can be deleted prior to startup to force a fresh startup.
The other important difference between Linux & Arduino devices revolves around fragmentation and re-assembly of large packets. A Linux based device will cache and store fragments for each individual node, while Arduino devices will only receive and cache fragments for a single node at a time, making Linux the system of choice for operating RF24Mesh master nodes that handle very large payloads and multiple devices transmitting at the same times.
How to get started?
You have to start somewhere, and I would generally recommend installing RF24Mesh directly, and testing out some of the provided examples. It helps later to have a good understanding of the basic operation and features, including the use of NodeIDs, RF24Network addresses, and the difference between the two.
Users can then move on to trying out the more complex libraries, like RF24Ethernet and RF24Gateway, which use complex underlying code to provide a simple and seamless communication system based on TCP/IP and UDP.
The documentation is available at https://nrf24.github.io/RF24Mesh/