Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lighting-app / nrfconnect / main / 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 #pragma once
20
21 #include "AppEvent.h"
22 #include "LightingManager.h"
23 #include "Rpc.h"
24
25 #include <platform/CHIPDeviceLayer.h>
26
27 #include <cstdint>
28
29 struct k_timer;
30
31 class AppTask
32 {
33 public:
34     int StartApp();
35
36     void PostLightingActionRequest(LightingManager::Action_t aAction);
37     void PostEvent(AppEvent * event);
38     void UpdateClusterState();
39
40 private:
41     friend class chip::rpc::LightingService;
42     friend AppTask & GetAppTask(void);
43
44     int Init();
45
46     static void ActionInitiated(LightingManager::Action_t aAction, int32_t aActor);
47     static void ActionCompleted(LightingManager::Action_t aAction, int32_t aActor);
48
49     void CancelTimer(void);
50
51     void DispatchEvent(AppEvent * event);
52
53     static void FunctionTimerEventHandler(AppEvent * aEvent);
54     static void FunctionHandler(AppEvent * aEvent);
55     static void StartThreadHandler(AppEvent * aEvent);
56     static void LightingActionEventHandler(AppEvent * aEvent);
57     static void StartBLEAdvertisementHandler(AppEvent * aEvent);
58
59     static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
60
61     static void ButtonEventHandler(uint32_t button_state, uint32_t has_changed);
62     static void TimerEventHandler(k_timer * timer);
63
64     void StartTimer(uint32_t aTimeoutInMs);
65
66 #ifdef CONFIG_CHIP_NFC_COMMISSIONING
67     int StartNFCTag();
68 #endif
69
70     enum Function_t
71     {
72         kFunction_NoneSelected   = 0,
73         kFunction_SoftwareUpdate = 0,
74         kFunction_FactoryReset,
75
76         kFunction_Invalid
77     };
78
79     Function_t mFunction;
80     bool mFunctionTimerActive;
81     static AppTask sAppTask;
82 };
83
84 inline AppTask & GetAppTask(void)
85 {
86     return AppTask::sAppTask;
87 }