@@ -48,15 +48,16 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate
48
48
void OnCheckInCompleted (const chip::app::ICDClientInfo & clientInfo) override
49
49
{
50
50
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 ());
53
53
54
54
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 );
58
58
59
- if (timeNowMs > checkInData.mRequestExpiresAtMs )
59
+ auto timeNowMs = System::SystemClock ().GetMonotonicTimestamp ();
60
+ if (timeNowMs > checkInData.mRequestExpiryTimestamp )
60
61
{
61
62
ChipLogError (NotSpecified,
62
63
" 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
153
154
void ScheduleSendingKeepActiveOnCheckIn (chip::NodeId nodeId, uint32_t stayActiveDurationMs)
154
155
{
155
156
156
- System::Clock::Milliseconds64 timeNowMs =
157
- std::chrono::duration_cast<System::Clock::Milliseconds64>(System::SystemClock ().GetMonotonicMilliseconds64 ());
157
+ auto timeNowMs = System::SystemClock ().GetMonotonicTimestamp ();
158
158
// 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;
163
163
}
164
164
165
165
private:
166
166
struct KeepActiveDataForCheckIn
167
167
{
168
168
uint32_t mStayActiveDurationMs = 0 ;
169
- System::Clock::Milliseconds64 mRequestExpiresAtMs ;
169
+ System::Clock::Timestamp mRequestExpiryTimestamp ;
170
170
};
171
171
172
172
struct KeepActiveWorkData
@@ -187,8 +187,8 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate
187
187
chip::Platform::Delete (data);
188
188
}
189
189
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 ;
192
192
};
193
193
194
194
FabricAdmin fabric_admin_service;
0 commit comments