Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nRF24/RF24Ethernet
Browse files Browse the repository at this point in the history
  • Loading branch information
TMRh20 committed Jun 22, 2023
2 parents 0d0e019 + 8c12396 commit d3ded1b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 21 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
[![Arduino CLI build](https://github.com/nRF24/RF24Ethernet/actions/workflows/build_arduino.yml/badge.svg)](https://github.com/nRF24/RF24Ethernet/actions/workflows/build_arduino.yml)
[![PlatformIO build](https://github.com/nRF24/RF24Ethernet/actions/workflows/build_platformIO.yml/badge.svg)](https://github.com/nRF24/RF24Ethernet/actions/workflows/build_platformIO.yml)

## Access your RF24Network sensors using a web browser
## Easily create home automation scenarios and sensor networks

### Current stage: Functional & Stable (Updated 2021)
### Updated 2023:

RF24Ethernet requires the RF24, RF24Network and RF24Mesh libraries

Documentation & Setup Info: http://nRF24.github.io/RF24Ethernet

Downloads: http://tmrh20.github.io/

Note: Recent changes to support NRF5x boards prevent usage of RF24 devices with NRF5x boards. Users must use the internal radio with RF24Ethernet.
See the [nrf_to_nrf Arduino library](https://github.com/TMRh20/nrf_to_nrf).


--------------


Licenses include, but are not limited to the following.
-------------
Expand Down
35 changes: 24 additions & 11 deletions RF24Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,33 @@
#include "RF24Ethernet.h"

IPAddress RF24EthernetClass::_dnsServerAddress;
//DhcpClass* RF24EthernetClass::_dhcp(NULL);
// DhcpClass* RF24EthernetClass::_dhcp(NULL);

/*************************************************************/
#if defined(RF24_TAP)
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network) : radio(_radio), network(_network) //fn_uip_cb(NULL)
#if !defined NRF52_RADIO_LIBRARY
#if defined(RF24_TAP)
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network) : radio(_radio), network(_network) // fn_uip_cb(NULL)
{
}

#else // Using RF24Mesh
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network, RF24Mesh& _mesh) : radio(_radio), network(_network), mesh(_mesh) //fn_uip_cb(NULL)
#else // Using RF24Mesh
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network, RF24Mesh& _mesh) : radio(_radio), network(_network), mesh(_mesh) // fn_uip_cb(NULL)
{
}
#endif
#endif

#else
#if defined(RF24_TAP)
RF24EthernetClass::RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network) : radio(_radio), network(_network) // fn_uip_cb(NULL)
{
}

#else // Using RF24Mesh
RF24EthernetClass::RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network, RF52Mesh& _mesh) : radio(_radio), network(_network), mesh(_mesh) // fn_uip_cb(NULL)
{
}
#endif
#endif
/*************************************************************/

void RF24EthernetClass::update()
Expand All @@ -58,14 +71,14 @@ void RF24EthernetClass::setMac(uint16_t address)
}

const uint8_t mac[6] = {0x52, 0x46, 0x32, 0x34, (uint8_t)address, (uint8_t)(address >> 8)};
//printf("MAC: %o %d\n", address, mac[0]);
// printf("MAC: %o %d\n", address, mac[0]);

#if defined(RF24_TAP)
uip_seteth_addr(mac);
network.multicastRelay = 1;
#else
if (mac[0] == 1) {
//Dummy operation to prevent warnings if TAP not defined
// Dummy operation to prevent warnings if TAP not defined
};
#endif
RF24_Channel = RF24_Channel ? RF24_Channel : 97;
Expand Down Expand Up @@ -274,8 +287,8 @@ void RF24EthernetClass::tick()
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if (uip_len > 0) {
//uip_arp_out();
//network_send();
// uip_arp_out();
// network_send();
RF24UDP::_send((uip_udp_userdata_t*)(uip_udp_conns[i].appstate));
}
}
Expand All @@ -288,7 +301,7 @@ void RF24EthernetClass::tick()
uip_arp_timer();
}
}
#endif //RF24_TAP
#endif // RF24_TAP
}

