Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change MESH_DEBUG into RF24MESH_DEBUG #239

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -314,7 +314,7 @@ bool ESBMesh<network_t, radio_t>::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 @@ -323,7 +323,7 @@ bool ESBMesh<network_t, radio_t>::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 @@ -341,15 +341,15 @@ bool ESBMesh<network_t, radio_t>::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 @@ -365,7 +365,7 @@ bool ESBMesh<network_t, radio_t>::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 @@ -392,7 +392,7 @@ bool ESBMesh<network_t, radio_t>::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 @@ -522,7 +522,7 @@ void ESBMesh<network_t, radio_t>::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 @@ -546,7 +546,7 @@ void ESBMesh<network_t, radio_t>::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 @@ -556,7 +556,7 @@ void ESBMesh<network_t, radio_t>::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 @@ -585,11 +585,11 @@ void ESBMesh<network_t, radio_t>::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__