/* * Copyright (c) 2023 Fancy Code. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef IHALCPP_H #define IHALCPP_H #include "StatusCode.h" #include #include #include #include using VirtualLedState = unsigned char; using VirtualKeyEvent = unsigned char; constexpr int INVALID_PERIOD = -1; constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100; constexpr int IMEI_LEN = 15; void CreateHalCppModule(void); class VKeyHalMonitor { public: VKeyHalMonitor() = default; virtual ~VKeyHalMonitor() = default; virtual void KeyEventHappened(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs) { } }; class VKeyHal { public: VKeyHal() = default; virtual ~VKeyHal() = default; virtual void CheckKeyStatus(void) {} virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event) {} virtual void SetKeyMonitor(std::shared_ptr &monitor) {} }; class VLedHal { public: VLedHal() = default; ~VLedHal() = default; virtual StatusCode SetHalLedState(const VirtualLedState &state) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } virtual std::string GetLedName(void) { return "undefine"; } }; class IHalCpp { public: IHalCpp() = default; virtual ~IHalCpp() = default; static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); virtual StatusCode Init(void); virtual StatusCode UnInit(void); virtual StatusCode GetLedHals(std::vector> &ledHals); virtual StatusCode GetAllKeys(std::map> &allKeys); }; #endif