Added support for configurable logging on the ESP32 platform. #10
5 changed files with 75 additions and 29 deletions
|
|
@ -72,3 +72,10 @@ 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
30
Kconfig
|
|
@ -35,4 +35,34 @@ 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
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||||
*
|
*
|
||||||
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
|
* Copyright © 2016-2026 Joseph P. Kearney and the KTag developers.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
* the terms of the GNU Affero General Public License as published by the Free
|
* the terms of the GNU Affero General Public License as published by the Free
|
||||||
|
|
@ -24,8 +24,10 @@
|
||||||
|
|
||||||
#include "SystemK.h"
|
#include "SystemK.h"
|
||||||
|
|
||||||
// #define DEBUG_PACKET_ENCODE
|
// Use these defines to enable detailed debug logging of packet encoding and decoding on the PSoC platform.
|
||||||
#define DEBUG_PACKET_DECODE
|
// Debug logging is always available on the ESP32 platform, and can be configured with the console.
|
||||||
|
//#define PSoC_DEBUG_PACKET_ENCODE
|
||||||
|
//#define PSoC_DEBUG_PACKET_DECODE
|
||||||
|
|
||||||
static const char *KLOG_TAG = "Protocols";
|
static const char *KLOG_TAG = "Protocols";
|
||||||
|
|
||||||
|
|
@ -220,10 +222,15 @@ TimedPulseTrain_T *PROTOCOLS_EncodePacket(TagPacket_T *packet)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PACKET_ENCODE
|
#if ((defined PSoC_DEBUG_PACKET_ENCODE) || (defined ESP_PLATFORM))
|
||||||
|
#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);
|
KLOG_DEBUG(KLOG_TAG, "\nEncoded %s packet (%u):", ProtocolNameAsString(packet->protocol), result->count);
|
||||||
PrintPulseTrainToConsole(result);
|
PrintPulseTrainToConsole(result);
|
||||||
#endif // DEBUG_PACKET_ENCODE
|
}
|
||||||
|
#endif // ((defined PSoC_DEBUG_PACKET_ENCODE) || (defined ESP_PLATFORM))
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -250,7 +257,7 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
{
|
{
|
||||||
// Many NEC remotes repeat packets when the button is held down.
|
// Many NEC remotes repeat packets when the button is held down.
|
||||||
// Too avoid double-counting, endure 500ms of silence between packets.
|
// Too avoid double-counting, ensure 500ms of silence between packets.
|
||||||
static TickType_t lastPacketTime = 0;
|
static TickType_t lastPacketTime = 0;
|
||||||
const TickType_t minimumInterval = pdMS_TO_TICKS(500);
|
const TickType_t minimumInterval = pdMS_TO_TICKS(500);
|
||||||
|
|
||||||
|
|
@ -328,11 +335,12 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
|
||||||
result = TEST_MaybeDecodePacket(packet);
|
result = TEST_MaybeDecodePacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PACKET_DECODE
|
#if ((defined PSoC_DEBUG_PACKET_DECODE) || (defined ESP_PLATFORM))
|
||||||
|
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
esp_log_level_set(KLOG_TAG, ESP_LOG_DEBUG);
|
if (esp_log_level_get(KLOG_TAG) >= ESP_LOG_DEBUG)
|
||||||
#endif // ESP_PLATFORM
|
#endif // ESP_PLATFORM
|
||||||
|
{
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -352,7 +360,8 @@ DecodedPacket_T *PROTOCOLS_MaybeDecodePacket(TimedPulseTrain_T *packet)
|
||||||
|
|
||||||
PrintPulseTrainToConsole(packet);
|
PrintPulseTrainToConsole(packet);
|
||||||
}
|
}
|
||||||
#endif // DEBUG_PACKET_DECODE
|
}
|
||||||
|
#endif // ((defined PSoC_DEBUG_PACKET_DECODE) || (defined ESP_PLATFORM))
|
||||||
|
|
||||||
// Remember which receiver saw the packet.
|
// Remember which receiver saw the packet.
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||||
*
|
*
|
||||||
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
|
* Copyright © 2016-2026 Joseph P. Kearney and the KTag developers.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
* the terms of the GNU Affero General Public License as published by the Free
|
* the terms of the GNU Affero General Public License as published by the Free
|
||||||
|
|
@ -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_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;
|
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_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;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@
|
||||||
#define SYSTEMK_H
|
#define SYSTEMK_H
|
||||||
|
|
||||||
#define SYSTEMK_MAJOR_VERSION 1
|
#define SYSTEMK_MAJOR_VERSION 1
|
||||||
#define SYSTEMK_MINOR_VERSION 0
|
#define SYSTEMK_MINOR_VERSION 1
|
||||||
#define SYSTEMK_VERSION_STRING "01.00"
|
#define SYSTEMK_VERSION_STRING "01.01"
|
||||||
|
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue