Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lock-app / qpg6100 / include / AppTask.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    All rights reserved.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 #ifndef APP_TASK_H
20 #define APP_TASK_H
21
22 #include <stdbool.h>
23 #include <stdint.h>
24
25 #include "AppEvent.h"
26 #include "BoltLockManager.h"
27
28 #include "FreeRTOS.h"
29 #include "timers.h" // provides FreeRTOS timer support
30 #include <ble/BLEEndPoint.h>
31 #include <platform/CHIPDeviceLayer.h>
32
33 #define APP_NAME "Lock-app"
34 class AppTask
35 {
36
37 public:
38     int StartAppTask();
39     static void AppTaskMain(void * pvParameter);
40
41     void PostLockActionRequest(int32_t aActor, BoltLockManager::Action_t aAction);
42     void PostEvent(const AppEvent * event);
43     void UpdateClusterState();
44
45     static void ButtonEventHandler(uint8_t btnIdx, bool btnPressed);
46
47 private:
48     friend AppTask & GetAppTask(void);
49
50     int Init();
51
52     static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor);
53     static void ActionCompleted(BoltLockManager::Action_t aAction);
54
55     void CancelTimer(void);
56
57     void DispatchEvent(AppEvent * event);
58
59     static void FunctionTimerEventHandler(AppEvent * aEvent);
60     static void FunctionHandler(AppEvent * aEvent);
61     static void LockActionEventHandler(AppEvent * aEvent);
62     static void TimerEventHandler(chip::System::Layer * aLayer, void * aAppState, chip::System::Error aError);
63
64     void StartTimer(uint32_t aTimeoutMs);
65
66     enum Function_t
67     {
68         kFunction_NoneSelected   = 0,
69         kFunction_SoftwareUpdate = 0,
70         kFunction_Joiner         = 1,
71         kFunction_FactoryReset   = 2,
72
73         kFunction_Invalid
74     } Function;
75
76     Function_t mFunction;
77     bool mFunctionTimerActive;
78     bool mSyncClusterToButtonAction;
79     chip::Ble::BLEEndPoint * mBLEEndPoint;
80
81     static AppTask sAppTask;
82 };
83
84 inline AppTask & GetAppTask(void)
85 {
86     return AppTask::sAppTask;
87 }
88
89 #endif // APP_TASK_H