RF24Gateway - TCP/IP over RF24Network v2.2.0
TMRh20 - Pushing the practical limits of RF24 modules
Loading...
Searching...
No Matches
ESBGateway< mesh_t, network_t, radio_t > Class Template Reference

#include <RF24Gateway.h>

Classes

struct  routeStruct

Public Member Functions

RF24Gateway (RPi/Linux)

RF24Gateway library for devices with an IP stack

 ESBGateway (radio_t &_radio, network_t &_network, mesh_t &_mesh)
void begin (uint8_t nodeID=0, uint8_t channel=97, rf24_datarate_e data_rate=RF24_1MBPS)
void begin (uint16_t address, uint8_t channel=97, rf24_datarate_e data_rate=RF24_1MBPS, bool meshEnable=0, uint8_t nodeID=0)
int setIP (char *ip_addr, char *mask)
void update (bool interrupts=0)
void poll (uint32_t waitDelay=3)
void interrupts (bool enable=1)

Advanced Operation

More advanced methods and options

uint16_t thisNodeAddress
uint8_t thisNodeID
bool config_TUN
bool fifoCleared
uint32_t droppedSpoofed
bool meshEnabled ()
uint32_t ifDropped ()
void sendUDP (uint8_t nodeID, RF24NetworkFrame frame)

Routing Table

Utilizing a routing table to provide complete connectivity

routeStruct routingStruct [256]
uint16_t routingTableSize
uint32_t networkOverruns
uint32_t networkCorruption

Detailed Description

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
class ESBGateway< mesh_t, network_t, radio_t >
Template Parameters
mesh_tThe mesh object's type. Defaults to RF24Mesh for legacy behavior. This new abstraction is really meant for using the nRF52840 SoC as a drop-in replacement for the nRF24L01 radio. For more detail, see the nrf_to_nrf Arduino library.
network_tThe network object's type. Defaults to RF24Network for legacy behavior. This new abstraction is really meant for using the nRF52840 SoC as a drop-in replacement for the nRF24L01 radio. For more detail, see the nrf_to_nrf Arduino library.
radio_tThe radio object's type. Defaults to RF24 for legacy behavior. This new abstraction is really meant for using the nRF52840 SoC as a drop-in replacement for the nRF24L01 radio. For more detail, see the nrf_to_nrf Arduino library.

Definition at line 66 of file RF24Gateway.h.

Constructor & Destructor Documentation

◆ ESBGateway()

template<class mesh_t, class network_t, class radio_t>
ESBGateway< mesh_t, network_t, radio_t >::ESBGateway ( radio_t & _radio,
network_t & _network,
mesh_t & _mesh )

ESBGateway constructor.

RF24 radio(7,8);
RF24Network network(radio);
RF24Mesh mesh(radio,network);
RF24Gateway gateway(radio,network,mesh);

Definition at line 16 of file RF24Gateway.cpp.

References droppedSpoofed, and routingTableSize.

Member Function Documentation

◆ begin() [1/2]

template<class mesh_t, class network_t, class radio_t>
void ESBGateway< mesh_t, network_t, radio_t >::begin ( uint8_t nodeID = 0,
uint8_t channel = 97,
rf24_datarate_e data_rate = RF24_1MBPS )

Begin function for use with RF24Mesh (TUN interface)

Parameters
nodeIDThe RF24Mesh nodeID to use
channelThe radio channel to use (1-127)
data_rateThe RF24 datarate to use (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS)
gw.begin(); //Start the gateway using RF24Mesh, with nodeID 0 (Master)
uint8_t nodeID; gw.begin(nodeID); //Start the gateway using RF24Mesh, with nodeID 1 (Child node)

Definition at line 26 of file RF24Gateway.cpp.

References begin().

Referenced by begin(), and begin().

◆ begin() [2/2]

template<class mesh_t, class network_t, class radio_t>
void ESBGateway< mesh_t, network_t, radio_t >::begin ( uint16_t address,
uint8_t channel = 97,
rf24_datarate_e data_rate = RF24_1MBPS,
bool meshEnable = 0,
uint8_t nodeID = 0 )

Begin function for use with a TAP (Ethernet) interface. RF24Mesh can be used for address assignment, but ARP will be used to perform the lookups.

Parameters
addressThe RF24Network address to use
channelThe radio channel (0-127) to use
data_rateThe RF24 datarate to use (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS)
meshEnableWhether to use RF24Mesh for address assignment
nodeIDThe RF24Mesh nodeID to use if meshEnable has been set to true
uint16_t address=00; gw.begin(address); //Start the gateway without using RF24Mesh, with RF24Network address 00 (Master)
uint16_t address=01; gw.begin(address); //Start the gateway without using RF24Mesh, with RF24Network address 01 (Child)

Definition at line 35 of file RF24Gateway.cpp.

References begin().

◆ setIP()

