-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ICD] Creation of ICDManager classes (#26523)
* Creation of ICDManager * restyle * refactor object management * add shutdown * restyle * Add event callback * restyle * make the changes in the wifi file * fix typos add missing define * address review comments * restyle * add missing define * move files * Remove handler in shutdown * refactor ICD Manager structure * restyle * remove line * fix ifdef * address comments on comments * refactor gn files * restyle * address comments
- Loading branch information
1 parent
fb94dd3
commit 001a6b5
Showing
11 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) 2020 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. | ||
|
||
import("//build_overrides/chip.gni") | ||
import("icd.gni") | ||
|
||
# ICD Server sources and configurations | ||
|
||
# ICD Manager source-set is broken out of the main source-set to enable unit tests | ||
# All sources and configurations used by the ICDManager need to go in this source-set | ||
source_set("manager-srcs") { | ||
sources = [ | ||
"ICDManager.cpp", | ||
"ICDManager.h", | ||
] | ||
|
||
public_deps = [ "${chip_root}/src/lib/core" ] | ||
} | ||
|
||
# ICD Server Configuration | ||
# All configurations necessary to the ICD Server featureset need to in this configuration | ||
config("server-config") { | ||
defines = [ "CHIP_CONFIG_ENABLE_ICD_SERVER" ] | ||
} | ||
|
||
# servers-srcs source-set contains all the sources and configurations necessary to build the ICD Server functionality | ||
# All sources, configurations and dependencies necessary for the ICD Server featureset need to go in this source-set | ||
# | ||
# The ICD Server featureset is enabled with the chip_enable_icd_server in the src/app/BUILD.gn file | ||
source_set("server-srcs") { | ||
sources = [ | ||
"ICDEventManager.cpp", | ||
"ICDEventManager.h", | ||
] | ||
|
||
public_deps = [ | ||
":manager-srcs", | ||
"${chip_root}/src/platform:platform", | ||
] | ||
|
||
public_configs = [ ":server-config" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* 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 { | ||
|
||
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)); | ||
mICDManager = nullptr; | ||
|
||
return CHIP_NO_ERROR; | ||
} | ||
|
||
void ICDEventManager::ICDEventHandler(const ChipDeviceEvent * event, intptr_t arg) | ||
{ | ||
// TODO | ||
} | ||
|
||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* | ||
* 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/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 ICD's behaviour | ||
* The class registers an Event Handler with the Platform Manager and dispatches the processing to the ICDManager class. | ||
*/ | ||
class ICDEventManager | ||
{ | ||
|
||
public: | ||
ICDEventManager() = default; | ||
|
||
/** | ||
* @brief Initialisation function of the ICDEventManager. | ||
* Init function MUST be called before using the object | ||
*/ | ||
CHIP_ERROR Init(ICDManager * icdManager); | ||
CHIP_ERROR Shutdown(); | ||
|
||
private: | ||
/** | ||
* @brief Event Handler callback given to the PlatformManager | ||
* Function dispatchs the event to the ICDManager member | ||
*/ | ||
static void ICDEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); | ||
|
||
ICDManager * mICDManager; | ||
}; | ||
|
||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* | ||
* 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 | ||
*/ | ||
class ICDManager | ||
{ | ||
public: | ||
ICDManager(); | ||
|
||
private: | ||
}; | ||
|
||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 functionality | ||
# TODO - Add Specifics when the design is refined | ||
chip_enable_icd_server = false | ||
|
||
# Matter SDK Configuration flag to enable ICD client functionality | ||
# TODO - Add Specifics when the design is refined | ||
chip_enable_icd_client = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* | ||
* 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. | ||
*/ | ||
#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) |