Skip to content

Commit f5716b1

Browse files
Added a public API to RefreshKeySender to retrieve ICDClientInfo (project-chip#36958)
* 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 <commits@restyled.io>
1 parent 2fed176 commit f5716b1

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

src/app/icd/client/CheckInDelegate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class DLL_EXPORT CheckInDelegate
7070
* @brief Callback used to let the application know that the re-registration process is done. This callback will be called for
7171
* both success and failure cases. On failure, the callee should take appropriate corrective action based on the error.
7272
*
73-
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller
74-
* will NOT use this pointer any more.
73+
* @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. It will NOT
74+
* be null regardless the key refresh status. The caller will NOT use this pointer any more.
7575
* @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key
7676
* Other errors indicate the failure reason.
7777
*/

src/app/icd/client/DefaultCheckInDelegate.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,26 @@ RefreshKeySender * DefaultCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & cl
6666

6767
void DefaultCheckInDelegate::OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error)
6868
{
69+
if (refreshKeySender == nullptr)
70+
{
71+
ChipLogError(ICD, "RefreshKeySender is null");
72+
return;
73+
}
74+
auto icdClientInfo = refreshKeySender->GetICDClientInfo();
75+
Platform::Delete(refreshKeySender);
76+
refreshKeySender = nullptr;
6977
if (error == CHIP_NO_ERROR)
7078
{
71-
ChipLogProgress(ICD, "Re-registration with new key completed successfully");
79+
ChipLogProgress(ICD, "Re-registration with new key completed successfully for peer node " ChipLogFormatScopedNodeId,
80+
ChipLogValueScopedNodeId(icdClientInfo.peer_node));
7281
}
7382
else
7483
{
75-
ChipLogError(ICD, "Re-registration with new key failed with error : %" CHIP_ERROR_FORMAT, error.Format());
84+
ChipLogError(
85+
ICD, "Re-registration with new key failed with error %" CHIP_ERROR_FORMAT " for peer node " ChipLogFormatScopedNodeId,
86+
error.Format(), ChipLogValueScopedNodeId(icdClientInfo.peer_node));
7687
// The callee can take corrective action based on the error received.
7788
}
78-
if (refreshKeySender != nullptr)
79-
{
80-
Platform::Delete(refreshKeySender);
81-
refreshKeySender = nullptr;
82-
}
8389
}
8490
} // namespace app
8591
} // namespace chip

src/app/icd/client/RefreshKeySender.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ RefreshKeySender::RefreshKeySender(CheckInDelegate * checkInDelegate, const ICDC
3636
mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this)
3737
{}
3838

39+
const ICDClientInfo & RefreshKeySender::GetICDClientInfo()
40+
{
41+
return mICDClientInfo;
42+
}
43+
3944
CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
4045
{
4146
auto onSuccess = [&](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) {

src/app/icd/client/RefreshKeySender.h

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ class RefreshKeySender
5252
*/
5353
CHIP_ERROR EstablishSessionToPeer();
5454

55+
/**
56+
* @brief Used to retrieve ICDClientInfo from RefreshKeySender.
57+
*
58+
* @return ICDClientInfo - ICDClientInfo object representing the state associated with the
59+
node that requested a key refresh.
60+
*/
61+
const ICDClientInfo & GetICDClientInfo();
62+
5563
private:
5664
// CASE session callbacks
5765
/**

0 commit comments

Comments
 (0)