-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SL-ONLY] Add structure for the SleepManager class (#105)
- Loading branch information
1 parent
b6cebf6
commit 2dccf95
Showing
4 changed files
with
143 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,37 @@ | ||
# 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. | ||
|
||
import("//build_overrides/chip.gni") | ||
|
||
config("sleep-manager-config") { | ||
include_dirs = [ "." ] | ||
defines = [] | ||
} | ||
|
||
source_set("sleep-manager") { | ||
sources = [ | ||
"SleepManager.cpp", | ||
"SleepManager.h", | ||
] | ||
|
||
public_deps = [ | ||
"${chip_root}/src/app:app", | ||
"${chip_root}/src/app/icd/server:manager", | ||
"${chip_root}/src/app/icd/server:observer", | ||
"${chip_root}/src/lib/core", | ||
"${chip_root}/src/lib/support", | ||
] | ||
|
||
public_configs = [ ":sleep-manager-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,40 @@ | ||
#include "SleepManager.h" | ||
|
||
using namespace chip::app; | ||
|
||
namespace chip { | ||
namespace DeviceLayer { | ||
namespace Silabs { | ||
|
||
// Initialize the static instance | ||
SleepManager SleepManager::mInstance; | ||
|
||
CHIP_ERROR SleepManager::Init() | ||
{ | ||
// Initialization logic | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
void SleepManager::OnEnterActiveMode() | ||
{ | ||
// Execution logic for entering active mode | ||
} | ||
|
||
void SleepManager::OnEnterIdleMode() | ||
{ | ||
// Execution logic for entering idle mode | ||
} | ||
|
||
void SleepManager::OnSubscriptionEstablished(ReadHandler & aReadHandler) | ||
{ | ||
// Implement logic for when a subscription is established | ||
} | ||
|
||
void SleepManager::OnSubscriptionTerminated(ReadHandler & aReadHandler) | ||
{ | ||
// Implement logic for when a subscription is terminated | ||
} | ||
|
||
} // namespace Silabs | ||
} // namespace DeviceLayer | ||
} // 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,61 @@ | ||
|
||
#pragma once | ||
|
||
#include <app/ReadHandler.h> | ||
#include <app/icd/server/ICDManager.h> | ||
#include <app/icd/server/ICDStateObserver.h> | ||
#include <lib/core/CHIPError.h> | ||
|
||
namespace chip { | ||
namespace DeviceLayer { | ||
namespace Silabs { | ||
|
||
/** | ||
* @brief SleepManager is a singleton class that manages the sleep modes for Wi-Fi devices. | ||
* The class contains the buisness logic associated with optimizing the sleep states based on the Matter SDK internal states | ||
* | ||
* The class implements two disctint optimization states; one of SIT devices and one of LIT devices | ||
* For SIT ICDs, the logic is based on the Subscriptions established with the device. | ||
* For LIT ICDs, the logic is based on the ICDManager operating modes. The LIT mode also utilizes the SIT mode logic. | ||
*/ | ||
class SleepManager : public chip::app::ICDStateObserver, public chip::app::ReadHandler::ApplicationCallback | ||
{ | ||
public: | ||
SleepManager(const SleepManager &) = delete; | ||
SleepManager & operator=(const SleepManager &) = delete; | ||
|
||
static SleepManager & GetInstance() { return mInstance; } | ||
|
||
/** | ||
* @brief Init function that configure the SleepManager APIs based on the type of ICD | ||
* SIT ICD: Init function registers the ReadHandler Application callback to be notified when a subscription is | ||
* established or destroyed. | ||
* | ||
* LIT ICD: Init function registers with the ICDManager as an observer to be notified of the ICD mode changes. | ||
* | ||
* @return CHIP_ERROR | ||
*/ | ||
CHIP_ERROR Init(); | ||
|
||
// ICDStateObserver implementation overrides | ||
|
||
void OnEnterActiveMode(); | ||
void OnEnterIdleMode(); | ||
void OnTransitionToIdle() { /* No execution logic */ } | ||
void OnICDModeChange() { /* No execution logic */ } | ||
|
||
// ReadHandler::ApplicationCallback implementation overrides | ||
|
||
void OnSubscriptionEstablished(chip::app::ReadHandler & aReadHandler); | ||
void OnSubscriptionTerminated(chip::app::ReadHandler & aReadHandler); | ||
|
||
private: | ||
SleepManager() = default; | ||
~SleepManager() = default; | ||
|
||
static SleepManager mInstance; | ||
}; | ||
|
||
} // namespace Silabs | ||
} // namespace DeviceLayer | ||
} // namespace chip |