template<class mesh_t, class network_t, class radio_t>
int ESBGateway< mesh_t, network_t, radio_t >::setIP ( char * ip_addr,
char * mask )

Once the Gateway has been started via begin() , call setIP to configure the IP and subnet mask.

Parameters
ip_addrA character array containing the numeric IP address ie: 192.168.1.1
maskA character array containing the subnet mask ie: 255.255.255.0
Returns
-1 if failed, 0 on success

Definition at line 260 of file RF24Gateway.cpp.

◆ update()

template<class mesh_t, class network_t, class radio_t>
void ESBGateway< mesh_t, network_t, radio_t >::update ( bool interrupts = 0)

Calling update() keeps the network and mesh layers active and processing data. This needs to be called regularly.

gw.update();
if(network.available()){
...do something
}
Parameters
interruptsSet true if called from an interrupt handler & call poll() from the main loop or a thread.

Definition at line 330 of file RF24Gateway.cpp.

References interrupts().

◆ poll()

template<class mesh_t, class network_t, class radio_t>
void ESBGateway< mesh_t, network_t, radio_t >::poll ( uint32_t waitDelay = 3)

gw.poll(); needs to be called to handle incoming data from the network interface. The function will perform a delayed wait of max 3ms unless otherwise specified.

Parameters
waitDelayHow long in milliseconds this function will wait for incoming data.

Definition at line 347 of file RF24Gateway.cpp.

References fifoCleared.

◆ interrupts()

template<class mesh_t, class network_t, class radio_t>
void ESBGateway< mesh_t, network_t, radio_t >::interrupts ( bool enable = 1)

When using interrupts (gwNodeInt, ncursesInt examples) users need to call this function to disable interrupts before accessing the radio and again to re-enable interrupts when complete

Parameters
enable0 to disable interrupts and access the radio, 1 to re-enable

Definition at line 322 of file RF24Gateway.cpp.

Referenced by update().

◆ meshEnabled()

template<class mesh_t, class network_t, class radio_t>
bool ESBGateway< mesh_t, network_t, radio_t >::meshEnabled ( )

Is RF24Mesh enabled?

Definition at line 160 of file RF24Gateway.cpp.

◆ ifDropped()

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint32_t ESBGateway< mesh_t, network_t, radio_t >::ifDropped ( )
inline

Definition at line 167 of file RF24Gateway.h.

◆ sendUDP()

template<class mesh_t, class network_t, class radio_t>
void ESBGateway< mesh_t, network_t, radio_t >::sendUDP ( uint8_t nodeID,
RF24NetworkFrame frame )

Definition at line 829 of file RF24Gateway.cpp.

Member Data Documentation

◆ thisNodeAddress

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint16_t ESBGateway< mesh_t, network_t, radio_t >::thisNodeAddress

Address of our node in Octal format (01,021, etc)

Definition at line 160 of file RF24Gateway.h.

◆ thisNodeID

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint8_t ESBGateway< mesh_t, network_t, radio_t >::thisNodeID

NodeID (0-255)

Definition at line 161 of file RF24Gateway.h.

◆ config_TUN

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
bool ESBGateway< mesh_t, network_t, radio_t >::config_TUN

Using a TAP(false) or TUN(true) interface

Definition at line 164 of file RF24Gateway.h.

◆ fifoCleared

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
bool ESBGateway< mesh_t, network_t, radio_t >::fifoCleared

Definition at line 165 of file RF24Gateway.h.

Referenced by poll().

◆ droppedSpoofed

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint32_t ESBGateway< mesh_t, network_t, radio_t >::droppedSpoofed

How many packets received from the radio were dropped because their source IP did not match the mesh node that sent them (TUN mode, master node only)

Definition at line 176 of file RF24Gateway.h.

Referenced by ESBGateway().

◆ routingStruct

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
routeStruct ESBGateway< mesh_t, network_t, radio_t >::routingStruct[256]

The array that holds the routing structure data. See routeStruct

Definition at line 226 of file RF24Gateway.h.

◆ routingTableSize

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint16_t ESBGateway< mesh_t, network_t, radio_t >::routingTableSize

The size of the existing routing table loaded into memory. See routeStruct

Definition at line 231 of file RF24Gateway.h.

Referenced by ESBGateway().

◆ networkOverruns

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint32_t ESBGateway< mesh_t, network_t, radio_t >::networkOverruns

How many times the network has returned error 160 NETWORK_OVERRUN

Definition at line 236 of file RF24Gateway.h.

◆ networkCorruption

template<class mesh_t = ESBMesh<ESBNetwork<RF24>, RF24>, class network_t = ESBNetwork<RF24>, class radio_t = RF24>
uint32_t ESBGateway< mesh_t, network_t, radio_t >::networkCorruption

How many times the network has returned error 161 NETWORK_CORRUPTION

Definition at line 241 of file RF24Gateway.h.