Skip to content

Commit a80b000

Browse files
Add structure for the SleepManager
1 parent 937321f commit a80b000

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed

examples/platform/silabs/SiWx917/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ source_set("siwx917-common") {
174174
}
175175
}
176176

177+
if (chip_enable_icd_server) {
178+
public_deps += [ "${silabs_common_plat_dir}/wifi/icd:sleep-manager" ]
179+
}
180+
177181
# DIC
178182
if (enable_dic) {
179183
public_deps +=
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
17+
config("sleep-manager-config") {
18+
include_dirs = [ "." ]
19+
defines = []
20+
}
21+
22+
source_set("sleep-manager") {
23+
sources = [
24+
"SiWxSleepManager.cpp",
25+
"SiWxSleepManager.h",
26+
]
27+
28+
public_deps = [
29+
"${chip_root}/src/app:app",
30+
"${chip_root}/src/app/icd/server:manager",
31+
"${chip_root}/src/app/icd/server:observer",
32+
"${chip_root}/src/lib/core",
33+
"${chip_root}/src/lib/support",
34+
]
35+
36+
public_configs = [ ":sleep-manager-config" ]
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "SleepManager.h"
18+
19+
using namespace chip::app;
20+
21+
namespace chip {
22+
namespace DeviceLayer {
23+
namespace Silabs {
24+
25+
// Initialize the static instance
26+
SleepManager SleepManager::mInstance;
27+
28+
CHIP_ERROR SleepManager::Init()
29+
{
30+
// Initialization logic
31+
return CHIP_NO_ERROR;
32+
}
33+
34+
void SleepManager::OnEnterActiveMode()
35+
{
36+
// Execution logic for entering active mode
37+
}
38+
39+
void SleepManager::OnEnterIdleMode()
40+
{
41+
// Execution logic for entering idle mode
42+
}
43+
44+
void SleepManager::OnSubscriptionEstablished(ReadHandler & aReadHandler)
45+
{
46+
// Implement logic for when a subscription is established
47+
}
48+
49+
void SleepManager::OnSubscriptionTerminated(ReadHandler & aReadHandler)
50+
{
51+
// Implement logic for when a subscription is terminated
52+
}
53+
54+
} // namespace Silabs
55+
} // namespace DeviceLayer
56+
} // namespace chip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
* or implied. See the License for the specific language governing permissions and limitations under the License.
13+
*/
14+
#pragma once
15+
16+
#include <app/ReadHandler.h>
17+
#include <app/icd/server/ICDManager.h>
18+
#include <app/icd/server/ICDStateObserver.h>
19+
#include <lib/core/CHIPError.h>
20+
21+
namespace chip {
22+
namespace DeviceLayer {
23+
namespace Silabs {
24+
25+
/**
26+
* @brief SleepManager is a singleton class that manages the sleep modes for Wi-Fi devices.
27+
* The class contains the buisness logic associated with optimizing the sleep states based on the Matter SDK internal states
28+
*
29+
* The class implements two disctint optimization states; one of SIT devices and one of LIT devices
30+
* For SIT ICDs, the logic is based on the Subscriptions established with the device.
31+
* For LIT ICDs, the logic is based on the ICDManager operating modes. The LIT mode also utilizes the SIT mode logic.
32+
*/
33+
class SleepManager : public chip::app::ICDStateObserver, public chip::app::ReadHandler::ApplicationCallback
34+
{
35+
public:
36+
SleepManager(const SleepManager &) = delete;
37+
SleepManager & operator=(const SleepManager &) = delete;
38+
39+
static SleepManager & GetInstance() { return mInstance; }
40+
41+
/**
42+
* @brief Init function that configure the SleepManager APIs based on the type of ICD
43+
* SIT ICD: Init function registers the ReadHandler Application callback to be notified when a subscription is
44+
* established or destroyed.
45+
*
46+
* LIT ICD: Init function registers with the ICDManager as an observer to be notified of the ICD mode changes.
47+
*
48+
* @return CHIP_ERROR
49+
*/
50+
CHIP_ERROR Init();
51+
52+
// ICDSateObserver implementation overrides
53+
54+
void OnEnterActiveMode() override;
55+
void OnEnterIdleMode() override;
56+
void OnTransitionToIdle() override { /* No execution logic */ }
57+
void OnICDModeChange() override { /* No execution logic */ }
58+
59+
// ReadHandler::ApplicationCallback implementation overrides
60+
61+
void OnSubscriptionEstablished(chip::app::ReadHandler & aReadHandler);
62+
void OnSubscriptionTerminated(chip::app::ReadHandler & aReadHandler);
63+
64+
private:
65+
SleepManager() = default;
66+
~SleepManager() = default;
67+
68+
static SleepManager mInstance;
69+
};
70+
71+
} // namespace Silabs
72+
} // namespace DeviceLayer
73+
} // namespace chip

0 commit comments

Comments
 (0)