Skip to content

Commit

Permalink
[Telink] Logs optimization (#24693)
Browse files Browse the repository at this point in the history
  • Loading branch information
s07641069 authored Jan 27, 2023
1 parent b838977 commit 3810f1a
Show file tree
Hide file tree
Showing 27 changed files with 89 additions and 32 deletions.
21 changes: 20 additions & 1 deletion config/telink/chip-module/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022 Project CHIP Authors
# Copyright (c) 2023 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,16 @@ rsource "../../zephyr/Kconfig"
config CHIP_DEVICE_VENDOR_NAME
default "Telink semiconductor"

config CHIP_APP_LOG_LEVEL
int "Logging level in application"
default LOG_DEFAULT_LEVEL
depends on LOG
help
Sets the logging level in the Matter application. Use this configuration
option only within the application. To set the logging level for the
Matter stack, use the MATTER_LOG_LEVEL configuration option.


# See config/zephyr/Kconfig for full definition
config CHIP_OTA_REQUESTOR
bool
Expand Down Expand Up @@ -130,3 +140,12 @@ endif #CHIP_FACTORY_DATA_BUILD
config CHIP_FACTORY_RESET_ERASE_NVS
bool
default y

config CHIP_LOG_SIZE_OPTIMIZATION
bool "Disable some detailed logs to decrease flash usage"
default y
help
Disables some log levels for specific Matter log modules that provide
information that is too detailed to be used in most cases. You can find
full configuration enabled by this option in the
platform/telink/CHIPPlatformConfig.h file.
2 changes: 1 addition & 1 deletion examples/all-clusters-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board
SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL);
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

namespace {
constexpr int kFactoryResetTriggerTimeout = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace ::chip;
using namespace ::chip::app::Clusters;
using namespace ::chip::app::Clusters::DoorLock;

LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

// Provided some empty callbacks and replaced feature map
// to simulate DoorLock endpoint for All-Clusters-App example
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-minimal-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board
SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL);
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

namespace {
constexpr int kFactoryResetTriggerTimeout = 2000;
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-minimal-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
2 changes: 1 addition & 1 deletion examples/contact-sensor-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <zephyr/logging/log.h>
#include <zephyr/zephyr.h>

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

ContactSensorManager ContactSensorManager::sContactSensor;

Expand Down
2 changes: 2 additions & 0 deletions examples/contact-sensor-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
using namespace chip;
using namespace chip::app::Clusters;

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
uint8_t * value)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/contact-sensor-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board
SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL);
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::app;
Expand Down
2 changes: 2 additions & 0 deletions examples/light-switch-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace chip::app::Clusters;

Expand Down
2 changes: 2 additions & 0 deletions examples/light-switch-app/telink/src/binding-handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "lib/shell/commands/Help.h"
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace chip::app;

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
14 changes: 7 additions & 7 deletions examples/lighting-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board
SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL);
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::app;
Expand Down Expand Up @@ -488,31 +488,31 @@ void AppTask::ActionInitiated(PWMDevice::Action_t aAction, int32_t aActor)
{
if (aAction == PWMDevice::ON_ACTION)
{
LOG_INF("ON_ACTION initiated");
LOG_DBG("ON_ACTION initiated");
}
else if (aAction == PWMDevice::OFF_ACTION)
{
LOG_INF("OFF_ACTION initiated");
LOG_DBG("OFF_ACTION initiated");
}
else if (aAction == PWMDevice::LEVEL_ACTION)
{
LOG_INF("LEVEL_ACTION initiated");
LOG_DBG("LEVEL_ACTION initiated");
}
}

void AppTask::ActionCompleted(PWMDevice::Action_t aAction, int32_t aActor)
{
if (aAction == PWMDevice::ON_ACTION)
{
LOG_INF("ON_ACTION completed");
LOG_DBG("ON_ACTION completed");
}
else if (aAction == PWMDevice::OFF_ACTION)
{
LOG_INF("OFF_ACTION completed");
LOG_DBG("OFF_ACTION completed");
}
else if (aAction == PWMDevice::LEVEL_ACTION)
{
LOG_INF("LEVEL_ACTION completed");
LOG_DBG("LEVEL_ACTION completed");
}

if (aActor == AppEvent::kEventType_Button)
Expand Down
14 changes: 8 additions & 6 deletions examples/lighting-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::OnOff;
Expand All @@ -40,15 +42,15 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &

if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "Cluster OnOff: attribute OnOff set to %u", *value);
ChipLogDetail(Zcl, "Cluster OnOff: attribute OnOff set to %u", *value);
GetAppTask().SetInitiateAction(*value ? PWMDevice::ON_ACTION : PWMDevice::OFF_ACTION,
static_cast<int32_t>(AppEvent::kEventType_Lighting), value);
}
else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::CurrentLevel::Id)
{
if (GetAppTask().GetPWMDevice().IsTurnedOn())
{
ChipLogProgress(Zcl, "Cluster LevelControl: attribute CurrentLevel set to %u", *value);
ChipLogDetail(Zcl, "Cluster LevelControl: attribute CurrentLevel set to %u", *value);
GetAppTask().SetInitiateAction(PWMDevice::LEVEL_ACTION, static_cast<int32_t>(AppEvent::kEventType_Lighting), value);
}
else
Expand Down Expand Up @@ -78,7 +80,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
xy.y = *reinterpret_cast<uint16_t *>(value);
}

