Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lock-app / k32w / main / include / AppTask.h
1 /*
2  *
3  *    Copyright (c) 2020 Google LLC.
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 #pragma once
20
21 #include <stdbool.h>
22 #include <stdint.h>
23
24 #include "AppEvent.h"
25 #include "BoltLockManager.h"
26
27 #include <platform/CHIPDeviceLayer.h>
28
29 #include "FreeRTOS.h"
30 #include "timers.h"
31
32 class AppTask
33 {
34 public:
35     int StartAppTask();
36     static void AppTaskMain(void * pvParameter);
37
38     void PostLockActionRequest(int32_t aActor, BoltLockManager::Action_t aAction);
39     void PostEvent(const AppEvent * event);
40
41     void UpdateClusterState(void);
42
43 private:
44     friend AppTask & GetAppTask(void);
45
46     int Init();
47
48     static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor);
49     static void ActionCompleted(BoltLockManager::Action_t aAction);
50
51     void CancelTimer(void);
52
53     void DispatchEvent(AppEvent * event);
54
55     static void FunctionTimerEventHandler(AppEvent * aEvent);
56     static void KBD_Callback(uint8_t events);
57     static void HandleKeyboard(void);
58     static void JoinHandler(AppEvent * aEvent);
59     static void BleHandler(AppEvent * aEvent);
60     static void LockActionEventHandler(AppEvent * aEvent);
61     static void ResetActionEventHandler(AppEvent * aEvent);
62     static void InstallEventHandler(AppEvent * aEvent);
63
64     static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action);
65     static void TimerEventHandler(TimerHandle_t xTimer);
66
67     static void ThreadStart();
68     void StartTimer(uint32_t aTimeoutInMs);
69
70     enum Function_t
71     {
72         kFunction_NoneSelected   = 0,
73         kFunction_SoftwareUpdate = 0,
74         kFunction_FactoryReset,
75         kFunctionLockUnlock,
76
77         kFunction_Invalid
78     } Function;
79
80     Function_t mFunction;
81     bool mResetTimerActive;
82
83     static AppTask sAppTask;
84 };
85
86 inline AppTask & GetAppTask(void)
87 {
88     return AppTask::sAppTask;
89 }