Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2023 Project CHIP Authors
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #include <app/InteractionModelEngine.h>
19 : #include <app/TimerDelegates.h>
20 : #include <system/SystemClock.h>
21 :
22 : using TimerContext = chip::app::reporting::TimerContext;
23 : using Timeout = chip::System::Clock::Timeout;
24 :
25 : namespace chip {
26 : namespace app {
27 :
28 32 : static void TimerCallbackInterface(System::Layer * aLayer, void * aAppState)
29 : {
30 32 : TimerContext * context = static_cast<TimerContext *>(aAppState);
31 32 : context->TimerFired();
32 32 : }
33 362 : CHIP_ERROR DefaultTimerDelegate::StartTimer(TimerContext * context, Timeout aTimeout)
34 : {
35 362 : return InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer(
36 362 : aTimeout, TimerCallbackInterface, context);
37 : }
38 700 : void DefaultTimerDelegate::CancelTimer(TimerContext * context)
39 : {
40 700 : InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer(
41 : TimerCallbackInterface, context);
42 700 : }
43 9 : bool DefaultTimerDelegate::IsTimerActive(TimerContext * context)
44 : {
45 9 : return InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->IsTimerActive(
46 9 : TimerCallbackInterface, context);
47 : }
48 :
49 1032 : System::Clock::Timestamp DefaultTimerDelegate::GetCurrentMonotonicTimestamp()
50 : {
51 1032 : return System::SystemClock().GetMonotonicTimestamp();
52 : }
53 :
54 : } // namespace app
55 : } // namespace chip
|