diff --git a/Debug-mode.md b/Debug-mode.md index bfde409..8a80d85 100644 --- a/Debug-mode.md +++ b/Debug-mode.md @@ -2,21 +2,29 @@ When something isn't working as expected, it might be useful to take a peek "und ## Enabling debug -To enable debug, you can go to the [BuildOptUser.h](https://github.com/jgromes/RadioLib/blob/master/src/BuildOptUser.h) file, and uncomment either one or both of these lines: +To enable debug, you can go to the [BuildOptUser.h](https://github.com/jgromes/RadioLib/blob/master/src/BuildOptUser.h) file, and uncomment any of these lines: ```c++ -//#define RADIOLIB_DEBUG (1) -//#define RADIOLIB_VERBOSE (1) +//#define RADIOLIB_DEBUG_BASIC (1) // basic debugging (e.g. reporting GPIO timeouts or module not being found) +//#define RADIOLIB_DEBUG_PROTOCOL (1) // protocol information (e.g. LoRaWAN internal information) +//#define RADIOLIB_DEBUG_SPI (1) // verbose transcription of all SPI communication - produces large debug logs! ``` +Any combination of debug levels may be enabled, information from different levels are distinguished by a prefix. + The default debug port is set to `Serial`, on most Arduino boards, this should correspond to the Serial port connected to USB. If you want to use a different port, simply change the value of `RADIOLIB_DEBUG_PORT` macro to e.g. `Serial2`, or whichever Serial port you want to use. `SoftwareSerial` ports are supported as well. __NOTE:__ RadioLib DOES NOT automatically initialize the debug port with `Serial.begin()`. This is done to prevent collisions when user already calls the `begin()` method from Arduino sketch. For that reason, debug interface initialization MUST be done prior to RadioLib module initialization (e.g. `lora.begin()`, otherwise there will be no debug output from the `begin()` method. +On non-Arduino platforms, `RADIOLIB_DEBUG_PORT` defaults to `stdout`. + ## Debug levels -### RADIOLIB_DEBUG -Enabling this macro will only print out basic debug info - for example, when writing to an SPI register fails. This is useful on modules like SX127x or RF69, which use direct SPI register access. +### RADIOLIB_DEBUG_BASIC ("RLB_DBG") +Enabling this macro will only print out basic debug info - for example, timeouts when waiting for GPIO signals or radio module not being found due to version register mismatch. -### RADIOLIB_VERBOSE -Enabling this macro will print out full transcript of all SPI or UART communication. This is useful on modules like SX126x or UART-based modules, which have command-based interface (instead of SPI register transfers). \ No newline at end of file +### RADIOLIB_DEBUG_PROTOCOL ("RLB_PRO") +Enabling this macro will print information important for debugging protocols. This is very useful when debugging LoRaWAN. + +### RADIOLIB_DEBUG_SPI ("RLB_SPI") +Enabling this macro will print out full transcript of all SPI communication. It should be noted that this outputs A LOT of information in the debug log. This can make debugging higher levels (e.g. protocols) cumbersome, so it should only be used when investigating issues with the radio module itself. \ No newline at end of file