3 * Copyright (c) 2020 Project CHIP Authors
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include "LightingManager.h"
29 #include "timers.h" // provides FreeRTOS timer support
30 #include <ble/BLEEndPoint.h>
31 #include <platform/CHIPDeviceLayer.h>
33 #define APP_NAME "Lighting-app"
40 static void AppTaskMain(void * pvParameter);
42 void PostLightActionRequest(int32_t aActor, LightingManager::Action_t aAction);
43 void PostEvent(const AppEvent * event);
44 void UpdateClusterState();
46 static void ButtonEventHandler(uint8_t btnIdx, bool btnPressed);
49 friend AppTask & GetAppTask(void);
53 static void ActionInitiated(LightingManager::Action_t aAction);
54 static void ActionCompleted(LightingManager::Action_t aAction);
56 void CancelTimer(void);
58 void DispatchEvent(AppEvent * event);
60 static void FunctionTimerEventHandler(AppEvent * aEvent);
61 static void FunctionHandler(AppEvent * aEvent);
63 static void LightingActionEventHandler(AppEvent * aEvent);
64 static void TimerEventHandler(chip::System::Layer * aLayer, void * aAppState, chip::System::Error aError);
66 void StartTimer(uint32_t aTimeoutMs);
70 kFunction_NoneSelected = 0,
71 kFunction_SoftwareUpdate = 0,
73 kFunction_FactoryReset = 2,
79 bool mFunctionTimerActive;
80 bool mSyncClusterToButtonAction;
81 chip::Ble::BLEEndPoint * mBLEEndPoint;
83 static AppTask sAppTask;
86 inline AppTask & GetAppTask(void)
88 return AppTask::sAppTask;