Added log level configuration to Kconfig.

This commit is contained in:
Joe Kearney 2026-01-08 21:37:49 -06:00
parent 3b2718e6f4
commit e62f243e86
4 changed files with 65 additions and 16 deletions

View file

@ -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
KLOG_DEBUG(KLOG_TAG, "\nEncoded %s packet (%u):", ProtocolNameAsString(packet->protocol), result->count);
PrintPulseTrainToConsole(result);
#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,23 +334,30 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
}
#ifdef DEBUG_PACKET_DECODE
if (result != NULL)
#ifdef ESP_PLATFORM
if (esp_log_level_get(KLOG_TAG) >= ESP_LOG_DEBUG)
#endif // ESP_PLATFORM
{
KLOG_DEBUG(KLOG_TAG, "Successfully decoded packet as %s: %s", DecodedPacketTypeAsString(result->Generic.type), ProtocolNameAsString(result->Generic.protocol));
vTaskDelay(pdMS_TO_TICKS(10));
if (result->Generic.type == DECODED_PACKET_TYPE_COMMAND_RECEIVED)
if (result != NULL)
{
KLOG_DEBUG(KLOG_TAG, "Command data: %lu", result->Command.data);
KLOG_DEBUG(KLOG_TAG, "Successfully decoded packet as %s: %s", DecodedPacketTypeAsString(result->Generic.type), ProtocolNameAsString(result->Generic.protocol));
vTaskDelay(pdMS_TO_TICKS(10));
}
}
else
{
KLOG_DEBUG(KLOG_TAG, "Couldn't decode packet. Size was %d symbols:", packet->count);
vTaskDelay(pdMS_TO_TICKS(10));
PrintPulseTrainToConsole(packet);
if (result->Generic.type == DECODED_PACKET_TYPE_COMMAND_RECEIVED)
{
KLOG_DEBUG(KLOG_TAG, "Command data: %lu", result->Command.data);
vTaskDelay(pdMS_TO_TICKS(10));
}
}
else
{
KLOG_DEBUG(KLOG_TAG, "Couldn't decode packet. Size was %d symbols:", packet->count);
vTaskDelay(pdMS_TO_TICKS(10));
PrintPulseTrainToConsole(packet);
}
}
#endif // DEBUG_PACKET_DECODE

View file

@ -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;
}
}