From 06f76b97f7ee52e0d6bc4700fe99e8d08b49436d Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:16:07 +0530 Subject: [PATCH 1/6] Added changes for the matter shell --- .../silabs/include/EventHandlerLibShell.h | 35 +++++ .../silabs/src/EventHandlerLibShell.cpp | 145 ++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 examples/refrigerator-app/silabs/include/EventHandlerLibShell.h create mode 100644 examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp diff --git a/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h b/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h new file mode 100644 index 0000000000..29239460e5 --- /dev/null +++ b/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2024 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +class EventData +{ +public: + chip::EventId eventId; +}; + +class RefrigeratorAlarmEventData : public EventData +{ +public: + AlarmBitmap alarmCode; +}; + + +CHIP_ERROR RegisterRefrigeratorAlarmEvents(); +void EventWorkerFunction(intptr_t context); diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp new file mode 100644 index 0000000000..c1a1e727d4 --- /dev/null +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -0,0 +1,145 @@ +/* + * + * Copyright (c) 2024 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "EventHandlerLibShell.h" +#include "AppTask.h" +#include "lib/shell/Engine.h" +#include "lib/shell/commands/Help.h" + +#include "app/server/Server.h" +#include "platform/CHIPDeviceLayer.h" +#include + +constexpr uint8_t kRefEndpointId = 1; + +using namespace chip; +using namespace chip::app; +using namespace Clusters::RefrigeratorAlarm; +using namespace Clusters::TemperatureControl; +using Shell::Engine; +using Shell::shell_command_t; +using Shell::streamer_get; +using Shell::streamer_printf; + +Engine sShellRefrigeratorSubCommands; +Engine sShellRefrigeratorEventSubCommands; +Engine sShellRefrigeratorEventAlarmDoorSubCommands; + +/******************************************************** + * Refrigerator shell functions + *********************************************************/ + +CHIP_ERROR RefrigeratorHelpHandler(int argc, char ** argv) +{ + sShellRefrigeratorSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); + return CHIP_NO_ERROR; +} + +CHIP_ERROR RefrigeratorCommandHandler(int argc, char ** argv) +{ + if (argc == 0) + { + return RefrigeratorHelpHandler(argc, argv); + } + + return sShellRefrigeratorSubCommands.ExecCommand(argc, argv); +} + +/******************************************************** + * Event shell functions + *********************************************************/ + +CHIP_ERROR EventHelpHandler(int argc, char ** argv) +{ + sShellRefrigeratorEventSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); + return CHIP_NO_ERROR; +} + +CHIP_ERROR EventRefrigeratorCommandHandler(int argc, char ** argv) +{ + if (argc == 0) + { + return EventHelpHandler(argc, argv); + } + + return sShellRefrigeratorEventSubCommands.ExecCommand(argc, argv); +} + +/******************************************************** + * Alarm shell functions + *********************************************************/ + +CHIP_ERROR AlarmHelpHandler(int argc, char ** argv) +{ + sShellRefrigeratorEventAlarmDoorSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); + return CHIP_NO_ERROR; +} + +CHIP_ERROR RefrigeratorDoorEventHandler(int argc, char ** argv) +{ + + if (argc == 0) + { + return AlarmHelpHandler(argc, argv); + } + if (argc >= 2) + { + ChipLogError(Zcl, "Too many arguments provided to function %s, line %d", __func__, __LINE__); + return APP_ERROR_TOO_MANY_SHELL_ARGUMENTS; + } + + RefrigeratorAlarmEventData * data = Platform::New(); + data->eventId = Events::Notify::Id; + data->alarmCode = static_cast(atoi(argv[0])); + + DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); + + return CHIP_NO_ERROR; +} + + +/** + * @brief configures Refrigerator matter shell + * + */ + +CHIP_ERROR RegisterRefrigeratorEvents() +{ + static const shell_command_t sRefrigeratorSubCommands[] = { { &RefrigeratorHelpHandler, "help", "Usage: refrigeratoralarm " }, + { &EventRefrigeratorCommandHandler, "event", + " Usage: refrigeratoralarm event " } }; + + static const shell_command_t sRefrigeratorEventSubCommands[] = { + { &EventHelpHandler, "help", "Usage : refrigeratoralarm event " }, + { &RefrigeratorDoorEventHandler, "door-state-change", "Sends door state change event to Refrigerator app" } + }; + + static const shell_command_t sRefrigeratorEventAlarmDoorSubCommands[] = { { &AlarmHelpHandler, "help", + "Usage : Refrigerator event to change door state" } }; + + static const shell_command_t sRefrigeratorCommand = { &RefrigeratorCommandHandler, "doorlock", + "doorlock commands. Usage: doorlock " }; + + sShellRefrigeratorEventAlarmDoorSubCommands.RegisterCommands(sRefrigeratorEventAlarmDoorSubCommands, ArraySize(sRefrigeratorEventAlarmDoorSubCommands)); + + sShellRefrigeratorEventSubCommands.RegisterCommands(sRefrigeratorEventSubCommands, ArraySize(sRefrigeratorEventSubCommands)); + sShellRefrigeratorSubCommands.RegisterCommands(sRefrigeratorSubCommands, ArraySize(sRefrigeratorSubCommands)); + + Engine::Root().RegisterCommands(&sRefrigeratorCommand, 1); + + return CHIP_NO_ERROR; +} \ No newline at end of file From f5e812e18483161530254ff73cc5795823a090a5 Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Tue, 19 Nov 2024 12:09:56 +0530 Subject: [PATCH 2/6] Added support for the matter shell refrigerator door state --- examples/refrigerator-app/silabs/BUILD.gn | 4 +++ .../refrigerator-app/silabs/include/AppTask.h | 1 + .../silabs/include/EventHandlerLibShell.h | 7 +++-- .../refrigerator-app/silabs/src/AppTask.cpp | 16 +++++++++- .../silabs/src/EventHandlerLibShell.cpp | 29 +++++++++++++++++-- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/examples/refrigerator-app/silabs/BUILD.gn b/examples/refrigerator-app/silabs/BUILD.gn index 9e63c6c10e..27c59f70a8 100644 --- a/examples/refrigerator-app/silabs/BUILD.gn +++ b/examples/refrigerator-app/silabs/BUILD.gn @@ -143,6 +143,10 @@ silabs_executable("refrigerator_app") { "src/refrigerator-and-temperature-controlled-cabinet-mode.cpp", ] + if (chip_build_libshell) { + sources += [ "src/EventHandlerLibShell.cpp" ] + } + if (use_temp_sensor) { sources += [ "${efr32_sdk_root}/hardware/driver/si70xx/src/sl_si70xx.c", diff --git a/examples/refrigerator-app/silabs/include/AppTask.h b/examples/refrigerator-app/silabs/include/AppTask.h index 36c4581b29..3f7b406b35 100644 --- a/examples/refrigerator-app/silabs/include/AppTask.h +++ b/examples/refrigerator-app/silabs/include/AppTask.h @@ -48,6 +48,7 @@ #define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) #define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) #define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) +#define APP_ERROR_TOO_MANY_SHELL_ARGUMENTS CHIP_APPLICATION_ERROR(0x08) /********************************************************** * AppTask Declaration diff --git a/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h b/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h index 29239460e5..618818a253 100644 --- a/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h +++ b/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h @@ -17,6 +17,9 @@ #pragma once #include +#include +#include + class EventData { @@ -27,9 +30,9 @@ class EventData class RefrigeratorAlarmEventData : public EventData { public: - AlarmBitmap alarmCode; + chip::app::Clusters::RefrigeratorAlarm::AlarmBitmap doorState; }; -CHIP_ERROR RegisterRefrigeratorAlarmEvents(); +CHIP_ERROR RegisterRefrigeratorEvents(); void EventWorkerFunction(intptr_t context); diff --git a/examples/refrigerator-app/silabs/src/AppTask.cpp b/examples/refrigerator-app/silabs/src/AppTask.cpp index d2def279be..904514cb29 100644 --- a/examples/refrigerator-app/silabs/src/AppTask.cpp +++ b/examples/refrigerator-app/silabs/src/AppTask.cpp @@ -24,7 +24,6 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" - #include "LEDWidget.h" #ifdef DISPLAY_ENABLED @@ -35,6 +34,10 @@ #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED +#if defined(ENABLE_CHIP_SHELL) +#include "EventHandlerLibShell.h" +#endif // ENABLE_CHIP_SHELL + #include #include #include @@ -94,6 +97,15 @@ CHIP_ERROR AppTask::Init() appError(err); } +#if defined(ENABLE_CHIP_SHELL) + err = RegisterRefrigeratorEvents(); + if (err != CHIP_NO_ERROR) + { + SILABS_LOG("RegisterRefrigeratorEvents() failed"); + appError(err); + } +#endif // ENABLE_CHIP_SHELL + return err; } @@ -102,6 +114,8 @@ CHIP_ERROR AppTask::StartAppTask() return BaseApplication::StartAppTask(AppTaskMain); } + + void AppTask::AppTaskMain(void * pvParameter) { AppEvent event; diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp index c1a1e727d4..a8fb4c6f0b 100644 --- a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -104,8 +104,9 @@ CHIP_ERROR RefrigeratorDoorEventHandler(int argc, char ** argv) RefrigeratorAlarmEventData * data = Platform::New(); data->eventId = Events::Notify::Id; - data->alarmCode = static_cast(atoi(argv[0])); + data->doorState = static_cast(atoi(argv[0])); + ChipLogProgress(Zcl, "Setting event for the door state %d", data->doorState); DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); return CHIP_NO_ERROR; @@ -131,8 +132,8 @@ CHIP_ERROR RegisterRefrigeratorEvents() static const shell_command_t sRefrigeratorEventAlarmDoorSubCommands[] = { { &AlarmHelpHandler, "help", "Usage : Refrigerator event to change door state" } }; - static const shell_command_t sRefrigeratorCommand = { &RefrigeratorCommandHandler, "doorlock", - "doorlock commands. Usage: doorlock " }; + static const shell_command_t sRefrigeratorCommand = { &RefrigeratorCommandHandler, "refrigeratoralarm", + "refrigerator alarm commands. Usage: refrigeratoralarm " }; sShellRefrigeratorEventAlarmDoorSubCommands.RegisterCommands(sRefrigeratorEventAlarmDoorSubCommands, ArraySize(sRefrigeratorEventAlarmDoorSubCommands)); @@ -142,4 +143,26 @@ CHIP_ERROR RegisterRefrigeratorEvents() Engine::Root().RegisterCommands(&sRefrigeratorCommand, 1); return CHIP_NO_ERROR; +} + +void EventWorkerFunction(intptr_t context) +{ + VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "EventWorkerFunction - Invalid work data")); + + EventData * data = reinterpret_cast(context); + + switch (data->eventId) + { + case Events::Notify::Id: { + RefrigeratorAlarmEventData * alarmData = reinterpret_cast(context); + ChipLogProgress(Zcl, "Changing the door state %d", alarmData->doorState); + RefrigeratorAlarmServer::Instance().SetStateValue(kRefEndpointId,alarmData->doorState); + break; + } + + default: { + ChipLogError(Zcl, "Invalid Event Id %s, line %d", __func__, __LINE__); + break; + } + } } \ No newline at end of file From c50da80a21607a0a16cc55ed6ce29c836580ebb0 Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:10:40 +0530 Subject: [PATCH 3/6] Added changes for the failure --- examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp index a8fb4c6f0b..06547845ce 100644 --- a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -106,13 +106,11 @@ CHIP_ERROR RefrigeratorDoorEventHandler(int argc, char ** argv) data->eventId = Events::Notify::Id; data->doorState = static_cast(atoi(argv[0])); - ChipLogProgress(Zcl, "Setting event for the door state %d", data->doorState); DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); return CHIP_NO_ERROR; } - /** * @brief configures Refrigerator matter shell * @@ -155,7 +153,6 @@ void EventWorkerFunction(intptr_t context) { case Events::Notify::Id: { RefrigeratorAlarmEventData * alarmData = reinterpret_cast(context); - ChipLogProgress(Zcl, "Changing the door state %d", alarmData->doorState); RefrigeratorAlarmServer::Instance().SetStateValue(kRefEndpointId,alarmData->doorState); break; } From 54833f1e60a5a9605bb8995e7080c6101e200e2a Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:15:18 +0530 Subject: [PATCH 4/6] Adds required comment changes --- .../silabs/src/EventHandlerLibShell.cpp | 4 +- .../refrigerator-app/silabs/include/AppTask.h | 1 - .../silabs/include/EventHandlerLibShell.h | 4 +- .../silabs/src/EventHandlerLibShell.cpp | 45 ++++++++++++------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/examples/lock-app/silabs/src/EventHandlerLibShell.cpp b/examples/lock-app/silabs/src/EventHandlerLibShell.cpp index ef79290bd1..d9b9244fc6 100644 --- a/examples/lock-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/lock-app/silabs/src/EventHandlerLibShell.cpp @@ -99,7 +99,7 @@ CHIP_ERROR AlarmEventHandler(int argc, char ** argv) if (argc >= 2) { ChipLogError(Zcl, "Too many arguments provided to function %s, line %d", __func__, __LINE__); - return APP_ERROR_TOO_MANY_SHELL_ARGUMENTS; + return CHIP_ERROR_INVALID_ARGUMENT; } AlarmEventData * data = Platform::New(); @@ -131,7 +131,7 @@ CHIP_ERROR DoorStateEventHandler(int argc, char ** argv) if (argc >= 2) { ChipLogError(Zcl, "Too many arguments provided to function %s, line %d", __func__, __LINE__); - return APP_ERROR_TOO_MANY_SHELL_ARGUMENTS; + return CHIP_ERROR_INVALID_ARGUMENT; } DoorStateEventData * data = Platform::New(); diff --git a/examples/refrigerator-app/silabs/include/AppTask.h b/examples/refrigerator-app/silabs/include/AppTask.h index 3f7b406b35..36c4581b29 100644 --- a/examples/refrigerator-app/silabs/include/AppTask.h +++ b/examples/refrigerator-app/silabs/include/AppTask.h @@ -48,7 +48,6 @@ #define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) #define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) #define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) -#define APP_ERROR_TOO_MANY_SHELL_ARGUMENTS CHIP_APPLICATION_ERROR(0x08) /********************************************************** * AppTask Declaration diff --git a/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h b/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h index 618818a253..5997b24d5b 100644 --- a/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h +++ b/examples/refrigerator-app/silabs/include/EventHandlerLibShell.h @@ -16,10 +16,9 @@ */ #pragma once +#include #include #include -#include - class EventData { @@ -33,6 +32,5 @@ class RefrigeratorAlarmEventData : public EventData chip::app::Clusters::RefrigeratorAlarm::AlarmBitmap doorState; }; - CHIP_ERROR RegisterRefrigeratorEvents(); void EventWorkerFunction(intptr_t context); diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp index 06547845ce..ee41a8b001 100644 --- a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -98,13 +98,23 @@ CHIP_ERROR RefrigeratorDoorEventHandler(int argc, char ** argv) } if (argc >= 2) { - ChipLogError(Zcl, "Too many arguments provided to function %s, line %d", __func__, __LINE__); - return APP_ERROR_TOO_MANY_SHELL_ARGUMENTS; + ChipLogError(Shell, "Too many arguments"); + return CHIP_ERROR_INVALID_ARGUMENT; } + // Check if the argument is a valid integer + if (argv[0] == nullptr || !std::all_of(argv[0], argv[0] + strlen(argv[0]), ::isdigit)) + { + ChipLogError(Shell, "Invalid argument: Input must be a valid integer."); + return CHIP_ERROR_INVALID_ARGUMENT; + } + + // Convert the argument to an integer + int value = std::stoi(argv[0]); // Safe to use now, as we validated the input earlier + RefrigeratorAlarmEventData * data = Platform::New(); - data->eventId = Events::Notify::Id; - data->doorState = static_cast(atoi(argv[0])); + data->eventId = Events::Notify::Id; + data->doorState = static_cast(atoi(argv[0])); DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); @@ -118,23 +128,25 @@ CHIP_ERROR RefrigeratorDoorEventHandler(int argc, char ** argv) CHIP_ERROR RegisterRefrigeratorEvents() { - static const shell_command_t sRefrigeratorSubCommands[] = { { &RefrigeratorHelpHandler, "help", "Usage: refrigeratoralarm " }, - { &EventRefrigeratorCommandHandler, "event", - " Usage: refrigeratoralarm event " } }; + static const shell_command_t sRefrigeratorSubCommands[] = { + { &RefrigeratorHelpHandler, "help", "Usage: refrigeratoralarm " }, + { &EventRefrigeratorCommandHandler, "event", " Usage: refrigeratoralarm event " } + }; static const shell_command_t sRefrigeratorEventSubCommands[] = { { &EventHelpHandler, "help", "Usage : refrigeratoralarm event " }, { &RefrigeratorDoorEventHandler, "door-state-change", "Sends door state change event to Refrigerator app" } }; - static const shell_command_t sRefrigeratorEventAlarmDoorSubCommands[] = { { &AlarmHelpHandler, "help", - "Usage : Refrigerator event to change door state" } }; + static const shell_command_t sRefrigeratorEventAlarmDoorSubCommands[] = { + { &AlarmHelpHandler, "help", "Usage : Refrigerator event to change door state" } + }; static const shell_command_t sRefrigeratorCommand = { &RefrigeratorCommandHandler, "refrigeratoralarm", - "refrigerator alarm commands. Usage: refrigeratoralarm " }; - - sShellRefrigeratorEventAlarmDoorSubCommands.RegisterCommands(sRefrigeratorEventAlarmDoorSubCommands, ArraySize(sRefrigeratorEventAlarmDoorSubCommands)); + "refrigerator alarm commands. Usage: refrigeratoralarm " }; + sShellRefrigeratorEventAlarmDoorSubCommands.RegisterCommands(sRefrigeratorEventAlarmDoorSubCommands, + ArraySize(sRefrigeratorEventAlarmDoorSubCommands)); sShellRefrigeratorEventSubCommands.RegisterCommands(sRefrigeratorEventSubCommands, ArraySize(sRefrigeratorEventSubCommands)); sShellRefrigeratorSubCommands.RegisterCommands(sRefrigeratorSubCommands, ArraySize(sRefrigeratorSubCommands)); @@ -145,15 +157,14 @@ CHIP_ERROR RegisterRefrigeratorEvents() void EventWorkerFunction(intptr_t context) { - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "EventWorkerFunction - Invalid work data")); - + VerifyOrReturn(reinterpret_cast(context) != nullptr, ChipLogError(Shell, "EventWorkerFunction - Invalid work data")); EventData * data = reinterpret_cast(context); switch (data->eventId) { case Events::Notify::Id: { RefrigeratorAlarmEventData * alarmData = reinterpret_cast(context); - RefrigeratorAlarmServer::Instance().SetStateValue(kRefEndpointId,alarmData->doorState); + RefrigeratorAlarmServer::Instance().SetStateValue(kRefEndpointId, alarmData->doorState); break; } @@ -161,5 +172,7 @@ void EventWorkerFunction(intptr_t context) ChipLogError(Zcl, "Invalid Event Id %s, line %d", __func__, __LINE__); break; } + // Free memory + Platform::Delete(data); } -} \ No newline at end of file +} From 69fdcc04434b74b67183be42ae70cdd4ef19f825 Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:20:44 +0530 Subject: [PATCH 5/6] Added restyler changes --- examples/refrigerator-app/silabs/src/AppTask.cpp | 2 -- .../refrigerator-app/silabs/src/EventHandlerLibShell.cpp | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/refrigerator-app/silabs/src/AppTask.cpp b/examples/refrigerator-app/silabs/src/AppTask.cpp index 904514cb29..c9dc451b71 100644 --- a/examples/refrigerator-app/silabs/src/AppTask.cpp +++ b/examples/refrigerator-app/silabs/src/AppTask.cpp @@ -114,8 +114,6 @@ CHIP_ERROR AppTask::StartAppTask() return BaseApplication::StartAppTask(AppTaskMain); } - - void AppTask::AppTaskMain(void * pvParameter) { AppEvent event; diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp index ee41a8b001..f923d5ec90 100644 --- a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -157,7 +157,7 @@ CHIP_ERROR RegisterRefrigeratorEvents() void EventWorkerFunction(intptr_t context) { - VerifyOrReturn(reinterpret_cast(context) != nullptr, ChipLogError(Shell, "EventWorkerFunction - Invalid work data")); + VerifyOrReturn(reinterpret_cast(context) != nullptr, ChipLogError(Shell, "EventWorkerFunction - Invalid work data")); EventData * data = reinterpret_cast(context); switch (data->eventId) @@ -172,7 +172,7 @@ void EventWorkerFunction(intptr_t context) ChipLogError(Zcl, "Invalid Event Id %s, line %d", __func__, __LINE__); break; } - // Free memory - Platform::Delete(data); + // Free memory + Platform::Delete(data); } } From 19cf6c5a27233fe378c83f0f5d3a9ef97a156bc1 Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Fri, 22 Nov 2024 23:19:09 +0530 Subject: [PATCH 6/6] Adds changes according to comment --- .../refrigerator-app/silabs/src/EventHandlerLibShell.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp index f923d5ec90..212b2ac8d8 100644 --- a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -114,7 +114,7 @@ CHIP_ERROR RefrigeratorDoorEventHandler(int argc, char ** argv) RefrigeratorAlarmEventData * data = Platform::New(); data->eventId = Events::Notify::Id; - data->doorState = static_cast(atoi(argv[0])); + data->doorState = static_cast(value); DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); @@ -172,7 +172,7 @@ void EventWorkerFunction(intptr_t context) ChipLogError(Zcl, "Invalid Event Id %s, line %d", __func__, __LINE__); break; } - // Free memory - Platform::Delete(data); } + // Free memory + Platform::Delete(data); }