Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ICD] Creation of ICDManager classes #26523

Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
60119a6
Creation of ICDManager
mkardous-silabs May 11, 2023
ab3ee5d
restyle
mkardous-silabs May 11, 2023
7569a7f
refactor object management
mkardous-silabs May 12, 2023
02a8539
add shutdown
mkardous-silabs May 12, 2023
d29bd69
restyle
mkardous-silabs May 12, 2023
41f986b
Add event callback
mkardous-silabs May 12, 2023
7e717fe
restyle
mkardous-silabs May 12, 2023
3c2e63e
make the changes in the wifi file
mkardous-silabs May 12, 2023
8d9a6ca
fix typos
mkardous-silabs May 12, 2023
ab28af0
address review comments
mkardous-silabs May 12, 2023
7097932
restyle
mkardous-silabs May 12, 2023
af3b403
add missing define
mkardous-silabs May 12, 2023
64faf94
move files
mkardous-silabs Jun 1, 2023
5eeddcc
Remove handler in shutdown
mkardous-silabs Jun 1, 2023
23f2e2e
refactor ICD Manager structure
mkardous-silabs Jun 1, 2023
9746c7b
restyle
mkardous-silabs Jun 1, 2023
79400b4
remove line
mkardous-silabs Jun 2, 2023
bb48d94
fix ifdef
mkardous-silabs Jun 2, 2023
47297b5
address comments on comments
mkardous-silabs Jun 2, 2023
36ec0b2
refactor gn files
mkardous-silabs Jun 2, 2023
2bb8208
restyle
mkardous-silabs Jun 2, 2023
b9c554d
address comments
mkardous-silabs Jun 2, 2023
46f740a
Apply suggestions from code review
mkardous-silabs Jun 2, 2023
45ea6a3
Address first wave of comments
mkardous-silabs Jun 2, 2023
439ad57
Address second wave of comments
mkardous-silabs Jun 2, 2023
fbeb297
fix typo
mkardous-silabs Jun 2, 2023
fc49437
clean defines
mkardous-silabs Jun 2, 2023
9e43929
rename define
mkardous-silabs Jun 2, 2023
569e560
fix gn check error
mkardous-silabs Jun 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("${chip_root}/src/platform/device.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("common_flags.gni")
import("icd/icd.gni")
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved

declare_args() {
# Enable strict schema checks.
Expand Down Expand Up @@ -55,6 +56,7 @@ buildconfig_header("app_buildconfig") {
"CHIP_CONFIG_ACCESS_CONTROL_POLICY_LOGGING_VERBOSITY=${chip_access_control_policy_logging_verbosity}",
"CHIP_CONFIG_PERSIST_SUBSCRIPTIONS=${chip_persist_subscriptions}",
"CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE=${enable_eventlist_attribute}",
"CHIP_CONFIG_ICD_SERVER_ENABLE=${chip_enable_icd_server}",
]
}

Expand Down Expand Up @@ -192,6 +194,15 @@ static_library("app") {
"reporting/reporting.h",
]

if (chip_enable_icd_server) {
sources += [
"icd/ICDEventManager.cpp",
"icd/ICDEventManager.h",
"icd/ICDManager.cpp",
"icd/ICDManager.h",
]
}

if (chip_persist_subscriptions) {
sources += [
"SimpleSubscriptionResumptionStorage.cpp",
Expand Down
61 changes: 61 additions & 0 deletions src/app/icd/ICDEventManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
*
* 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.
* 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 <app/icd/ICDEventManager.h>

using namespace chip::DeviceLayer;

namespace chip {
namespace app {

/**
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
* @brief Initialisation function of the ICDEventManager.
* Init function MUST be called before using the object
*
* @param icdManager pointer to the ICDManager object
* @return CHIP_ERROR
*/
CHIP_ERROR ICDEventManager::Init(ICDManager * icdManager)
{
VerifyOrReturnError(icdManager != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
mICDManager = icdManager;

PlatformMgr().AddEventHandler(ICDEventHandler, reinterpret_cast<intptr_t>(nullptr));

return CHIP_NO_ERROR;
}

CHIP_ERROR ICDEventManager::Shutdown()
{
PlatformMgr().RemoveEventHandler(ICDEventHandler, reinterpret_cast<intptr_t>(nullptr));
return CHIP_NO_ERROR;
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @brief Event Handler callback given to the PlatformManager
* Function dispatchs the event to the ICDManager member
*
* @param event
* @param arg
*/
void ICDEventManager::ICDEventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
// TODO
}

} // namespace app
} // namespace chip
46 changes: 46 additions & 0 deletions src/app/icd/ICDEventManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* 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.
* 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 <platform/internal/CHIPDeviceLayerInternal.h>

#include <app/icd/ICDEventManager.h>
#include <app/icd/ICDManager.h>
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceEvent.h>

namespace chip {
namespace app {

/**
* @brief ICDEventManager class is responsible of processing Platform Events that affect an ICDs behaviour
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
* The class registers an Event Handler with the Platform Manager and dispatchs the processing to the ICDManager class.
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
*/
class ICDEventManager
{

public:
ICDEventManager() = default;
CHIP_ERROR Init(ICDManager * icdManager);
CHIP_ERROR Shutdown();
static void ICDEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved

private:
ICDManager * mICDManager;
};

} // namespace app
} // namespace chip
26 changes: 26 additions & 0 deletions src/app/icd/ICDManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
*
* 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.
* 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 <app/icd/ICDManager.h>

namespace chip {
namespace app {

ICDManager::ICDManager() {}

} // namespace app
} // namespace chip
35 changes: 35 additions & 0 deletions src/app/icd/ICDManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
*
* 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.
* 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

namespace chip {
namespace app {

/**
* @brief ICD Manager is responsible of processing the events and triggering the correct action for an ICD
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
*
*/
class ICDManager
{
public:
ICDManager();

private:
};

} // namespace app
} // namespace chip
23 changes: 23 additions & 0 deletions src/app/icd/icd.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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.
# 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.

declare_args() {
# Matter SDK Configuration flag to enable ICD server functionalities
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
# TODO - Add Specifics when the design is refined
chip_enable_icd_server = false

# Matter SDK Configuration flag to enable ICD client functionalities
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
# TODO - Add Specifics when the design is refined
chip_enable_icd_client = false
}
7 changes: 7 additions & 0 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
}
#endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT

#if CHIP_CONFIG_ENABLE_ICD_SERVER
mICDEventManager.Init(&mICDManager);
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

// This initializes clusters, so should come after lower level initialization.
InitDataModelHandler();

Expand Down Expand Up @@ -484,6 +488,9 @@ void Server::Shutdown()
mAccessControl.Finish();
Access::ResetAccessControlToDefault();
Credentials::SetGroupDataProvider(nullptr);
#if CHIP_CONFIG_ENABLE_ICD_SERVER
mICDEventManager.Shutdown();
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
mAttributePersister.Shutdown();
// TODO(16969): Remove chip::Platform::MemoryInit() call from Server class, it belongs to outer code
chip::Platform::MemoryShutdown();
Expand Down
9 changes: 9 additions & 0 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
#endif
#include <transport/raw/UDP.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/ICDEventManager.h>
#include <app/ICDManager.h>
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

namespace chip {

constexpr size_t kMaxBlePendingPackets = 1;
Expand Down Expand Up @@ -595,6 +600,10 @@ class Server
Inet::InterfaceId mInterfaceId;

System::Clock::Microseconds64 mInitTimestamp;
#if CHIP_CONFIG_ENABLE_ICD_SERVER
DeviceLayer::ICDEventManager mICDEventManager;
DeviceLayer::ICDManager mICDManager;
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
};

} // namespace chip
11 changes: 11 additions & 0 deletions src/app/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ source_set("binding-test-srcs") {
]
}

source_set("icd-manager-srcs") {
sources = [
"${chip_root}/src/app/icd/ICDManager.cpp",
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
"${chip_root}/src/app/icd/ICDManager.h",
]

public_deps = [ "${chip_root}/src/lib/core" ]
}

# source_set("client-monitoring-test-srcs") {
# sources = [
# "${chip_root}/src/app/util/ClientMonitoringRegistrationTable.cpp",
Expand Down Expand Up @@ -121,6 +130,7 @@ chip_test_suite("tests") {
"TestEventPathParams.cpp",
"TestExtensionFieldSets.cpp",
"TestFabricScopedEventLogging.cpp",
"TestICDManager.cpp",
"TestInteractionModelEngine.cpp",
"TestMessageDef.cpp",
"TestNumericAttributeTraits.cpp",
Expand Down Expand Up @@ -166,6 +176,7 @@ chip_test_suite("tests") {
# Disable CM cluster table tests until update is done
#https://github.com/project-chip/connectedhomeip/issues/24425
# ":client-monitoring-test-srcs",
":icd-manager-srcs",
":ota-requestor-test-srcs",
":scenes-table-test-srcs",
"${chip_root}/src/app",
Expand Down
38 changes: 38 additions & 0 deletions src/app/tests/TestICDManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* 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.
*/

/**
* @file
* This file implements tests for the ICDManager class
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
*
*/

#include <lib/support/UnitTestRegistration.h>
#include <nlunit-test.h>

int TestICDManager()
{
static nlTest sTests[] = { NL_TEST_SENTINEL() };

nlTestSuite cmSuite = { "TestICDManager", &sTests[0], nullptr, nullptr };

nlTestRunner(&cmSuite, nullptr);
return (nlTestRunnerStats(&cmSuite));
}

CHIP_REGISTER_TEST_SUITE(TestICDManager)