From 99253efd75a1c8e47a2d4080c4aa4794dbe8dfe9 Mon Sep 17 00:00:00 2001 From: dlktdr Date: Thu, 9 Dec 2021 20:39:41 -0800 Subject: [PATCH] Add verbose option --- radio/src/bluetooth.cpp | 8 ++++---- radio/src/bluetooth.h | 8 ++++++++ radio/src/targets/common/arm/CMakeLists.txt | 6 +++++- radio/src/targets/common/arm/stm32/bluetooth_driver.cpp | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/radio/src/bluetooth.cpp b/radio/src/bluetooth.cpp index 72aaab1d0..3a3c5dd87 100644 --- a/radio/src/bluetooth.cpp +++ b/radio/src/bluetooth.cpp @@ -57,12 +57,12 @@ Bluetooth bluetooth; void Bluetooth::write(const uint8_t * data, uint8_t length) { if (btTxFifo.hasSpace(length)) { - BLUETOOTH_TRACE("BT>"); + BLUETOOTH_TRACE_VERBOSE("BT>"); for (int i = 0; i < length; i++) { - BLUETOOTH_TRACE(" %02X", data[i]); + BLUETOOTH_TRACE_VERBOSE(" %02X", data[i]); btTxFifo.push(data[i]); } - BLUETOOTH_TRACE(CRLF); + BLUETOOTH_TRACE_VERBOSE(CRLF); } else { BLUETOOTH_TRACE("[BT] TX fifo full!" CRLF); @@ -95,7 +95,7 @@ char * Bluetooth::readline(bool error_reset) return nullptr; } - BLUETOOTH_TRACE("%02X ", byte); + BLUETOOTH_TRACE_VERBOSE("%02X ", byte); #if 0 if (error_reset && byte == 'R' && bufferIndex == 4 && memcmp(buffer, "ERRO", 4)) { diff --git a/radio/src/bluetooth.h b/radio/src/bluetooth.h index 17fecfbc0..a2f07a0cd 100644 --- a/radio/src/bluetooth.h +++ b/radio/src/bluetooth.h @@ -58,8 +58,16 @@ enum BluetoothStates { #else #if defined(DEBUG_BLUETOOTH) #define BLUETOOTH_TRACE(...) TRACE_NOCRLF(__VA_ARGS__); + #define BLUETOOTH_TRACE_TIMESTAMP(f_, ...) debugPrintf((TRACE_TIME_FORMAT f_), TRACE_TIME_VALUE, ##__VA_ARGS__) +#if defined(DEBUG_BLUETOOTH_VERBOSE) + #define BLUETOOTH_TRACE_VERBOSE(...) TRACE_NOCRLF(__VA_ARGS__); +#else + #define BLUETOOTH_TRACE_VERBOSE(...) +#endif #else #define BLUETOOTH_TRACE(...) + #define BLUETOOTH_TIMESTAMP(f_, ...) + #define BLUETOOTH_TRACE_VERBOSE(...) #endif #endif diff --git a/radio/src/targets/common/arm/CMakeLists.txt b/radio/src/targets/common/arm/CMakeLists.txt index 325462e22..535ad60ef 100644 --- a/radio/src/targets/common/arm/CMakeLists.txt +++ b/radio/src/targets/common/arm/CMakeLists.txt @@ -143,7 +143,11 @@ if(DEBUG_LATENCY STREQUAL END_TO_END) endif() if(DEBUG_BLUETOOTH) - add_definitions(-DDEBUG_BLUETOOTH) + add_definitions(-DDEBUG_BLUETOOTH) + option(DEBUG_BLUETOOTH_VERBOSE "Debug Bluetooth Verbose" OFF) + if(DEBUG_BLUETOOTH_VERBOSE) + add_definitions(-DDEBUG_BLUETOOTH_VERBOSE) + endif() endif() if(CLI) diff --git a/radio/src/targets/common/arm/stm32/bluetooth_driver.cpp b/radio/src/targets/common/arm/stm32/bluetooth_driver.cpp index 09b43a66c..00c1e40b6 100644 --- a/radio/src/targets/common/arm/stm32/bluetooth_driver.cpp +++ b/radio/src/targets/common/arm/stm32/bluetooth_driver.cpp @@ -123,7 +123,7 @@ extern "C" void BT_USART_IRQHandler(void) USART_ClearITPendingBit(BT_USART, USART_IT_RXNE); uint8_t byte = USART_ReceiveData(BT_USART); btRxFifo.push(byte); - BLUETOOTH_TRACE("BT %02X", byte); + BLUETOOTH_TRACE_VERBOSE("BT %02X" CRLF, byte); #if defined(BLUETOOTH_PROBE) if (!btChipPresent) { // This is to differentiate X7 and X7S and X-Lite with/without BT