From eb21f320ac3de6730ed11b537e8c1e5ce5bdd5d1 Mon Sep 17 00:00:00 2001
From: jgromes <jan.gromes@gmail.com>
Date: Tue, 12 Sep 2023 17:20:27 +0200
Subject: [PATCH] [SX126x] Use debug macro for hexdump

---
 src/BuildOpt.h                | 2 ++
 src/modules/SX126x/SX126x.cpp | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/BuildOpt.h b/src/BuildOpt.h
index 48081988..82c777a1 100644
--- a/src/BuildOpt.h
+++ b/src/BuildOpt.h
@@ -457,9 +457,11 @@
       #define RADIOLIB_DEBUG_PRINTLN(M, ...) fprintf(RADIOLIB_DEBUG_PORT, M "\n", ##__VA_ARGS__)
     #endif
   #endif
+  #define RADIOLIB_DEBUG_HEXDUMP(...) Module::hexdump(__VA_ARGS__)
 #else
   #define RADIOLIB_DEBUG_PRINT(...) {}
   #define RADIOLIB_DEBUG_PRINTLN(...) {}
+  #define RADIOLIB_DEBUG_HEXDUMP(...) {}
 #endif
 
 #if defined(RADIOLIB_VERBOSE)
diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp
index 69abb173..a4257510 100644
--- a/src/modules/SX126x/SX126x.cpp
+++ b/src/modules/SX126x/SX126x.cpp
@@ -2097,13 +2097,13 @@ bool SX126x::findChip(const char* verStr) {
     // check version register
     if(strncmp(verStr, version, 6) == 0) {
       RADIOLIB_DEBUG_PRINTLN("Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:");
-      this->mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
+      RADIOLIB_DEBUG_HEXDUMP((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
       RADIOLIB_DEBUG_PRINTLN();
       flagFound = true;
     } else {
       #if defined(RADIOLIB_DEBUG)
         RADIOLIB_DEBUG_PRINTLN("SX126x not found! (%d of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:", i + 1);
-        this->mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
+        RADIOLIB_DEBUG_HEXDUMP((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
         RADIOLIB_DEBUG_PRINTLN("Expected string: %s", verStr);
       #endif
       this->mod->hal->delay(10);