diff --git a/README.md b/README.md index 7f38131..cc22874 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ [![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 @@ -13,8 +13,12 @@ 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. ------------- diff --git a/RF24Ethernet.cpp b/RF24Ethernet.cpp index 0c7fca7..86837a2 100644 --- a/RF24Ethernet.cpp +++ b/RF24Ethernet.cpp @@ -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() @@ -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; @@ -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)); } } @@ -288,7 +301,7 @@ void RF24EthernetClass::tick() uip_arp_timer(); } } -#endif //RF24_TAP +#endif // RF24_TAP } /*******************************************************/ diff --git a/RF24Ethernet.h b/RF24Ethernet.h index d8ee3f8..40adb67 100644 --- a/RF24Ethernet.h +++ b/RF24Ethernet.h @@ -38,6 +38,9 @@ extern "C" { } #include "RF24Ethernet_config.h" + #if defined (ARDUINO_ARCH_NRF52) || defined (ARDUINO_ARCH_NRF52840) || defined (ARDUINO_ARCH_NRF52833) + #include + #endif #include #include #if !defined(RF24_TAP) // Using RF24Mesh @@ -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 { \ @@ -96,8 +99,10 @@ typedef struct int a, b, c, d; } IP_ADDR; + class RF24; -class RF24Network; +template +class ESB_Network; class RF24EthernetClass { //: public Print { @@ -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(); @@ -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; @@ -206,7 +229,8 @@ class RF24EthernetClass extern RF24EthernetClass RF24Ethernet; -#endif // RF24Ethernet_h +typedef RF24EthernetClass RF52EthernetClass; + /** * @example Getting_Started_SimpleServer_Mesh.ino @@ -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. */ @@ -269,3 +293,6 @@ extern RF24EthernetClass RF24Ethernet; *
This example uses [HTML.h](SLIP__InteractiveServer_2HTML_8h.html) from the * example's directory. */ + + #endif // RF24Ethernet_h + \ No newline at end of file