ChipLogProgress(Zcl, "New XY color: %u|%u", xy.x, xy.y);
ChipLogDetail(Zcl, "New XY color: %u|%u", xy.x, xy.y);
GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_XY, static_cast<int32_t>(AppEvent::kEventType_Lighting),
(uint8_t *) &xy);
}
Expand All @@ -100,19 +102,19 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
{
hsv.s = *value;
}
ChipLogProgress(Zcl, "New HSV color: hue = %u| saturation = %u", hsv.h, hsv.s);
ChipLogDetail(Zcl, "New HSV color: hue = %u| saturation = %u", hsv.h, hsv.s);
GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_HSV, static_cast<int32_t>(AppEvent::kEventType_Lighting),
(uint8_t *) &hsv);
}
/* Temperature Mireds color space */
else if (attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id)
{
ChipLogProgress(Zcl, "New Temperature Mireds color = %u", *(uint16_t *) value);
ChipLogDetail(Zcl, "New Temperature Mireds color = %u", *(uint16_t *) value);
GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_CT, static_cast<int32_t>(AppEvent::kEventType_Lighting), value);
}
else
{
ChipLogProgress(Zcl, "Ignore ColorControl attribute (%u) that is not currently processed!", attributeId);
ChipLogDetail(Zcl, "Ignore ColorControl attribute (%u) that is not currently processed!", attributeId);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "Rpc.h"
#endif

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
2 changes: 1 addition & 1 deletion examples/ota-requestor-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board
SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL);
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

namespace {
constexpr int kFactoryResetTriggerTimeout = 2000;
Expand Down
2 changes: 2 additions & 0 deletions examples/ota-requestor-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace chip::app::Clusters;

Expand Down
2 changes: 1 addition & 1 deletion examples/ota-requestor-app/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/util/src/PWMDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool PWMDevice::InitiateAction(Action_t aAction, int32_t aActor, uint8_t * value

void PWMDevice::SetLevel(uint8_t aLevel)
{
LOG_INF("Setting brightness level to %u", aLevel);
LOG_DBG("Setting brightness level to %u", aLevel);
mLevel = aLevel;
UpdateLight();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board
SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL);
#endif // CONFIG_CHIP_LIB_SHELL

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::app;
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/telink/src/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "AppEvent.h"
#include "AppTask.h"

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace ::chip::DeviceLayer;
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/telink/src/TemperatureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "AppTask.h"
#include <zephyr/logging/log.h>

LOG_MODULE_DECLARE(app);
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace ::chip::DeviceLayer;
Expand Down
2 changes: 2 additions & 0 deletions examples/thermostat/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace chip;
using namespace chip::app::Clusters;

Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/telink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(app);
LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
26 changes: 26 additions & 0 deletions src/platform/telink/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,29 @@
#ifndef CHIP_CONFIG_MAX_FABRICS
#define CHIP_CONFIG_MAX_FABRICS 5
#endif

#if CONFIG_CHIP_LOG_SIZE_OPTIMIZATION
// Disable some of the too detailed log modules to save flash
#define CHIP_CONFIG_LOG_MODULE_ExchangeManager_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Crypto_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Crypto_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_BDX_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_BDX_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_EventLogging_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_EventLogging_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_SetupPayload_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_SetupPayload_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_CASESessionManager_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_CASESessionManager_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_DataManagement_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_FabricProvisioning_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_chipSystemLayer_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_chipSystemLayer_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_Zcl_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_SecureChannel_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Ble_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_AppServer_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Support_DETAIL 0
#define CHIP_CONFIG_LOG_MODULE_Support_PROGRESS 0
#define CHIP_CONFIG_LOG_MODULE_DeviceLayer_DETAIL 0
#endif

0 comments on commit 3810f1a

Please sign in to comment.