This commit is contained in:
Fancy code 2024-03-06 05:49:11 -08:00
parent b4d5fa020d
commit 7233841a4a
5 changed files with 59 additions and 1 deletions

View File

@ -36,6 +36,10 @@ StatusCode IHalCpp::GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode IHalCpp::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
{
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode IHalCpp::GetWifiHal(std::shared_ptr<VWifiHal> &wifi)
{
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}

View File

@ -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<std::string, std::shared_ptr<VLedHal>> &allLeds);
virtual StatusCode GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
virtual StatusCode GetWifiHal(std::shared_ptr<VWifiHal> &wifi);
};
#endif

14
hal/src/WifiHal.cpp Normal file
View File

@ -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.
*/

24
hal/src/WifiHal.h Normal file
View File

@ -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

View File

@ -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 &param)
{
std::shared_ptr<VWifiHal> 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();