-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fabric-Sync] Support icd-registration during device sync (#36569)
- Loading branch information
1 parent
c197bc2
commit f4b8064
Showing
10 changed files
with
507 additions
and
5 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
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,51 @@ | ||
/* | ||
* Copyright (c) 2024 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 "IcdManager.h" | ||
|
||
namespace admin { | ||
|
||
IcdManager IcdManager::sInstance; | ||
|
||
IcdManager & IcdManager::Instance() | ||
{ | ||
return sInstance; | ||
} | ||
|
||
void IcdManager::OnCheckInComplete(const chip::app::ICDClientInfo & clientInfo) | ||
{ | ||
DefaultCheckInDelegate::OnCheckInComplete(clientInfo); | ||
if (mDelegate) | ||
{ | ||
mDelegate->OnCheckInCompleted(clientInfo); | ||
} | ||
} | ||
|
||
void IcdManager::SetDelegate(Delegate * delegate) | ||
{ | ||
// To keep IcdManager simple, there is an assumption that there is only ever | ||
// one delegate set and it's lifetime is identical to IcdManager. In the | ||
// future this assumption can change should there be a need, but that will | ||
// require code changes to IcdManager. For now we will crash if someone tries | ||
// to call SetDelegate for a second time or if delegate is non-null. | ||
VerifyOrDie(delegate); | ||
VerifyOrDie(!mDelegate); | ||
mDelegate = delegate; | ||
} | ||
|
||
} // namespace admin |
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) 2024 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. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/icd/client/DefaultCheckInDelegate.h> | ||
|
||
namespace admin { | ||
|
||
/** | ||
* @brief Manages check-ins from ICD devices. | ||
* | ||
* Intended to be used as a thin CheckInDelegate. This allows a delegate register | ||
* themselves so they can be aware when ICD device checks-in allowing the | ||
* delegate to interact with the ICD device during the short window that it is | ||
* awake. | ||
*/ | ||
class IcdManager : public chip::app::DefaultCheckInDelegate | ||
{ | ||
public: | ||
class Delegate | ||
{ | ||
public: | ||
virtual ~Delegate() = default; | ||
virtual void OnCheckInCompleted(const chip::app::ICDClientInfo & clientInfo) = 0; | ||
}; | ||
|
||
static IcdManager & Instance(); | ||
void OnCheckInComplete(const chip::app::ICDClientInfo & clientInfo) override; | ||
|
||
// There is an assumption delegate assigned only happens once and that it lives | ||
// for the entirety of the lifetime of fabric admin. | ||
void SetDelegate(Delegate * delegate); | ||
|
||
private: | ||
static IcdManager sInstance; | ||
Delegate * mDelegate = nullptr; | ||
}; | ||
|
||
} // namespace admin |
Oops, something went wrong.