Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lock-app / nrfconnect / main / include / AppTask.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2019 Google LLC.
5  *    All rights reserved.
6  *
7  *    Licensed under the Apache License, Version 2.0 (the "License");
8  *    you may not use this file except in compliance with the License.
9  *    You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *    Unless required by applicable law or agreed to in writing, software
14  *    distributed under the License is distributed on an "AS IS" BASIS,
15  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *    See the License for the specific language governing permissions and
17  *    limitations under the License.
18  */
19
20 #pragma once
21
22 #include "AppEvent.h"
23 #include "BoltLockManager.h"
24
25 #include <platform/CHIPDeviceLayer.h>
26
27 struct k_timer;
28
29 class AppTask
30 {
31 public:
32     int StartApp();
33
34     void PostLockActionRequest(int32_t aActor, BoltLockManager::Action_t aAction);
35     void PostEvent(AppEvent * event);
36     void UpdateClusterState();
37
38 private:
39     friend AppTask & GetAppTask(void);
40
41     int Init();
42
43     static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor);
44     static void ActionCompleted(BoltLockManager::Action_t aAction, int32_t aActor);
45
46     void CancelTimer(void);
47
48     void DispatchEvent(AppEvent * event);
49
50     static void FunctionTimerEventHandler(AppEvent * aEvent);
51     static void FunctionHandler(AppEvent * aEvent);
52     static void StartThreadHandler(AppEvent * aEvent);
53     static void LockActionEventHandler(AppEvent * aEvent);
54     static void StartBLEAdvertisementHandler(AppEvent * aEvent);
55
56     static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
57
58     static void ButtonEventHandler(uint32_t buttons_state, uint32_t has_changed);
59     static void TimerEventHandler(k_timer * timer);
60
61     void StartTimer(uint32_t aTimeoutInMs);
62
63 #ifdef CONFIG_CHIP_NFC_COMMISSIONING
64     int StartNFCTag();
65 #endif
66
67     enum Function_t
68     {
69         kFunction_NoneSelected   = 0,
70         kFunction_SoftwareUpdate = 0,
71         kFunction_FactoryReset,
72
73         kFunction_Invalid
74     };
75
76     Function_t mFunction;
77     bool mFunctionTimerActive;
78     static AppTask sAppTask;
79 };
80
81 inline AppTask & GetAppTask(void)
82 {
83     return AppTask::sAppTask;
84 }