Skip to content

Commit

Permalink
change MESH_DEBUG into RF24MESH_DEBUG (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jun 15, 2024
1 parent a007a86 commit 4fbd113
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/GetLibInfo.cmake) # sets the variable Li

# allow using CMake options to adjust RF24Network_config.h without modiying source code
option(MESH_NOMASTER "exclude compiling code that is strictly for master nodes" OFF)
option(MESH_DEBUG "enable/disable debugging output" OFF)
option(MESH_DEBUG_MINIMAL "enable/disable minimal debugging output" OFF)
option(RF24MESH_DEBUG "enable/disable debugging output" OFF)
option(RF24MESH_DEBUG_MINIMAL "enable/disable minimal debugging output" OFF)

# Link this 'library' to set the c++ standard / compile-time options requested
add_library(${LibTargetName}_project_options INTERFACE)
Expand Down Expand Up @@ -110,13 +110,13 @@ if(MESH_NOMASTER)
message(STATUS "MESH_NOMASTER asserted")
target_compile_definitions(${LibTargetName} PUBLIC MESH_NOMASTER)
endif()
if(MESH_DEBUG)
message(STATUS "MESH_DEBUG asserted")
target_compile_definitions(${LibTargetName} PUBLIC MESH_DEBUG)
if(RF24MESH_DEBUG)
message(STATUS "RF24MESH_DEBUG asserted")
target_compile_definitions(${LibTargetName} PUBLIC RF24MESH_DEBUG)
endif()
if(MESH_DEBUG_MINIMAL)
message(STATUS "MESH_DEBUG_MINIMAL asserted")
target_compile_definitions(${LibTargetName} PUBLIC MESH_DEBUG_MINIMAL)
if(RF24MESH_DEBUG_MINIMAL)
message(STATUS "RF24MESH_DEBUG_MINIMAL asserted")
target_compile_definitions(${LibTargetName} PUBLIC RF24MESH_DEBUG_MINIMAL)
endif()
# for the following, we let the default be configured in source code
if(DEFINED MESH_MAX_CHILDREN)
Expand Down
22 changes: 11 additions & 11 deletions RF24Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ bool RF24Mesh::requestAddress(uint8_t level)
{
RF24NetworkHeader header(MESH_MULTICAST_ADDRESS, NETWORK_POLL);
//Find another radio, starting with level 0 multicast
IF_MESH_DEBUG(printf_P(PSTR("MSH Poll Level %d\n"), level));
IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Poll Level %d\n"), level));
network.multicast(header, 0, 0, level);

uint32_t timeout = millis() + 55;
Expand All @@ -308,7 +308,7 @@ bool RF24Mesh::requestAddress(uint8_t level)
uint8_t pollCount = 0;

while (millis() < timeout && pollCount < MESH_MAXPOLLS) {
#if defined(MESH_DEBUG)
#if defined(RF24MESH_DEBUG)
bool goodSignal = radio.testRPD();
#endif
if (network.update() == NETWORK_POLL) {
Expand All @@ -326,15 +326,15 @@ bool RF24Mesh::requestAddress(uint8_t level)
if (!isDupe) {
contactNode[pollCount] = contact;
++pollCount;
IF_MESH_DEBUG(printf_P(PSTR("MSH Poll %c -64dbm from 0%o \n"), (goodSignal ? '>' : '<'), contact));
IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Poll %c -64dbm from 0%o \n"), (goodSignal ? '>' : '<'), contact));
}

} // end if

MESH_CALLBACK
} // end while

IF_MESH_DEBUG(printf_P(PSTR("MSH Polls from level %d: %d\n"), level, pollCount));
IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Polls from level %d: %d\n"), level, pollCount));

if (!pollCount) return 0;

Expand All @@ -350,7 +350,7 @@ bool RF24Mesh::requestAddress(uint8_t level)
// Do a direct write (no ack) to the contact node. Include the nodeId and address.
network.write(header, 0, 0, contactNode[i]);

IF_MESH_DEBUG(printf_P(PSTR("MSH Request address from: 0%o\n"), contactNode[i]));
IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Request address from: 0%o\n"), contactNode[i]));

timeout = millis() + 225;

Expand All @@ -377,7 +377,7 @@ bool RF24Mesh::requestAddress(uint8_t level)
uint16_t newAddress = 0;
memcpy(&newAddress, network.frame_buffer + sizeof(RF24NetworkHeader), sizeof(newAddress));

IF_MESH_DEBUG(printf_P(PSTR("Set address: Current: 0%o New: 0%o\n"), mesh_address, newAddress));
IF_RF24MESH_DEBUG(printf_P(PSTR("Set address: Current: 0%o New: 0%o\n"), mesh_address, newAddress));
mesh_address = newAddress;

radio.stopListening();
Expand Down Expand Up @@ -501,7 +501,7 @@ void RF24Mesh::DHCP()

// Get the unique id of the requester (ID is in header.reserved)
if (!header.reserved || header.type != NETWORK_REQ_ADDRESS) {
IF_MESH_DEBUG(printf_P(PSTR("MSH Invalid id or type rcvd\n")));
IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Invalid id or type rcvd\n")));
return;
}

Expand All @@ -525,7 +525,7 @@ void RF24Mesh::DHCP()
extraChild = 1;
}

