Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lighting-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 "LightingManager.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 "Lighting-app"
34
35 class AppTask
36 {
37
38 public:
39     int StartAppTask();
40     static void AppTaskMain(void * pvParameter);
41
42     void PostLightActionRequest(int32_t aActor, LightingManager::Action_t aAction);
43     void PostEvent(const AppEvent * event);
44     void UpdateClusterState();
45
46     static void ButtonEventHandler(uint8_t btnIdx, bool btnPressed);
47
48 private:
49     friend AppTask & GetAppTask(void);
50
51     int Init();
52
53     static void ActionInitiated(LightingManager::Action_t aAction);
54     static void ActionCompleted(LightingManager::Action_t aAction);
55
56     void CancelTimer(void);
57
58     void DispatchEvent(AppEvent * event);
59
60     static void FunctionTimerEventHandler(AppEvent * aEvent);
61     static void FunctionHandler(AppEvent * aEvent);
62
63     static void LightingActionEventHandler(AppEvent * aEvent);
64     static void TimerEventHandler(chip::System::Layer * aLayer, void * aAppState, chip::System::Error aError);
65
66     void StartTimer(uint32_t aTimeoutMs);
67
68     enum Function_t
69     {
70         kFunction_NoneSelected   = 0,
71         kFunction_SoftwareUpdate = 0,
72         kFunction_Joiner         = 1,
73         kFunction_FactoryReset   = 2,
74
75         kFunction_Invalid
76     } Function;
77
78     Function_t mFunction;
79     bool mFunctionTimerActive;
80     bool mSyncClusterToButtonAction;
81     chip::Ble::BLEEndPoint * mBLEEndPoint;
82
83     static AppTask sAppTask;
84 };
85
86 inline AppTask & GetAppTask(void)
87 {
88     return AppTask::sAppTask;
89 }
90
91 #endif // APP_TASK_H