Compare commits

..

No commits in common. "3d87f2b53070b181d9811f19daf606d5896e3932" and "3b2718e6f41070de1db08f9d173de94e90cc372a" have entirely different histories.

4 changed files with 21 additions and 72 deletions

View file

@ -72,10 +72,3 @@ idf_component_register(
"Settings" "Settings"
"States" "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
View file

@ -35,34 +35,4 @@ menu "KTag SystemK"
help help
Value of audio volume representing the minimum volume possible for this device. 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 endmenu

View file

@ -24,10 +24,8 @@
#include "SystemK.h" #include "SystemK.h"
// Use these defines to enable detailed debug logging of packet encoding and decoding on the PSoC platform. // #define DEBUG_PACKET_ENCODE
// Debug logging is always available on the ESP32 platform, and can be configured with the console. #define DEBUG_PACKET_DECODE
//#define PSoC_DEBUG_PACKET_ENCODE
//#define PSoC_DEBUG_PACKET_DECODE
static const char *KLOG_TAG = "Protocols"; static const char *KLOG_TAG = "Protocols";
@ -222,15 +220,10 @@ TimedPulseTrain_T *PROTOCOLS_EncodePacket(TagPacket_T *packet)
break; break;
} }
#if ((defined PSoC_DEBUG_PACKET_ENCODE) || (defined ESP_PLATFORM)) #ifdef DEBUG_PACKET_ENCODE
#ifdef ESP_PLATFORM KLOG_DEBUG(KLOG_TAG, "\nEncoded %s packet (%u):", ProtocolNameAsString(packet->protocol), result->count);
if (esp_log_level_get(KLOG_TAG) >= ESP_LOG_DEBUG) PrintPulseTrainToConsole(result);
#endif // ESP_PLATFORM #endif // DEBUG_PACKET_ENCODE
{
KLOG_DEBUG(KLOG_TAG, "\nEncoded %s packet (%u):", ProtocolNameAsString(packet->protocol), result->count);
PrintPulseTrainToConsole(result);
}
#endif // ((defined PSoC_DEBUG_PACKET_ENCODE) || (defined ESP_PLATFORM))
return result; return result;
} }
@ -335,33 +328,26 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
result = TEST_MaybeDecodePacket(packet); result = TEST_MaybeDecodePacket(packet);
} }
#if ((defined PSoC_DEBUG_PACKET_DECODE) || (defined ESP_PLATFORM)) #ifdef DEBUG_PACKET_DECODE
#ifdef ESP_PLATFORM if (result != NULL)
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)); vTaskDelay(pdMS_TO_TICKS(10));
if (result != NULL) if (result->Generic.type == DECODED_PACKET_TYPE_COMMAND_RECEIVED)
{ {
KLOG_DEBUG(KLOG_TAG, "Successfully decoded packet as %s: %s", DecodedPacketTypeAsString(result->Generic.type), ProtocolNameAsString(result->Generic.protocol)); KLOG_DEBUG(KLOG_TAG, "Command data: %lu", result->Command.data);
vTaskDelay(pdMS_TO_TICKS(10)); vTaskDelay(pdMS_TO_TICKS(10));
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 // ((defined PSoC_DEBUG_PACKET_DECODE) || (defined ESP_PLATFORM)) 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
// Remember which receiver saw the packet. // Remember which receiver saw the packet.
if (result != NULL) if (result != NULL)

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)) if (packet->bitstream[index].duration < (expected_pulse_duration_in_us - TEST_TOLERANCE_IN_us))
{ {
KLOG_DEBUG(KLOG_TAG, "Pulse %u is too short! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration); KLOG_WARN(KLOG_TAG, "Pulse %u is too short! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration);
return NULL; return NULL;
} }
if (packet->bitstream[index].duration > (expected_pulse_duration_in_us + TEST_TOLERANCE_IN_us)) if (packet->bitstream[index].duration > (expected_pulse_duration_in_us + TEST_TOLERANCE_IN_us))
{ {
KLOG_DEBUG(KLOG_TAG, "Pulse %u is too long! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration); KLOG_WARN(KLOG_TAG, "Pulse %u is too long! Expected %lu; received %u.", index, expected_pulse_duration_in_us, packet->bitstream[index].duration);
return NULL; return NULL;
} }
} }