// IF_MESH_DEBUG(printf_P(PSTR("%u: MSH Rcv addr req from_id %d\n"), millis(), header.reserved));
// IF_RF24MESH_DEBUG(printf_P(PSTR("%u: MSH Rcv addr req from_id %d\n"), millis(), header.reserved));

for (int i = MESH_MAX_CHILDREN + extraChild; i > 0; i--) { // For each of the possible addresses (5 max)

Expand All @@ -535,7 +535,7 @@ void RF24Mesh::DHCP()
if (newAddress == MESH_DEFAULT_ADDRESS) continue;

for (uint8_t i = 0; i < addrListTop; i++) {
IF_MESH_DEBUG_MINIMAL(printf_P(PSTR("ID: %d ADDR: 0%o\n"), addrList[i].nodeID, addrList[i].address));
IF_RF24MESH_DEBUG_MINIMAL(printf_P(PSTR("ID: %d ADDR: 0%o\n"), addrList[i].nodeID, addrList[i].address));
if (addrList[i].address == newAddress && addrList[i].nodeID != header.reserved) {
found = true;
break;
Expand Down Expand Up @@ -564,11 +564,11 @@ void RF24Mesh::DHCP()
network.write(header, &newAddress, sizeof(newAddress), header.to_node);
}

IF_MESH_DEBUG(printf_P(PSTR("Sent to 0%o phys: 0%o new: 0%o id: %d\n"), header.to_node, MESH_DEFAULT_ADDRESS, newAddress, header.reserved));
IF_RF24MESH_DEBUG(printf_P(PSTR("Sent to 0%o phys: 0%o new: 0%o id: %d\n"), header.to_node, MESH_DEFAULT_ADDRESS, newAddress, header.reserved));
break;
}
else {
IF_MESH_DEBUG(printf_P(PSTR("not allocated\n")));
IF_RF24MESH_DEBUG(printf_P(PSTR("not allocated\n")));
}
} // end for
}
Expand Down
16 changes: 8 additions & 8 deletions RF24Mesh_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@

/**************************/
/*** Debug ***/
//#define MESH_DEBUG_MINIMAL /** Uncomment for the Master Node to print out address assignments as they are assigned */
//#define MESH_DEBUG /** Uncomment to enable debug output to serial **/
//#define RF24MESH_DEBUG_MINIMAL /** Uncomment for the Master Node to print out address assignments as they are assigned */
//#define RF24MESH_DEBUG /** Uncomment to enable debug output to serial **/
/**************************/

/*** Other Configuration ***/
Expand Down Expand Up @@ -98,16 +98,16 @@
#include <RF24_config.h>
#endif

#if defined(MESH_DEBUG_MINIMAL)
#define IF_MESH_DEBUG_MINIMAL(x) ({ x; })
#if defined(RF24MESH_DEBUG_MINIMAL)
#define IF_RF24MESH_DEBUG_MINIMAL(x) ({ x; })
#else
#define IF_MESH_DEBUG_MINIMAL(x)
#define IF_RF24MESH_DEBUG_MINIMAL(x)
#endif

#if defined(MESH_DEBUG)
#define IF_MESH_DEBUG(x) ({ x; })
#if defined(RF24MESH_DEBUG)
#define IF_RF24MESH_DEBUG(x) ({ x; })
#else
#define IF_MESH_DEBUG(x)
#define IF_RF24MESH_DEBUG(x)
#endif

#endif // __RF24MESH_CONFIG_H__

0 comments on commit 4fbd113

Please sign in to comment.