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 "BoltLockManager.h"
29 #include "timers.h" // provides FreeRTOS timer support
30 #include <ble/BLEEndPoint.h>
31 #include <platform/CHIPDeviceLayer.h>
33 #define APP_NAME "Lock-app"
39 static void AppTaskMain(void * pvParameter);
41 void PostLockActionRequest(int32_t aActor, BoltLockManager::Action_t aAction);
42 void PostEvent(const AppEvent * event);
43 void UpdateClusterState();
45 static void ButtonEventHandler(uint8_t btnIdx, bool btnPressed);
48 friend AppTask & GetAppTask(void);
52 static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor);
53 static void ActionCompleted(BoltLockManager::Action_t aAction);
55 void CancelTimer(void);
57 void DispatchEvent(AppEvent * event);
59 static void FunctionTimerEventHandler(AppEvent * aEvent);
60 static void FunctionHandler(AppEvent * aEvent);
61 static void LockActionEventHandler(AppEvent * aEvent);
62 static void TimerEventHandler(chip::System::Layer * aLayer, void * aAppState, chip::System::Error aError);
64 void StartTimer(uint32_t aTimeoutMs);
68 kFunction_NoneSelected = 0,
69 kFunction_SoftwareUpdate = 0,
71 kFunction_FactoryReset = 2,
77 bool mFunctionTimerActive;
78 bool mSyncClusterToButtonAction;
79 chip::Ble::BLEEndPoint * mBLEEndPoint;
81 static AppTask sAppTask;
84 inline AppTask & GetAppTask(void)
86 return AppTask::sAppTask;