Skip to content

Commit

Permalink
Added a public API to RefreshKeySender to retrieve ICDClientInfo (#36958
Browse files Browse the repository at this point in the history
)

* Added a public API to RefreshKeySender to retrieve ICDClientInfo

* Added a public API to RefreshKeySender to retrieve ICDClientInfo

* Restyled by clang-format

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
thivya-amazon and restyled-commits authored Jan 21, 2025
1 parent 2fed176 commit f5716b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app/icd/client/CheckInDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class DLL_EXPORT CheckInDelegate
* @brief Callback used to let the application know that the re-registration process is done. This callback will be called for
* both success and failure cases. On failure, the callee should take appropriate corrective action based on the error.
*
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller
* will NOT use this pointer any more.
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. It will NOT
* be null regardless the key refresh status. The caller will NOT use this pointer any more.
* @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key
* Other errors indicate the failure reason.
*/
Expand Down
20 changes: 13 additions & 7 deletions src/app/icd/client/DefaultCheckInDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,26 @@ RefreshKeySender * DefaultCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & cl

void DefaultCheckInDelegate::OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error)
{
if (refreshKeySender == nullptr)
{
ChipLogError(ICD, "RefreshKeySender is null");
return;
}
auto icdClientInfo = refreshKeySender->GetICDClientInfo();
Platform::Delete(refreshKeySender);
refreshKeySender = nullptr;
if (error == CHIP_NO_ERROR)
{
ChipLogProgress(ICD, "Re-registration with new key completed successfully");
ChipLogProgress(ICD, "Re-registration with new key completed successfully for peer node " ChipLogFormatScopedNodeId,
ChipLogValueScopedNodeId(icdClientInfo.peer_node));
}
else
{
ChipLogError(ICD, "Re-registration with new key failed with error : %" CHIP_ERROR_FORMAT, error.Format());
ChipLogError(
ICD, "Re-registration with new key failed with error %" CHIP_ERROR_FORMAT " for peer node " ChipLogFormatScopedNodeId,
error.Format(), ChipLogValueScopedNodeId(icdClientInfo.peer_node));
// The callee can take corrective action based on the error received.
}
if (refreshKeySender != nullptr)
{
Platform::Delete(refreshKeySender);
refreshKeySender = nullptr;
}
}
} // namespace app
} // namespace chip
5 changes: 5 additions & 0 deletions src/app/icd/client/RefreshKeySender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ RefreshKeySender::RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDC
mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this)
{}

const ICDClientInfo & RefreshKeySender::GetICDClientInfo()
{
return mICDClientInfo;
}

CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
{
auto onSuccess = [&](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) {
Expand Down
8 changes: 8 additions & 0 deletions src/app/icd/client/RefreshKeySender.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class RefreshKeySender
*/
CHIP_ERROR EstablishSessionToPeer();

/**
* @brief Used to retrieve ICDClientInfo from RefreshKeySender.
*
* @return ICDClientInfo - ICDClientInfo object representing the state associated with the
node that requested a key refresh.
*/
const ICDClientInfo & GetICDClientInfo();

private:
// CASE session callbacks
/**
Expand Down

0 comments on commit f5716b1

Please sign in to comment.