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