/*******************************************************/
Expand Down
43 changes: 35 additions & 8 deletions RF24Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ extern "C" {
}

#include "RF24Ethernet_config.h"
#if defined (ARDUINO_ARCH_NRF52) || defined (ARDUINO_ARCH_NRF52840) || defined (ARDUINO_ARCH_NRF52833)
#include <nrf_to_nrf.h>
#endif
#include <RF24.h>
#include <RF24Network.h>
#if !defined(RF24_TAP) // Using RF24Mesh
Expand Down Expand Up @@ -76,7 +79,7 @@ extern "C" {
} while (0)
#define uip_ip_addr(addr, ip) memcpy(addr, &ip[0], 4)

#define ip_addr_uip(a) IPAddress(a[0] & 0xFF, a[0] >> 8, a[1] & 0xFF, a[1] >> 8) //TODO this is not IPV6 capable
#define ip_addr_uip(a) IPAddress(a[0] & 0xFF, a[0] >> 8, a[1] & 0xFF, a[1] >> 8) // TODO this is not IPV6 capable

#define uip_seteth_addr(eaddr) \
do { \
Expand All @@ -96,8 +99,10 @@ typedef struct
int a, b, c, d;
} IP_ADDR;


class RF24;
class RF24Network;
template<class radio_t>
class ESB_Network;

class RF24EthernetClass
{ //: public Print {
Expand All @@ -111,6 +116,13 @@ class RF24EthernetClass
#else
RF24EthernetClass(RF24& _radio, RF24Network& _network);
#endif
#if defined NRF52_RADIO_LIBRARY
#if !defined(RF24_TAP)
RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network, RF52Mesh& _mesh);
#else
RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network);
#endif
#endif

/** Basic constructor */
RF24EthernetClass();
Expand Down Expand Up @@ -176,13 +188,24 @@ class RF24EthernetClass

/** Keeps the TCP/IP stack running & processing incoming data */
void update();
//uint8_t *key;
// uint8_t *key;

private:
#if defined NRF52_RADIO_LIBRARY
nrf_to_nrf& radio;
#else
RF24& radio;
RF24Network& network;
#if !defined(RF24_TAP) // Using RF24Mesh
RF24Mesh& mesh;
#endif
#if !defined NRF52_RADIO_LIBRARY
RF24Network& network;
#if !defined(RF24_TAP) // Using RF24Mesh
RF24Mesh& mesh;
#endif
#else
RF52Network& network;
#if !defined(RF24_TAP) // Using RF24Mesh
RF52Mesh& mesh;
#endif
#endif

static IPAddress _dnsServerAddress;
Expand All @@ -206,7 +229,8 @@ class RF24EthernetClass

extern RF24EthernetClass RF24Ethernet;

#endif // RF24Ethernet_h
typedef RF24EthernetClass RF52EthernetClass;


/**
* @example Getting_Started_SimpleServer_Mesh.ino
Expand All @@ -225,7 +249,7 @@ extern RF24EthernetClass RF24Ethernet;
/**
* @example Getting_Started_SimpleClient_Mesh_DNS.ino
*
* This is an example of how to use the RF24Ethernet class to connect out to a web server and retrieve data via HTTP,
* This is an example of how to use the RF24Ethernet class to connect out to a web server and retrieve data via HTTP,
* using DNS lookups instead of IP address.
*/

Expand Down Expand Up @@ -269,3 +293,6 @@ extern RF24EthernetClass RF24Ethernet;
* <br>This example uses [HTML.h](SLIP__InteractiveServer_2HTML_8h.html) from the
* example's directory.
*/

#endif // RF24Ethernet_h

0 comments on commit d3ded1b

Please sign in to comment.