Skip to content

Commit 85a372f

Browse files
committed
Remove nrf_to_nrf support
1 parent b774f03 commit 85a372f

File tree

2 files changed

+21
-40
lines changed

2 files changed

+21
-40
lines changed

RF24Mesh.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
#include <fstream>
1111
#endif
1212

13-
#if defined NRF52_RADIO_LIBRARY
14-
RF24Mesh::RF24Mesh(nrf_to_nrf& _radio, RF24Network& _network) : radio(_radio), network(_network)
15-
#else
1613
RF24Mesh::RF24Mesh(RF24& _radio, RF24Network& _network) : radio(_radio), network(_network)
17-
#endif
1814
{
1915
setCallback(NULL);
2016
meshStarted = false;
@@ -27,7 +23,7 @@ RF24Mesh::RF24Mesh(RF24& _radio, RF24Network& _network) : radio(_radio), network
2723

2824
bool RF24Mesh::begin(uint8_t channel, rf24_datarate_e data_rate, uint32_t timeout)
2925
{
30-
// delay(1); // Found problems w/SPIDEV & ncurses. Without this, getch() returns a stream of garbage
26+
//delay(1); // Found problems w/SPIDEV & ncurses. Without this, getch() returns a stream of garbage
3127
if (meshStarted) {
3228
radio.stopListening();
3329
}
@@ -38,7 +34,7 @@ bool RF24Mesh::begin(uint8_t channel, rf24_datarate_e data_rate, uint32_t timeou
3834
radio.setDataRate(data_rate);
3935
network.returnSysMsgs = true;
4036

41-
if (getNodeID() > 0) { // Not master node
37+
if (getNodeID() > 0) { //Not master node
4238
if (renewAddress(timeout) == MESH_DEFAULT_ADDRESS) {
4339
return false;
4440
}
@@ -97,7 +93,7 @@ uint8_t RF24Mesh::update()
9793
}
9894
}
9995
}
100-
#endif //! NO_MASTER
96+
#endif //!NO_MASTER
10197

10298
return type;
10399
}
@@ -168,13 +164,13 @@ bool RF24Mesh::checkConnection()
168164
int16_t RF24Mesh::getAddress(uint8_t nodeID)
169165
{ // Master will return and send 00 address for a nodeID with address 0, -1 if not found
170166

171-
// if (nodeID == _nodeID) return mesh_address;
167+
//if (nodeID == _nodeID) return mesh_address;
172168
if (!nodeID) return 0;
173169
if (mesh_address == MESH_DEFAULT_ADDRESS) return -2;
174170

175171
// Lets say 0 if nodeID 0, -1 if write failed or timed out, -2 if not found in list or address is default,
176172
#if !defined(MESH_NOMASTER)
177-
if (!getNodeID()) { // Master Node
173+
if (!getNodeID()) { //Master Node
178174
for (uint8_t i = 0; i < addrListTop; i++) {
179175
if (addrList[i].nodeID == nodeID) {
180176
return addrList[i].address;
@@ -209,7 +205,7 @@ int16_t RF24Mesh::getNodeID(uint16_t address)
209205
if (mesh_address == MESH_DEFAULT_ADDRESS) return -2;
210206

211207
#if !defined(MESH_NOMASTER)
212-
if (!mesh_address) { // Master Node
208+
if (!mesh_address) { //Master Node
213209
for (uint8_t i = 0; i < addrListTop; i++) {
214210
if (addrList[i].address == address) {
215211
return addrList[i].nodeID;
@@ -302,7 +298,7 @@ uint16_t RF24Mesh::renewAddress(uint32_t timeout)
302298
bool RF24Mesh::requestAddress(uint8_t level)
303299
{
304300
RF24NetworkHeader header(MESH_MULTICAST_ADDRESS, NETWORK_POLL);
305-
// Find another radio, starting with level 0 multicast
301+
//Find another radio, starting with level 0 multicast
306302
IF_MESH_DEBUG(printf_P(PSTR("%u: MSH Poll\n"), millis()));
307303
network.multicast(header, 0, 0, level);
308304

@@ -319,7 +315,7 @@ bool RF24Mesh::requestAddress(uint8_t level)
319315
if (network.update() == NETWORK_POLL) {
320316

321317
memcpy(&contactNode[pollCount], &network.frame_buffer[0], sizeof(uint16_t));
322-
if (pollCount > 0 && contactNode[pollCount] != contactNode[pollCount - 1]) { // Drop duplicate polls to help prevent duplicate requests
318+
if (pollCount > 0 && contactNode[pollCount] != contactNode[pollCount - 1]) { //Drop duplicate polls to help prevent duplicate requests
323319
++pollCount;
324320
}
325321
else {
@@ -418,20 +414,20 @@ void RF24Mesh::setStaticAddress(uint8_t nodeID, uint16_t address)
418414

419415
void RF24Mesh::setAddress(uint8_t nodeID, uint16_t address, bool searchBy)
420416
{
421-
// Look for the node in the list
417+
//Look for the node in the list
422418
for (uint8_t i = 0; i < addrListTop; i++) {
423419
if (searchBy == false) {
424420
if (addrList[i].nodeID == nodeID) {
425421
addrList[i].address = address;
426422
#if defined(__linux) && !defined(__ARDUINO_X86__)
427423
saveDHCP();
428424
#endif
429-
return; // Found & set, complete
425+
return; //Found & set, complete
430426
}
431427
}
432428
else { // Search by address, set the nodeID
433429
if (addrList[i].address == address) {
434-
// printf("*** Addr 0%o Found, reassign fr ID %d to ID %d ***\n", addrList[i].address, addrList[i].nodeID, nodeID);
430+
//printf("*** Addr 0%o Found, reassign fr ID %d to ID %d ***\n", addrList[i].address, addrList[i].nodeID, nodeID);
435431
addrList[i].nodeID = nodeID;
436432
#if defined(__linux) && !defined(__ARDUINO_X86__)
437433
saveDHCP();
@@ -445,7 +441,7 @@ void RF24Mesh::setAddress(uint8_t nodeID, uint16_t address, bool searchBy)
445441
addrList = (addrListStruct*)realloc(addrList, (addrListTop + MESH_MEM_ALLOC_SIZE) * sizeof(addrListStruct));
446442
}
447443
addrList[addrListTop].address = address;
448-
addrList[addrListTop++].nodeID = nodeID; // Set the value AND increment Top without another line of code
444+
addrList[addrListTop++].nodeID = nodeID; //Set the value AND increment Top without another line of code
449445
#if defined(__linux) && !defined(__ARDUINO_X86__)
450446
saveDHCP();
451447
#endif
@@ -517,14 +513,14 @@ void RF24Mesh::DHCP()
517513
uint16_t m = fwd_by;
518514
uint8_t count = 0;
519515

520-
while (m) { // Octal addresses convert nicely to binary in threes. Address 03 = B011 Address 033 = B011011
521-
m >>= 3; // Find out how many digits are in the octal address
516+
while (m) { //Octal addresses convert nicely to binary in threes. Address 03 = B011 Address 033 = B011011
517+
m >>= 3; //Find out how many digits are in the octal address
522518
count += 3;
523519
}
524-
shiftVal = count; // Now we know how many bits to shift when adding a child node 1-5 (B001 to B101) to any address
520+
shiftVal = count; //Now we know how many bits to shift when adding a child node 1-5 (B001 to B101) to any address
525521
}
526522
else {
527-
// If request is coming from level 1, add an extra child to the master
523+
//If request is coming from level 1, add an extra child to the master
528524
extraChild = 1;
529525
}
530526

@@ -548,22 +544,22 @@ void RF24Mesh::DHCP()
548544
if (!found) {
549545
header.type = NETWORK_ADDR_RESPONSE;
550546
header.to_node = header.from_node;
551-
// This is a routed request to 00
547+
//This is a routed request to 00
552548

553549
setAddress(header.reserved, newAddress);
554550
// without this delay, address renewal fails for children with slower execution speed
555551
#if defined(SLOW_ADDR_POLL_RESPONSE)
556552
delay(SLOW_ADDR_POLL_RESPONSE);
557553
#endif // defined (SLOW_ADDR_POLL_RESPONSE)
558554

559-
if (header.from_node != MESH_DEFAULT_ADDRESS) { // Is NOT node 01 to 05
560-
// delay(2);
555+
if (header.from_node != MESH_DEFAULT_ADDRESS) { //Is NOT node 01 to 05
556+
//delay(2);
561557
if (!network.write(header, &newAddress, sizeof(newAddress))) {
562558
network.write(header, &newAddress, sizeof(newAddress));
563559
}
564560
}
565561
else {
566-
// delay(2);
562+
//delay(2);
567563
network.write(header, &newAddress, sizeof(newAddress), header.to_node);
568564
}
569565

RF24Mesh.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,13 @@
4040
#define RF24_LINUX
4141
#else
4242
#include <RF24.h>
43-
#if defined ARDUINO_ARCH_NRF52 || defined ARDUINO_ARCH_NRF52840 || defined ARDUINO_ARCH_NRF52833
44-
#include <nrf_to_nrf.h>
45-
#endif
4643
#include <RF24Network.h>
4744
#endif
4845

4946
#include <stddef.h>
5047
#include <stdint.h>
5148

52-
#if defined NRF52_RADIO_LIBRARY
53-
class nrf_to_nrf;
54-
#else
5549
class RF24;
56-
#endif
5750
class RF24Network;
5851

5952
class RF24Mesh
@@ -77,12 +70,8 @@ class RF24Mesh
7770
* @param _radio The underlying radio driver instance
7871
* @param _network The underlying network instance
7972
*/
80-
81-
#if defined NRF52_RADIO_LIBRARY
82-
RF24Mesh(nrf_to_nrf& _radio, RF24Network& _network);
83-
#else
8473
RF24Mesh(RF24& _radio, RF24Network& _network);
85-
#endif
74+
8675
/**
8776
* Call this in setup() to configure the mesh and request an address. <br>
8877
*
@@ -329,11 +318,7 @@ class RF24Mesh
329318
/**@}*/
330319

331320
private:
332-
#if defined NRF52_RADIO_LIBRARY
333-
nrf_to_nrf& radio;
334-
#else
335321
RF24& radio;
336-
#endif
337322
RF24Network& network;
338323

339324
/** Function pointer for customized callback usage in long running algorithms. */

0 commit comments

Comments
 (0)