Skip to content

Commit a61b9f0

Browse files
committed
Self Review fix
1 parent b102d76 commit a61b9f0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

examples/fabric-admin/rpc/RpcServer.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate
4848
void OnCheckInCompleted(const chip::app::ICDClientInfo & clientInfo) override
4949
{
5050
chip::NodeId nodeId = clientInfo.peer_node.GetNodeId();
51-
auto it = mPendingKeepActiveTimesMs.find(nodeId);
52-
VerifyOrReturn(it != mPendingKeepActiveTimesMs.end());
51+
auto it = mPendingCheckIn.find(nodeId);
52+
VerifyOrReturn(it != mPendingCheckIn.end());
5353

5454
KeepActiveDataForCheckIn checkInData = it->second;
55-
mPendingKeepActiveTimesMs.erase(nodeId);
56-
System::Clock::Milliseconds64 timeNowMs =
57-
std::chrono::duration_cast<System::Clock::Milliseconds64>(System::SystemClock().GetMonotonicMilliseconds64());
55+
// Removed from pending map as check-in from this node has occured and we will handle the pending KeepActive
56+
// request.
57+
mPendingCheckIn.erase(nodeId);
5858

59-
if (timeNowMs > checkInData.mRequestExpiresAtMs)
59+
auto timeNowMs = System::SystemClock().GetMonotonicTimestamp();
60+
if (timeNowMs > checkInData.mRequestExpiryTimestamp)
6061
{
6162
ChipLogError(NotSpecified,
6263
"ICD check-in for device we have been waiting, came after KeepActive expiry. Reqeust dropped");
@@ -153,20 +154,19 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate
153154
void ScheduleSendingKeepActiveOnCheckIn(chip::NodeId nodeId, uint32_t stayActiveDurationMs)
154155
{
155156

156-
System::Clock::Milliseconds64 timeNowMs =
157-
std::chrono::duration_cast<System::Clock::Milliseconds64>(System::SystemClock().GetMonotonicMilliseconds64());
157+
auto timeNowMs = System::SystemClock().GetMonotonicTimestamp();
158158
// Spec says we should expire the request 60 mins after we get it
159-
System::Clock::Milliseconds64 expireTimeMs = timeNowMs + System::Clock::Milliseconds64(60 * 60 * 1000);
160-
KeepActiveDataForCheckIn checkInData = { .mStayActiveDurationMs = stayActiveDurationMs,
161-
.mRequestExpiresAtMs = expireTimeMs };
162-
mPendingKeepActiveTimesMs[nodeId] = checkInData;
159+
System::Clock::Timestamp expiryTimestamp = timeNowMs + System::Clock::Seconds64(60 * 60);
160+
KeepActiveDataForCheckIn checkInData = { .mStayActiveDurationMs = stayActiveDurationMs,
161+
.mRequestExpiryTimestamp = expiryTimestamp };
162+
mPendingCheckIn[nodeId] = checkInData;
163163
}
164164

165165
private:
166166
struct KeepActiveDataForCheckIn
167167
{
168168
uint32_t mStayActiveDurationMs = 0;
169-
System::Clock::Milliseconds64 mRequestExpiresAtMs;
169+
System::Clock::Timestamp mRequestExpiryTimestamp;
170170
};
171171

172172
struct KeepActiveWorkData
@@ -187,8 +187,8 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate
187187
chip::Platform::Delete(data);
188188
}
189189

190-
// Modifications to mPendingKeepActiveTimesMs should be done on the MatterEventLoop thread
191-
std::map<chip::NodeId, KeepActiveDataForCheckIn> mPendingKeepActiveTimesMs;
190+
// Modifications to mPendingCheckIn should be done on the MatterEventLoop thread
191+
std::map<chip::NodeId, KeepActiveDataForCheckIn> mPendingCheckIn;
192192
};
193193

194194
FabricAdmin fabric_admin_service;

0 commit comments

Comments
 (0)