Skip to content

Commit d3ded1b

Browse files
committed
2 parents 0d0e019 + 8c12396 commit d3ded1b

File tree

3 files changed

+65
-21
lines changed

3 files changed

+65
-21
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
[![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)
44
[![PlatformIO build](https://github.com/nRF24/RF24Ethernet/actions/workflows/build_platformIO.yml/badge.svg)](https://github.com/nRF24/RF24Ethernet/actions/workflows/build_platformIO.yml)
55

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

8-
### Current stage: Functional & Stable (Updated 2021)
8+
### Updated 2023:
99

1010
RF24Ethernet requires the RF24, RF24Network and RF24Mesh libraries
1111

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

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

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

1719

20+
--------------
21+
1822

1923
Licenses include, but are not limited to the following.
2024
-------------

RF24Ethernet.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,33 @@
2121
#include "RF24Ethernet.h"
2222

2323
IPAddress RF24EthernetClass::_dnsServerAddress;
24-
//DhcpClass* RF24EthernetClass::_dhcp(NULL);
24+
// DhcpClass* RF24EthernetClass::_dhcp(NULL);
2525

2626
/*************************************************************/
27-
#if defined(RF24_TAP)
28-
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network) : radio(_radio), network(_network) //fn_uip_cb(NULL)
27+
#if !defined NRF52_RADIO_LIBRARY
28+
#if defined(RF24_TAP)
29+
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network) : radio(_radio), network(_network) // fn_uip_cb(NULL)
2930
{
3031
}
3132

32-
#else // Using RF24Mesh
33-
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network, RF24Mesh& _mesh) : radio(_radio), network(_network), mesh(_mesh) //fn_uip_cb(NULL)
33+
#else // Using RF24Mesh
34+
RF24EthernetClass::RF24EthernetClass(RF24& _radio, RF24Network& _network, RF24Mesh& _mesh) : radio(_radio), network(_network), mesh(_mesh) // fn_uip_cb(NULL)
3435
{
3536
}
36-
#endif
37+
#endif
3738

39+
#else
40+
#if defined(RF24_TAP)
41+
RF24EthernetClass::RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network) : radio(_radio), network(_network) // fn_uip_cb(NULL)
42+
{
43+
}
44+
45+
#else // Using RF24Mesh
46+
RF24EthernetClass::RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network, RF52Mesh& _mesh) : radio(_radio), network(_network), mesh(_mesh) // fn_uip_cb(NULL)
47+
{
48+
}
49+
#endif
50+
#endif
3851
/*************************************************************/
3952

4053
void RF24EthernetClass::update()
@@ -58,14 +71,14 @@ void RF24EthernetClass::setMac(uint16_t address)
5871
}
5972

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

6376
#if defined(RF24_TAP)
6477
uip_seteth_addr(mac);
6578
network.multicastRelay = 1;
6679
#else
6780
if (mac[0] == 1) {
68-
//Dummy operation to prevent warnings if TAP not defined
81+
// Dummy operation to prevent warnings if TAP not defined
6982
};
7083
#endif
7184
RF24_Channel = RF24_Channel ? RF24_Channel : 97;
@@ -274,8 +287,8 @@ void RF24EthernetClass::tick()
274287
should be sent out on the network, the global variable
275288
uip_len is set to a value > 0. */
276289
if (uip_len > 0) {
277-
//uip_arp_out();
278-
//network_send();
290+
// uip_arp_out();
291+
// network_send();
279292
RF24UDP::_send((uip_udp_userdata_t*)(uip_udp_conns[i].appstate));
280293
}
281294
}
@@ -288,7 +301,7 @@ void RF24EthernetClass::tick()
288301
uip_arp_timer();
289302
}
290303
}
291-
#endif //RF24_TAP
304+
#endif // RF24_TAP
292305
}
293306

294307
/*******************************************************/

RF24Ethernet.h

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern "C" {
3838
}
3939

4040
#include "RF24Ethernet_config.h"
41+
#if defined (ARDUINO_ARCH_NRF52) || defined (ARDUINO_ARCH_NRF52840) || defined (ARDUINO_ARCH_NRF52833)
42+
#include <nrf_to_nrf.h>
43+
#endif
4144
#include <RF24.h>
4245
#include <RF24Network.h>
4346
#if !defined(RF24_TAP) // Using RF24Mesh
@@ -76,7 +79,7 @@ extern "C" {
7679
} while (0)
7780
#define uip_ip_addr(addr, ip) memcpy(addr, &ip[0], 4)
7881

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

8184
#define uip_seteth_addr(eaddr) \
8285
do { \
@@ -96,8 +99,10 @@ typedef struct
9699
int a, b, c, d;
97100
} IP_ADDR;
98101

102+
99103
class RF24;
100-
class RF24Network;
104+
template<class radio_t>
105+
class ESB_Network;
101106

102107
class RF24EthernetClass
103108
{ //: public Print {
@@ -111,6 +116,13 @@ class RF24EthernetClass
111116
#else
112117
RF24EthernetClass(RF24& _radio, RF24Network& _network);
113118
#endif
119+
#if defined NRF52_RADIO_LIBRARY
120+
#if !defined(RF24_TAP)
121+
RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network, RF52Mesh& _mesh);
122+
#else
123+
RF24EthernetClass(nrf_to_nrf& _radio, RF52Network& _network);
124+
#endif
125+
#endif
114126

115127
/** Basic constructor */
116128
RF24EthernetClass();
@@ -176,13 +188,24 @@ class RF24EthernetClass
176188

177189
/** Keeps the TCP/IP stack running & processing incoming data */
178190
void update();
179-
//uint8_t *key;
191+
// uint8_t *key;
180192

181193
private:
194+
#if defined NRF52_RADIO_LIBRARY
195+
nrf_to_nrf& radio;
196+
#else
182197
RF24& radio;
183-
RF24Network& network;
184-
#if !defined(RF24_TAP) // Using RF24Mesh
185-
RF24Mesh& mesh;
198+
#endif
199+
#if !defined NRF52_RADIO_LIBRARY
200+
RF24Network& network;
201+
#if !defined(RF24_TAP) // Using RF24Mesh
202+
RF24Mesh& mesh;
203+
#endif
204+
#else
205+
RF52Network& network;
206+
#if !defined(RF24_TAP) // Using RF24Mesh
207+
RF52Mesh& mesh;
208+
#endif
186209
#endif
187210

188211
static IPAddress _dnsServerAddress;
@@ -206,7 +229,8 @@ class RF24EthernetClass
206229

207230
extern RF24EthernetClass RF24Ethernet;
208231

209-
#endif // RF24Ethernet_h
232+
typedef RF24EthernetClass RF52EthernetClass;
233+
210234

211235
/**
212236
* @example Getting_Started_SimpleServer_Mesh.ino
@@ -225,7 +249,7 @@ extern RF24EthernetClass RF24Ethernet;
225249
/**
226250
* @example Getting_Started_SimpleClient_Mesh_DNS.ino
227251
*
228-
* This is an example of how to use the RF24Ethernet class to connect out to a web server and retrieve data via HTTP,
252+
* This is an example of how to use the RF24Ethernet class to connect out to a web server and retrieve data via HTTP,
229253
* using DNS lookups instead of IP address.
230254
*/
231255

@@ -269,3 +293,6 @@ extern RF24EthernetClass RF24Ethernet;
269293
* <br>This example uses [HTML.h](SLIP__InteractiveServer_2HTML_8h.html) from the
270294
* example's directory.
271295
*/
296+
297+
#endif // RF24Ethernet_h
298+

0 commit comments

Comments
 (0)