nRF24 / RF24Mesh

OSI Layer 7 Mesh Networking for RF24Network & nrf24L01+ & nrf52x devices
http://nrf24.github.io/RF24Mesh
GNU General Public License v2.0
422 stars 154 forks source link

[Request] Adjust debugging output to follow RF24 lib's debug output paradigm #189

Closed 2bndy5 closed 2 years ago

2bndy5 commented 3 years ago

The RF42Mesh lib has its debugging output statements hardcoded to only work on certain boards, while RF24 has its debugging outputs to rely on RF24/printf.h & _RF24config.h. This presents a problem as I've recently expanded the printf mechanism to use more boards (including the Aduino Nano 33 BLE using arduino's MBED core and all boards supported by adaruit's fork of arduino's SAMD core).

I noticed this when testing RF24Mesh examples on my Adafruit QtPy (ATSAMD21) board - no debugging output from RF24Mesh and some faulty/missing debug output from RF24Network (e.g. it doesn't print message data in <millis()>: FRG message <%02x for each char in message>).

Solution

change all

#if defined (MESH_DEBUG)
printf("%u: MSH <statement>\n", millis())
#endif

to

IF_MESH_DEBUG(printf_P("%lu: MSH <statement>", millis(), ...));

where IF_MESH_DEBUG would be defined in _RF24Meshconfig.h like

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

Additional Context

Since we don't need to include everything from _RF24config.h, I was thinking the printf_P related stuff could be abstracted (away from the RF24 utility driver stuff) into its own header (in RF24 lib) called _printfcompatibility.h, but I need to investigate more...

I will also fix the warning in the Arduino compiler output about using %u where it should be %lu because millis() is an unsigned long, and unsigned int is the fallback when no data type is specified (like with %u).

All of this should be considered a temporary workaround until we finalize the RF24Log library.