diff --git a/hal/abstract/IHalCpp.cpp b/hal/abstract/IHalCpp.cpp index ae017566..58369e4f 100644 --- a/hal/abstract/IHalCpp.cpp +++ b/hal/abstract/IHalCpp.cpp @@ -36,6 +36,10 @@ StatusCode IHalCpp::GetAllLeds(std::map> & return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } StatusCode IHalCpp::GetAllKeys(std::map> &allKeys) +{ + return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +} +StatusCode IHalCpp::GetWifiHal(std::shared_ptr &wifi) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } \ No newline at end of file diff --git a/hal/include/IHalCpp.h b/hal/include/IHalCpp.h index da82e9eb..b885ed26 100644 --- a/hal/include/IHalCpp.h +++ b/hal/include/IHalCpp.h @@ -50,6 +50,13 @@ public: VLedHal() = default; virtual ~VLedHal() = default; }; +class VWifiHal +{ +public: + VWifiHal() = default; + virtual ~VWifiHal() = default; + virtual StatusCode OpenApMode(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +}; class IHalCpp { public: @@ -60,5 +67,6 @@ public: virtual StatusCode UnInit(void); virtual StatusCode GetAllLeds(std::map> &allLeds); virtual StatusCode GetAllKeys(std::map> &allKeys); + virtual StatusCode GetWifiHal(std::shared_ptr &wifi); }; #endif diff --git a/hal/src/WifiHal.cpp b/hal/src/WifiHal.cpp new file mode 100644 index 00000000..f297c002 --- /dev/null +++ b/hal/src/WifiHal.cpp @@ -0,0 +1,14 @@ +/* + * 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. + */ \ No newline at end of file diff --git a/hal/src/WifiHal.h b/hal/src/WifiHal.h new file mode 100644 index 00000000..70384bc1 --- /dev/null +++ b/hal/src/WifiHal.h @@ -0,0 +1,24 @@ +/* + * 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 WIFI_HAL_H +#define WIFI_HAL_H +#include "IHalCpp.h" +class WifiHal : public VWifiHal +{ +public: + WifiHal() = default; + virtual ~WifiHal() = default; +}; +#endif \ No newline at end of file diff --git a/middleware/AppManager/src/AppManager.cpp b/middleware/AppManager/src/AppManager.cpp index c4171e81..634bbebf 100644 --- a/middleware/AppManager/src/AppManager.cpp +++ b/middleware/AppManager/src/AppManager.cpp @@ -15,6 +15,7 @@ #include "AppManager.h" #include "AppManagerMakePtr.h" // #include "FxHttpServer.h" +#include "IHalCpp.h" #include "ILog.h" #include "WebServer.h" AppManager::AppManager() @@ -24,11 +25,18 @@ AppManager::AppManager() } const StatusCode AppManager::Init(const AppParam ¶m) { + std::shared_ptr wifi; + IHalCpp::GetInstance()->GetWifiHal(wifi); + if (!wifi) { + LogError("Get wifi hal failed.\n"); + return CreateStatusCode(STATUS_CODE_NOT_OK); + } + wifi->OpenApMode(); AppManagerMakePtr::GetInstance()->CreateProtocolHandle(mProtocolHandle); HttpServerStart(param); return CreateStatusCode(STATUS_CODE_OK); } -const StatusCode AppManager::UnInit(void) +const StatusCode AppManager::UnInit(void) { HttpServerStop(); mProtocolHandle.reset();