3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2019 Google LLC.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include "LightingManager.h"
29 #include "timers.h" // provides FreeRTOS timer support
30 #include <ble/BLEEndPoint.h>
31 #include <platform/CHIPDeviceLayer.h>
38 static void AppTaskMain(void * pvParameter);
40 void PostLightActionRequest(int32_t aActor, LightingManager::Action_t aAction);
41 void PostEvent(const AppEvent * event);
43 void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
46 friend AppTask & GetAppTask(void);
50 static void ActionInitiated(LightingManager::Action_t aAction, int32_t aActor);
51 static void ActionCompleted(LightingManager::Action_t aAction);
53 void CancelTimer(void);
55 void DispatchEvent(AppEvent * event);
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);
62 static void UpdateClusterState(void);
64 void StartTimer(uint32_t aTimeoutMs);
68 kFunction_NoneSelected = 0,
69 kFunction_SoftwareUpdate = 0,
70 kFunction_StartBleAdv = 1,
71 kFunction_FactoryReset = 2,
77 bool mFunctionTimerActive;
78 bool mSyncClusterToButtonAction;
80 static AppTask sAppTask;
83 inline AppTask & GetAppTask(void)
85 return AppTask::sAppTask;