Added log level configuration to Kconfig.
This commit is contained in:
parent
3b2718e6f4
commit
e62f243e86
4 changed files with 65 additions and 16 deletions
|
|
@ -72,3 +72,10 @@ idf_component_register(
|
|||
"Settings"
|
||||
"States"
|
||||
)
|
||||
|
||||
# This ensures LOG_LOCAL_LEVEL is defined before any header files are included.
|
||||
idf_build_set_property(COMPILE_DEFINITIONS
|
||||
"-DLOG_LOCAL_LEVEL=${CONFIG_SYSTEMK_LOG_LEVEL}"
|
||||
APPEND
|
||||
)
|
||||
|
||||
|
|
|
|||
30
Kconfig
30
Kconfig
|
|
@ -35,4 +35,34 @@ menu "KTag SystemK"
|
|||
help
|
||||
Value of audio volume representing the minimum volume possible for this device.
|
||||
|
||||
config SYSTEMK_LOG_LEVEL
|
||||
int
|
||||
default 0 if SYSTEMK_LOG_LEVEL_NONE
|
||||
default 1 if SYSTEMK_LOG_LEVEL_ERROR
|
||||
default 2 if SYSTEMK_LOG_LEVEL_WARN
|
||||
default 3 if SYSTEMK_LOG_LEVEL_INFO
|
||||
default 4 if SYSTEMK_LOG_LEVEL_DEBUG
|
||||
default 5 if SYSTEMK_LOG_LEVEL_VERBOSE
|
||||
|
||||
choice SYSTEMK_LOG_LEVEL_CHOICE
|
||||
bool "SystemK maximum log level"
|
||||
default SYSTEMK_LOG_LEVEL_VERBOSE
|
||||
help
|
||||
Set the maximum compiled log level for SystemK.
|
||||
Messages at higher levels will be removed at compile time.
|
||||
|
||||
config SYSTEMK_LOG_LEVEL_NONE
|
||||
bool "No output"
|
||||
config SYSTEMK_LOG_LEVEL_ERROR
|
||||
bool "Error"
|
||||
config SYSTEMK_LOG_LEVEL_WARN
|
||||
bool "Warning"
|
||||
config SYSTEMK_LOG_LEVEL_INFO
|
||||
bool "Info"
|
||||
config SYSTEMK_LOG_LEVEL_DEBUG
|
||||
bool "Debug"
|
||||
config SYSTEMK_LOG_LEVEL_VERBOSE
|
||||
bool "Verbose"
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SystemK.h"
|
||||
|
||||
// #define DEBUG_PACKET_ENCODE
|
||||
#define DEBUG_PACKET_ENCODE
|
||||
#define DEBUG_PACKET_DECODE
|
||||
|
||||
static const char *KLOG_TAG = "Protocols";
|
||||
|
|
@ -221,8 +221,13 @@ TimedPulseTrain_T *PROTOCOLS_EncodePacket(TagPacket_T *packet)
|
|||
}
|
||||
|
||||
#ifdef DEBUG_PACKET_ENCODE
|
||||
#ifdef ESP_PLATFORM
|
||||
if (esp_log_level_get(KLOG_TAG) >= ESP_LOG_DEBUG)
|
||||
#endif // ESP_PLATFORM
|
||||
{
|
||||
KLOG_DEBUG(KLOG_TAG, "\nEncoded %s packet (%u):", ProtocolNameAsString(packet->protocol), result->count);
|
||||
PrintPulseTrainToConsole(result);
|
||||
}
|
||||
#endif // DEBUG_PACKET_ENCODE
|
||||
|
||||
return result;
|
||||
|
|
@ -329,6 +334,12 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
|
|||
}
|
||||
|
||||
#ifdef DEBUG_PACKET_DECODE
|
||||
#ifdef ESP_PLATFORM
|
||||
if (esp_log_level_get(KLOG_TAG) >= ESP_LOG_DEBUG)
|
||||
#endif // ESP_PLATFORM
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
|
||||
if (result != NULL)
|
||||
{
|
||||
KLOG_DEBUG(KLOG_TAG, "Successfully decoded packet as %s: %s", DecodedPacketTypeAsString(result->Generic.type), ProtocolNameAsString(result->Generic.protocol));
|
||||
|
|
@ -347,6 +358,7 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
|
|||
|
||||
PrintPulseTrainToConsole(packet);
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_PACKET_DECODE
|
||||
|
||||
// Remember which receiver saw the packet.
|
||||
|
|
|
|||
|
|
@ -118,12 +118,12 @@ DecodedPacket_T *TEST_MaybeDecodePacket(TimedPulseTrain_T *packet)
|
|||
|
||||
if (packet->bitstream[index].duration < (expected_pulse_duration_in_us - TEST_TOLERANCE_IN_us))
|
||||
{
|
||||
KLOG_WARN(KLOG_TAG, "Pulse %u is too short! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration);
|
||||
KLOG_DEBUG(KLOG_TAG, "Pulse %u is too short! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration);
|
||||
return NULL;
|
||||
}
|
||||
if (packet->bitstream[index].duration > (expected_pulse_duration_in_us + TEST_TOLERANCE_IN_us))
|
||||
{
|
||||
KLOG_WARN(KLOG_TAG, "Pulse %u is too long! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration);
|
||||
KLOG_DEBUG(KLOG_TAG, "Pulse %u is too long! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue