Merge include cleaner.

This commit is contained in:
Fancy code 2024-06-20 12:30:37 +08:00
commit fdacb0c652
226 changed files with 2055 additions and 543 deletions

View File

@ -37,3 +37,4 @@ clean:
external/goahead-5.2.0/GoAhead \ external/goahead-5.2.0/GoAhead \
output_files \ output_files \
cmake-shell cmake-shell
@git checkout output_files

View File

@ -10,6 +10,7 @@ include_directories(
link_directories( link_directories(
${LIBS_OUTPUT_PATH} ${LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH} ${EXTERNAL_LIBS_OUTPUT_PATH}
${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig/lib
) )
aux_source_directory(. SRC_FILES) aux_source_directory(. SRC_FILES)
@ -30,7 +31,6 @@ if(${TEST_COVERAGE} MATCHES "true")
target_link_libraries(${TARGET_NAME} gcov) target_link_libraries(${TARGET_NAME} gcov)
endif() endif()
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
HuntingCamera_code_check HuntingCamera_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -43,12 +43,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HuntingCamera WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HuntingCamera
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make HuntingCamera_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
HuntingCamera_code_format HuntingCamera_code_format
@ -57,6 +51,7 @@ add_custom_target(
-i ${SRC_FILES} ${MAIN_SRC_FILE_THIS} ${HEADER_FILES} -i ${SRC_FILES} ${MAIN_SRC_FILE_THIS} ${HEADER_FILES}
WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HuntingCamera WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/HuntingCamera
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -32,7 +32,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StorageManager DeviceManager HuntingUpgrade KeyControl LedControl StatusCode Log) target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StorageManager DeviceManager HuntingUpgrade KeyControl LedControl StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
MissionManager_code_check MissionManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -44,12 +43,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/MissionManager WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/MissionManager
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make MissionManager_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
MissionManager_code_format MissionManager_code_format
@ -58,6 +51,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/MissionManager WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/MissionManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -13,8 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include "AppMonitor.h" #include "AppMonitor.h"
#include "IAppManager.h"
#include "ILog.h" #include "ILog.h"
#include "IStorageManager.h"
#include "StatusCode.h"
#include <vector> #include <vector>
AppMonitor::AppMonitor() : mMicStatus(SwitchStatus::END)
{
}
StatusCode AppMonitor::GetProductInfo(AppGetProductInfo &param) StatusCode AppMonitor::GetProductInfo(AppGetProductInfo &param)
{ {
LogInfo("AppMonitor::GetProductInfo.\n"); LogInfo("AppMonitor::GetProductInfo.\n");
@ -65,7 +71,7 @@ StatusCode AppMonitor::GetBatteryInfo(AppGetBatteryInfo &param)
} }
StatusCode AppMonitor::GetParamValue(AppParamValue &param) StatusCode AppMonitor::GetParamValue(AppParamValue &param)
{ {
param.mMicStatus = SwitchStatus::ON; param.mMicStatus = mMicStatus;
param.mRec = SwitchStatus::OFF; param.mRec = SwitchStatus::OFF;
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
@ -114,16 +120,18 @@ StatusCode AppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::v
} }
StatusCode AppMonitor::SetDateTime(const AppSetDateTime &param) StatusCode AppMonitor::SetDateTime(const AppSetDateTime &param)
{ {
//
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode AppMonitor::SetTimeZone(const unsigned int &zone) StatusCode AppMonitor::SetTimeZone(const unsigned int &zone)
{ {
//
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode AppMonitor::SetParamValue(const AppSetParamValue &param) StatusCode AppMonitor::SetParamValue(const AppSetParamValue &param)
{ {
LogInfo("SetParamValue: param = %s.\n", param.mName.c_str());
if (param.mName == "mic") {
mMicStatus = static_cast<SwitchStatus>(param.mValue);
}
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode AppMonitor::EnterRecorder(void) StatusCode AppMonitor::EnterRecorder(void)
@ -136,7 +144,6 @@ StatusCode AppMonitor::AppPlayback(const PlayBackEvent &event)
} }
StatusCode AppMonitor::UploadFile(AppUploadFile &param) StatusCode AppMonitor::UploadFile(AppUploadFile &param)
{ {
//
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode AppMonitor::GetThumbnail(AppGetThumbnail &param) StatusCode AppMonitor::GetThumbnail(AppGetThumbnail &param)

View File

@ -19,7 +19,7 @@
class AppMonitor : public VAppMonitor class AppMonitor : public VAppMonitor
{ {
public: public:
AppMonitor() = default; AppMonitor();
virtual ~AppMonitor() = default; virtual ~AppMonitor() = default;
StatusCode GetProductInfo(AppGetProductInfo &param) override; StatusCode GetProductInfo(AppGetProductInfo &param) override;
StatusCode GetDeviceAttr(AppGetDeviceAttr &param) override; StatusCode GetDeviceAttr(AppGetDeviceAttr &param) override;
@ -41,5 +41,8 @@ public:
private: private:
SdCardStatus SdCardStatusConvert(const StorageEvent &event); SdCardStatus SdCardStatusConvert(const StorageEvent &event);
private:
SwitchStatus mMicStatus; // TODO: improve delete.
}; };
#endif #endif

View File

@ -14,6 +14,13 @@
*/ */
#include "DataProcessing.h" #include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IMissionManager.h"
#include "IStateMachine.h"
#include "KeyControl.h"
#include <functional>
#include <map>
#include <memory>
#include <string>
const bool NOT_EXECUTED = false; const bool NOT_EXECUTED = false;
const bool EXECUTED = true; const bool EXECUTED = true;
key_event_data::key_event_data(const std::string &keyName, const KeyEvent &keyEvent, const unsigned int &holdTime) key_event_data::key_event_data(const std::string &keyName, const KeyEvent &keyEvent, const unsigned int &holdTime)

View File

@ -14,6 +14,8 @@
*/ */
#include "IMissionManager.h" #include "IMissionManager.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
std::shared_ptr<IMissionManager> &IMissionManager::GetInstance(std::shared_ptr<IMissionManager> *impl) std::shared_ptr<IMissionManager> &IMissionManager::GetInstance(std::shared_ptr<IMissionManager> *impl)
{ {
static auto instance = std::make_shared<IMissionManager>(); static auto instance = std::make_shared<IMissionManager>();

View File

@ -13,10 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "IdleState.h" #include "IdleState.h"
#include "IFilesManager.h" #include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h" #include "IStateMachine.h"
#include "MissionStateMachine.h"
IdleState::IdleState() : State("IdleState") IdleState::IdleState() : State("IdleState")
{ {
// mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&IdleState::MediaReportHandle, this, _1); // mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&IdleState::MediaReportHandle, this, _1);

View File

@ -14,6 +14,8 @@
*/ */
#include "LedsHandle.h" #include "LedsHandle.h"
#include "ILog.h" #include "ILog.h"
#include "LedControl.h"
#include "SetLedState.h"
void LedsHandle::ControlDeviceStatusLed(const DeviceStatus &status, const long int &keepAliveTime, void LedsHandle::ControlDeviceStatusLed(const DeviceStatus &status, const long int &keepAliveTime,
const unsigned int &blinkPeriod) const unsigned int &blinkPeriod)
{ {

View File

@ -15,6 +15,7 @@
#include "McuMonitor.h" #include "McuMonitor.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h" #include "IMcuManager.h"
#include <memory>
void McuMonitor::Init(std::shared_ptr<VMcuMonitor> &monitor) void McuMonitor::Init(std::shared_ptr<VMcuMonitor> &monitor)
{ {
IMcuManager::GetInstance()->SetMcuMonitor(monitor); IMcuManager::GetInstance()->SetMcuMonitor(monitor);

View File

@ -13,10 +13,15 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MediaHandleState.h" #include "MediaHandleState.h"
#include "IFilesManager.h" #include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h" #include "IMediaManager.h"
#include "IStateMachine.h"
#include "MediaTaskHandle.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include <functional>
#include <memory>
#include <vector>
MediaHandleState::MediaHandleState() : State("MediaHandleState") MediaHandleState::MediaHandleState() : State("MediaHandleState")
{ {
mEventHandle[InternalStateEvent::RESET_KEY_MEDIA_TASK] = mEventHandle[InternalStateEvent::RESET_KEY_MEDIA_TASK] =

View File

@ -13,6 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MediaTask.h" #include "MediaTask.h"
#include "DataProcessing.h"
#include "IMediaManager.h"
#include <memory>
MediaTask::MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEvent, MediaTask::MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEvent,
const std::weak_ptr<VMediaTaskIniator> &iniator) const std::weak_ptr<VMediaTaskIniator> &iniator)
: mType(type), mBindEvent(bindEvent), mIniator(iniator) : mType(type), mBindEvent(bindEvent), mIniator(iniator)

View File

@ -13,8 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MediaTaskHandle.h" #include "MediaTaskHandle.h"
#include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h"
#include "IMissionManager.h"
#include "MediaTask.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include "StatusCode.h"
#include <memory>
MediaTaskHandle::MediaTaskHandle() MediaTaskHandle::MediaTaskHandle()
{ {
mMediaHandle.reset(); mMediaHandle.reset();

View File

@ -15,6 +15,7 @@
#include "MissionManager.h" #include "MissionManager.h"
#include "IAppManager.h" #include "IAppManager.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include "StatusCode.h"
const StatusCode MissionManager::Init(void) const StatusCode MissionManager::Init(void)
{ {
MissionStateMachine::GetInstance()->Init(); MissionStateMachine::GetInstance()->Init();

View File

@ -14,16 +14,21 @@
*/ */
#include "MissionManagerMakePtr.h" #include "MissionManagerMakePtr.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "IMissionManager.h"
#include "IStateMachine.h"
#include "IdleState.h" #include "IdleState.h"
#include "MediaHandleState.h" #include "MediaHandleState.h"
#include "MissionManager.h" #include "MissionManager.h"
#include "OnMissionState.h" #include "OnMissionState.h"
#include "PirTriggeredMissionState.h" #include "PirTriggeredMissionState.h"
#include "SdCardHandleState.h" #include "SdCardHandleState.h"
#include "StatusCode.h"
#include "StorageHandleState.h" #include "StorageHandleState.h"
#include "TestMissionState.h" #include "TestMissionState.h"
#include "TopState.h" #include "TopState.h"
#include "UpgradeState.h" #include "UpgradeState.h"
#include <memory>
bool CreateMissionManagerModule(void) bool CreateMissionManagerModule(void)
{ {
auto instance = std::make_shared<IMissionManager>(); auto instance = std::make_shared<IMissionManager>();

View File

@ -13,9 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MissionState.h" #include "MissionState.h"
#include "IAppManager.h" #include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IStateMachine.h"
#include "LedsHandle.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include <functional>
#include <string>
MissionState::MissionState(const std::string &name) : State(name) MissionState::MissionState(const std::string &name) : State(name)
{ {
mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&MissionState::MediaReportHandle, this, _1); mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&MissionState::MediaReportHandle, this, _1);

View File

@ -15,8 +15,13 @@
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include "DataProcessing.h" #include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "IMissionManager.h"
#include "IStateMachine.h"
#include "McuAskBase.h" #include "McuAskBase.h"
#include "MissionManagerMakePtr.h" #include "MissionManagerMakePtr.h"
#include "StatusCode.h"
#include <memory>
// #include "TopState.h" // #include "TopState.h"
std::shared_ptr<MissionStateMachine> &MissionStateMachine::GetInstance(std::shared_ptr<MissionStateMachine> *impl) std::shared_ptr<MissionStateMachine> &MissionStateMachine::GetInstance(std::shared_ptr<MissionStateMachine> *impl)
{ {

View File

@ -14,7 +14,8 @@
*/ */
#include "OnMissionState.h" #include "OnMissionState.h"
#include "ILog.h" #include "ILog.h"
#include "IStorageManager.h" #include "IStateMachine.h"
#include "MissionState.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
OnMissionState::OnMissionState() : MissionState("OnMissionState") OnMissionState::OnMissionState() : MissionState("OnMissionState")
{ {

View File

@ -12,10 +12,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "PirTriggeredMissionState.h"
#include "ILog.h" #include "ILog.h"
#include "IStorageManager.h" #include "IStateMachine.h"
#include "MissionState.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include "PirTriggeredMissionState.h"
PirTriggeredMissionState::PirTriggeredMissionState() : MissionState("PirTriggeredMissionState") PirTriggeredMissionState::PirTriggeredMissionState() : MissionState("PirTriggeredMissionState")
{ {
// mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] = // mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] =

View File

@ -13,10 +13,18 @@
* limitations under the License. * limitations under the License.
*/ */
#include "SdCardHandleState.h" #include "SdCardHandleState.h"
#include "DataProcessing.h"
#include "IFilesManager.h" #include "IFilesManager.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h" #include "IMediaManager.h"
#include "IMissionManager.h"
#include "IStateMachine.h"
#include "IStorageManager.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include "StatusCode.h"
#include <functional>
#include <memory>
using std::placeholders::_1;
SdCardHandleState::SdCardHandleState() : State("SdCardHandleState"), mSdCardStatus(StorageEvent::END) SdCardHandleState::SdCardHandleState() : State("SdCardHandleState"), mSdCardStatus(StorageEvent::END)
{ {
mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&SdCardHandleState::MediaReportHandle, this, _1); mEventHandle[InternalStateEvent::MEDIA_REPORT_EVENT] = std::bind(&SdCardHandleState::MediaReportHandle, this, _1);

View File

@ -13,6 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "SetLedState.h" #include "SetLedState.h"
#include "IDeviceManager.h"
#include "LedControl.h"
#include "StatusCode.h"
#include <memory>
#include <string>
SetLedState::SetLedState(const LedState &state, const unsigned int &keepAliveTime, const unsigned int &blinkPeriod) SetLedState::SetLedState(const LedState &state, const unsigned int &keepAliveTime, const unsigned int &blinkPeriod)
: mState(state), mKeepAliveTime(keepAliveTime), mBlinkPeriod(blinkPeriod) : mState(state), mKeepAliveTime(keepAliveTime), mBlinkPeriod(blinkPeriod)
{ {

View File

@ -13,9 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include "StorageHandleState.h" #include "StorageHandleState.h"
#include "DataProcessing.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h" #include "IMissionManager.h"
#include "IStateMachine.h"
#include "IStorageManager.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include <functional>
#include <memory>
StorageHandleState::StorageHandleState() : State("StorageHandleState") StorageHandleState::StorageHandleState() : State("StorageHandleState")
{ {
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] = mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =

View File

@ -13,10 +13,17 @@
* limitations under the License. * limitations under the License.
*/ */
#include "TestMissionState.h" #include "TestMissionState.h"
#include "DataProcessing.h"
#include "IAppManager.h" #include "IAppManager.h"
#include "ILog.h" #include "ILog.h"
#include "IMissionManager.h"
#include "IStateMachine.h"
#include "IStorageManager.h" #include "IStorageManager.h"
#include "LedsHandle.h"
#include "MissionState.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include <functional>
#include <memory>
TestMissionState::TestMissionState() : MissionState("TestMissionState") TestMissionState::TestMissionState() : MissionState("TestMissionState")
{ {
mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] = mEventHandle[InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED] =

View File

@ -13,10 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
#include "TopState.h" #include "TopState.h"
#include "DataProcessing.h"
#include "IDeviceManager.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "IMediaManager.h" #include "IMediaManager.h"
#include "IMissionManager.h"
#include "IStateMachine.h"
#include "KeyControl.h" #include "KeyControl.h"
#include "McuMonitor.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include "StatusCode.h"
#include <functional>
#include <memory>
TopState::TopState() : State("TopState") TopState::TopState() : State("TopState")
{ {
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] = mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =

View File

@ -13,10 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "UpgradeState.h" #include "UpgradeState.h"
#include "DataProcessing.h"
#include "IHuntingUpgrade.h" #include "IHuntingUpgrade.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h" #include "IStateMachine.h"
#include "MissionStateMachine.h" #include "MissionStateMachine.h"
#include <functional>
UpgradeState::UpgradeState() : State("UpgradeState") UpgradeState::UpgradeState() : State("UpgradeState")
{ {
mEventHandle[InternalStateEvent::CHECK_UPGRADE_FILE] = std::bind(&UpgradeState::CheckUpgradeFileHandle, this, _1); mEventHandle[InternalStateEvent::CHECK_UPGRADE_FILE] = std::bind(&UpgradeState::CheckUpgradeFileHandle, this, _1);

View File

@ -35,7 +35,6 @@ if(${TEST_COVERAGE} MATCHES "true")
target_link_libraries(${TARGET_NAME} gcov) target_link_libraries(${TARGET_NAME} gcov)
endif() endif()
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
ipc_x86_code_check ipc_x86_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -55,6 +54,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} ${MAIN_SRC_FILE_THIS} -i ${SRC_FILES} ${HEADER_FILES} ${MAIN_SRC_FILE_THIS}
WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/main WORKING_DIRECTORY ${APPLICATION_SOURCE_PATH}/main
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -27,7 +27,7 @@ llvm-twine-local,\
misc-confusable-identifiers,\ misc-confusable-identifiers,\
misc-definitions-in-headers,\ misc-definitions-in-headers,\
misc-header-include-cycle,\ misc-header-include-cycle,\
-misc-include-cleaner,\ misc-include-cleaner,\
misc-misleading-bidirectional,\ misc-misleading-bidirectional,\
misc-misleading-identifier,\ misc-misleading-identifier,\
misc-misplaced-const,\ misc-misplaced-const,\

View File

@ -21,3 +21,4 @@ add_subdirectory(httpserver.h-master/src)
add_subdirectory(cJSON-1.7.17) add_subdirectory(cJSON-1.7.17)
add_subdirectory(libhv/libhv-1.3.2) add_subdirectory(libhv/libhv-1.3.2)
add_subdirectory(ffmpeg) add_subdirectory(ffmpeg)
add_subdirectory(libconfig)

View File

@ -1,32 +1,46 @@
set(FFMPEG_INSTALL_PATH "${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg")
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=linux \
--cc=${CMAKE_C_COMPILER} \
--cxx=${CMAKE_CXX_COMPILER} \
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg \
--enable-parsers --enable-decoder=h264 \
--enable-ffmpeg --enable-static \
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
--enable-muxer=mov --enable-muxer=mp4 \
--enable-decoder=aac --enable-decoder=pcm_alaw --enable-encoder=pcm_alaw \
--enable-demuxer=mov \
--enable-protocol=file --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb")
else()
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=arm64 \
--cc=${CMAKE_C_COMPILER} \
--cxx=${CMAKE_CXX_COMPILER} \
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg \
--disable-asm --enable-parsers --disable-decoders --enable-decoder=h264 \
--disable-debug --enable-ffmpeg --enable-shared --enable-static --disable-stripping --disable-doc \
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
--disable-mipsdsp --disable-mipsdspr2 \
--disable-encoders \
--disable-muxers --enable-muxer=mov --enable-muxer=mp4 \
--disable-decoders --enable-decoder=aac \
--disable-filters \
--disable-demuxers --enable-demuxer=mov \
--disable-parsers \
--disable-protocols --enable-protocol=file \
--disable-bsfs --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb \
--disable-indevs \
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug")
endif()
message("Compile ffmpeg comand : ${CONFIGURE_COMMAND}")
add_custom_target( add_custom_target(
ffmpeg ffmpeg
# DEPENDS ${EXTERNAL_LIBS_OUTPUT_PATH}/libgo.a COMMAND echo "Now compile ffmpeg, please wait..."
# COMMAND mkdir ${GOAHEAD_UPLOAD_TMP_PATH}
# COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/modify/http.c ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src
# COMMAND touch ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src/http.c
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz COMMAND test -f ${EXTERNAL_SOURCE_PATH}/ffmpeg/Makefile || tar -xf ffmpeg_6.1.1.orig.tar.xz
COMMAND cd ffmpeg-6.1.1 && ./configure --enable-cross-compile --target-os=linux --arch=arm64 COMMAND chmod 777 -R ffmpeg-6.1.1
--cc=${CMAKE_C_COMPILER} COMMAND cd ffmpeg-6.1.1 && bash -c "./configure ${CONFIGURE_COMMAND}"
--cxx=${CMAKE_CXX_COMPILER}
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg
--disable-asm --enable-parsers --disable-decoders --enable-decoder=h264
--disable-debug --enable-ffmpeg --enable-shared --enable-static --disable-stripping --disable-doc
--enable-gpl --enable-nonfree --enable-version3 --enable-small
--disable-mipsdsp --disable-mipsdspr2
--disable-encoders
--disable-muxers --enable-muxer=mov --enable-muxer=mp4
--disable-decoders --enable-decoder=aac
--disable-filters
--disable-demuxers --enable-demuxer=mov
--disable-parsers
--disable-protocols --enable-protocol=file
--disable-bsfs --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb
--disable-indevs
--disable-outdevs --disable-ffprobe --disable-ffmpeg --disable-ffplay --disable-debug
COMMAND cd ffmpeg-6.1.1 && make COMMAND cd ffmpeg-6.1.1 && make
COMMAND cd ffmpeg-6.1.1 && make install COMMAND cd ffmpeg-6.1.1 && make install
COMMAND cd ffmpeg-6.1.1 && make clean
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/ffmpeg/ WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/ffmpeg/
) )

39
external/ffmpeg/README.md vendored Normal file
View File

@ -0,0 +1,39 @@
# 1. ffmpeg开发文档
## 1.1. ffplay命令使用
* 播放G711a音频文件
```code
$ ffplay -i audio.g711a -f alaw -ac 1 -ar 8000
```
ffmpeg -i input.g711a -acodec alaw output.wav
* 播放h264视频文件
```code
$ ffplay video.h264
```
## 1.2. 问题记录
### 1.2.1. avformat_open_input执行失败
&emsp;&emsp;在执行avformat_open_input时返回-1094995529<0错误
解决在Ubuntu编译时使能所有的编译选项并且把--arch=赋值为linux
```code
# 详见://external/ffmpeg/CMakeLists.txt
set(CONFIGURE_COMMAND "--enable-cross-compile --target-os=linux --arch=linux \
--cc=${CMAKE_C_COMPILER} \
--cxx=${CMAKE_CXX_COMPILER} \
--prefix=${EXTERNAL_LIBS_OUTPUT_PATH}/ffmpeg \
--enable-parsers --enable-decoder=h264 \
--enable-ffmpeg --enable-shared --enable-static \
--enable-gpl --enable-nonfree --enable-version3 --enable-small \
--enable-muxer=mov --enable-muxer=mp4 \
--enable-decoder=aac \
--enable-demuxer=mov \
--enable-protocol=file --enable-bsf=aac_adtstoasc --enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb")
```

View File

@ -1,4 +1,30 @@
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
include(${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/goahead.cmake) include(${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/goahead.cmake)
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH}) include(${UTILS_SOURCE_PATH}/WebServer/build/webserver.cmake)
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH}) add_custom_target(
goahead-5.2.0
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/Makefile || tar zxvf goahead-5.2.0.tar.gz
COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/modify/http.c ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/src
COMMAND chmod 777 -R GoAhead
COMMAND cd GoAhead && make CC=${CMAKE_C_COMPILER} ARCH=${SET_ARCH} PROFILE=${LIB_TYPE} ME_GOAHEAD_UPLOAD_DIR=\"${GOAHEAD_UPLOAD_TMP_PATH}\"
ME_GOAHEAD_SSL_KEY=\"${GOAHEAD_CONFIG_FILE_PATH}/self.key\" ME_GOAHEAD_SSL_CERTIFICATE=\"${GOAHEAD_CONFIG_FILE_PATH}/self.crt\"
${ME_GOAHEAD_LIMIT_POST} -f ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/modify/goahead-linux-static-fancy.mk
COMMAND echo "Copy goahead lib to output path."
COMMAND mv ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/build/${GOAHEAD_INCLUDE_PATH}/bin/libgo.a ${EXTERNAL_LIBS_OUTPUT_PATH}/libgo.a
COMMAND mv ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/build/${GOAHEAD_INCLUDE_PATH}/bin/libmbedtls.a ${EXTERNAL_LIBS_OUTPUT_PATH}/libmbedtls.a
COMMAND mv ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/build/${GOAHEAD_INCLUDE_PATH}/bin/libgoahead-mbedtls.a ${EXTERNAL_LIBS_OUTPUT_PATH}/libgoahead-mbedtls.a
COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/build/${GOAHEAD_INCLUDE_PATH}/bin/self.crt ${PLATFORM_PATH}/cmake-shell/
COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/build/${GOAHEAD_INCLUDE_PATH}/bin/self.key ${PLATFORM_PATH}/cmake-shell/
COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/test/route.txt ${PLATFORM_PATH}/cmake-shell/
COMMAND cp ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/GoAhead/test/auth.txt ${PLATFORM_PATH}/cmake-shell/
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/
)
add_custom_target(
remove_goahead_source_files
COMMAND rm -rf GoAhead
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/goahead-5.2.0/
)
# cleanclean_script
add_dependencies(sdk_clean remove_goahead_source_files)

26
external/libconfig/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,26 @@
set(LIBCONFIG_INSTALL_PATH "${EXTERNAL_LIBS_OUTPUT_PATH}/libconfig")
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
set(CONFIGURE_COMMAND "--disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}")
else()
set(CONFIGURE_COMMAND "--host=${COMPILE_HOST} --disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}")
endif()
message("Compile libconfig comand : ${CONFIGURE_COMMAND}")
add_custom_target(
libconfig
COMMAND test -f ${EXTERNAL_SOURCE_PATH}/libconfig-1.7.3/Makefile || tar zxvf libconfig-1.7.3.tar.gz
COMMAND chmod 777 -R libconfig-1.7.3
# COMMAND cd libconfig-1.7.3 && ./configure --disable-cxx --enable-static=yes --prefix=${LIBCONFIG_INSTALL_PATH}
COMMAND cd libconfig-1.7.3 && bash -c "./configure ${CONFIGURE_COMMAND}"
COMMAND cd libconfig-1.7.3 && make
COMMAND cd libconfig-1.7.3 && make install
COMMAND cd libconfig-1.7.3 && make clean
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
)
add_custom_target(
remove_libconfig_source_files
COMMAND rm -rf libconfig-1.7.3
WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/libconfig/
)
# cleanclean_script
add_dependencies(sdk_clean remove_libconfig_source_files)

View File

@ -12,6 +12,7 @@ include_directories(
${UTILS_SOURCE_PATH}/Log/include ${UTILS_SOURCE_PATH}/Log/include
${UTILS_SOURCE_PATH}/LinuxApi/include ${UTILS_SOURCE_PATH}/LinuxApi/include
${UTILS_SOURCE_PATH}/KeyControl/include ${UTILS_SOURCE_PATH}/KeyControl/include
${UTILS_SOURCE_PATH}/LedControl/include
) )
#do not rely on any other library #do not rely on any other library
# link_directories( # link_directories(
@ -24,12 +25,10 @@ aux_source_directory(./src IMPL_SRC_FILES)
set(ABSTRACT_TARGET HalAbstract) set(ABSTRACT_TARGET HalAbstract)
set(IMPL_TARGET Hal) set(IMPL_TARGET Hal)
add_library(${ABSTRACT_TARGET} STATIC ${ABSTRACT_SRC_FILES}) add_library(${ABSTRACT_TARGET} STATIC ${ABSTRACT_SRC_FILES})
target_link_libraries(${ABSTRACT_TARGET} LinuxApi KeyControl StatusCode Log) target_link_libraries(${ABSTRACT_TARGET} LinuxApi KeyControl LedControl StatusCode Log)
add_library(${IMPL_TARGET} STATIC ${IMPL_SRC_FILES}) add_library(${IMPL_TARGET} STATIC ${IMPL_SRC_FILES})
target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET}) target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET})
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
Hal_code_check Hal_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -50,6 +49,7 @@ add_custom_target(
-i ${ABSTRACT_SRC_FILES} ${IMPL_SRC_FILES} ${HEADER_FILES} -i ${ABSTRACT_SRC_FILES} ${IMPL_SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${HAL_SOURCE_PATH} WORKING_DIRECTORY ${HAL_SOURCE_PATH}
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${IMPL_TARGET} TARGET ${IMPL_TARGET}
PRE_BUILD PRE_BUILD

View File

@ -14,7 +14,10 @@
*/ */
#include "IHalCpp.h" #include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <map>
#include <memory> #include <memory>
#include <string>
camera_report_event::camera_report_event(const std::string &fileName, const CameraType &cameraType) camera_report_event::camera_report_event(const std::string &fileName, const CameraType &cameraType)
: mFileName(fileName), mCameraType(cameraType) : mFileName(fileName), mCameraType(cameraType)
{ {
@ -64,8 +67,14 @@ void VCameraHalMonitor::ReportEvent(const CameraReportEvent &event)
{ {
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
} }
StatusCode VCameraTaskContext::TaskFinished(void)
{
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
camera_task_param::camera_task_param(const CameraTaskType &cameraTask) : mCameraTask(cameraTask) camera_task_param::camera_task_param(const CameraTaskType &cameraTask) : mCameraTask(cameraTask)
{ {
mVideoRecordingTimeMs = DEFAULT_VIDEO_RECORDING_TIME_MS;
} }
void VCameraHal::SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor) void VCameraHal::SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor)
{ {
@ -76,6 +85,21 @@ StatusCode VCameraHal::StartSingleTask(const CameraTaskParam &param)
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
} }
StatusCode VCameraHal::StopTask(void)
{
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode VCameraHal::SetAudioStreamCallback(AudioStreamCallback callback)
{
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode VCameraHal::SetVideoStreamCallback(VideoStreamCallback callback)
{
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
void VSdCardHalMonitor::ReportEvent(const SdCardHalStatus &status) void VSdCardHalMonitor::ReportEvent(const SdCardHalStatus &status)
{ {
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n"); LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");

View File

@ -15,6 +15,7 @@
#ifndef I_HAL_CPP_H #ifndef I_HAL_CPP_H
#define I_HAL_CPP_H #define I_HAL_CPP_H
#include "StatusCode.h" #include "StatusCode.h"
#include <functional>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <memory> #include <memory>
@ -70,7 +71,6 @@ public:
virtual void CheckKeyStatus(void); virtual void CheckKeyStatus(void);
virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event); virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event);
virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor); virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor);
// virtual std::string GetKeyHalName(void);
}; };
class VLedHal class VLedHal
{ {
@ -100,6 +100,7 @@ class VCameraTaskContext
public: public:
VCameraTaskContext() = default; VCameraTaskContext() = default;
virtual ~VCameraTaskContext() = default; virtual ~VCameraTaskContext() = default;
virtual StatusCode TaskFinished(void);
}; };
template <typename T> template <typename T>
class CameraTaskContext : public VCameraTaskContext class CameraTaskContext : public VCameraTaskContext
@ -113,12 +114,18 @@ public:
public: public:
T mData; T mData;
}; };
constexpr int DEFAULT_VIDEO_RECORDING_TIME_MS = 10 * 1000;
typedef struct camera_task_param typedef struct camera_task_param
{ {
camera_task_param(const CameraTaskType &cameraTask); camera_task_param(const CameraTaskType &cameraTask);
const CameraTaskType mCameraTask; const CameraTaskType mCameraTask;
unsigned int mVideoRecordingTimeMs;
std::shared_ptr<VCameraTaskContext> mCtx; std::shared_ptr<VCameraTaskContext> mCtx;
} CameraTaskParam; } CameraTaskParam;
// using AudioStreamCallback = void (*)(const void *, const int, const unsigned long long);
// using VideoStreamCallback = void (*)(const void *, const int, const unsigned long long);
using AudioStreamCallback = std::function<void(const void *, const unsigned int &, const unsigned long long &)>;
using VideoStreamCallback = std::function<void(const void *, const unsigned int &, const unsigned long long &)>;
class VCameraHal class VCameraHal
{ {
public: public:
@ -126,6 +133,9 @@ public:
virtual ~VCameraHal() = default; virtual ~VCameraHal() = default;
virtual void SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor); virtual void SetCameraMonitor(std::shared_ptr<VCameraHalMonitor> &monitor);
virtual StatusCode StartSingleTask(const CameraTaskParam &param); virtual StatusCode StartSingleTask(const CameraTaskParam &param);
virtual StatusCode StopTask(void);
virtual StatusCode SetAudioStreamCallback(AudioStreamCallback callback);
virtual StatusCode SetVideoStreamCallback(VideoStreamCallback callback);
}; };
class VSdCardHalMonitor class VSdCardHalMonitor
{ {

60
hal/src/CameraHal.cpp Normal file
View File

@ -0,0 +1,60 @@
/*
* 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.
*/
#include "CameraHal.h"
#include "IHalCpp.h"
#include "ILog.h"
#include "StatusCode.h"
CameraHal::CameraHal() : mTaskRuning(false), mAudioStreamCallback(nullptr), mVideoStreamCallback(nullptr)
{
}
void CameraHal::Init(void)
{
}
void CameraHal::UnInit(void)
{
}
StatusCode CameraHal::StartSingleTask(const CameraTaskParam &param)
{
LogInfo("StartSingleTask.\n");
mTaskRuning = true;
return CreateStatusCode(STATUS_CODE_OK);
}
StatusCode CameraHal::StopTask(void)
{
mTaskRuning = false;
return CreateStatusCode(STATUS_CODE_OK);
}
StatusCode CameraHal::SetAudioStreamCallback(AudioStreamCallback callback)
{
mAudioStreamCallback = callback;
return CreateStatusCode(STATUS_CODE_OK);
}
StatusCode CameraHal::SetVideoStreamCallback(VideoStreamCallback callback)
{
mVideoStreamCallback = callback;
return CreateStatusCode(STATUS_CODE_OK);
}
void CameraHal::GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{
if (mTaskRuning && nullptr != mAudioStreamCallback) {
mAudioStreamCallback(stream, length, timeStamp);
}
}
void CameraHal::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{
if (mTaskRuning && nullptr != mVideoStreamCallback) {
mVideoStreamCallback(stream, length, timeStamp);
}
}

45
hal/src/CameraHal.h Normal file
View File

@ -0,0 +1,45 @@
/*
* 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 CAMERA_HAL_H
#define CAMERA_HAL_H
#include "IHalCpp.h"
#include <mutex>
#include <thread>
constexpr unsigned int NO_MEDIA_RECORDING = -1;
class CameraHal : public VCameraHal, public std::enable_shared_from_this<CameraHal>
{
public:
CameraHal();
virtual ~CameraHal() = default;
virtual void Init(void);
virtual void UnInit(void);
protected:
StatusCode StartSingleTask(const CameraTaskParam &param) override;
StatusCode StopTask(void) override;
StatusCode SetAudioStreamCallback(AudioStreamCallback callback) override;
StatusCode SetVideoStreamCallback(VideoStreamCallback callback) override;
protected:
void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
private:
// std::mutex mMutex;
bool mTaskRuning;
AudioStreamCallback mAudioStreamCallback;
VideoStreamCallback mVideoStreamCallback;
};
#endif

View File

@ -13,7 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "Hal.h" #include "Hal.h"
#include "IHal.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
StatusCode HalInit(IHal *hal) StatusCode HalInit(IHal *hal)

View File

@ -14,9 +14,15 @@
*/ */
#include "HalCpp.h" #include "HalCpp.h"
#include "HalMakePtr.h" #include "HalMakePtr.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "SdCardHal.h" #include "SdCardHal.h"
#include "StatusCode.h"
#include "WifiHal.h" #include "WifiHal.h"
#include <map>
#include <memory>
#include <string>
#include <utility>
StatusCode HalCpp::Init(void) StatusCode HalCpp::Init(void)
{ {
LogInfo("HalCpp::Init\n"); LogInfo("HalCpp::Init\n");
@ -30,12 +36,8 @@ StatusCode HalCpp::Init(void)
if (nullptr != sdCardImpl) { if (nullptr != sdCardImpl) {
sdCardImpl->Init(); sdCardImpl->Init();
} }
HalMakePtr::GetInstance()->CreateAllKeyHal(mKeys); HalMakePtr::GetInstance()->CreateAllKeysHal(mKeys);
// auto checkPinValue = [](std::shared_ptr<HalCpp> impl) { HalMakePtr::GetInstance()->CreateAllLedsHal(mLeds);
// LogInfo("HalCpp::CheckAllPinVauleThread start\n");
// impl->CheckAllPinVauleThread();
// };
// mCheckPinThread = std::thread(checkPinValue, shared_from_this());
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode HalCpp::UnInit(void) StatusCode HalCpp::UnInit(void)
@ -45,10 +47,6 @@ StatusCode HalCpp::UnInit(void)
if (nullptr != sdCardImpl) { if (nullptr != sdCardImpl) {
sdCardImpl->UnInit(); sdCardImpl->UnInit();
} }
mThreadRuning = false;
if (mCheckPinThread.joinable()) {
mCheckPinThread.join();
}
mWifiHal.reset(); mWifiHal.reset();
mSdCardHal.reset(); mSdCardHal.reset();
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
@ -63,6 +61,19 @@ StatusCode HalCpp::GetSdCardHal(std::shared_ptr<VSdCardHal> &sdCard)
sdCard = mSdCardHal; sdCard = mSdCardHal;
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode HalCpp::GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds)
{
LogInfo("GetAllLeds, size = %d\n", mLeds.size());
for (auto &led : mLeds) {
std::shared_ptr<VLedHal> ledControl = std::dynamic_pointer_cast<VLedHal>(led);
if (nullptr == ledControl) {
LogError("ledControl is nullptr\n");
continue;
}
allLeds.insert(std::make_pair(led->GetLedName(), ledControl));
}
return CreateStatusCode(STATUS_CODE_OK);
}
StatusCode HalCpp::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys) StatusCode HalCpp::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
{ {
LogInfo("GetAllKeys\n"); LogInfo("GetAllKeys\n");
@ -76,12 +87,3 @@ StatusCode HalCpp::GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &a
} }
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
void HalCpp::CheckAllPinVauleThread(void)
{
// mThreadRuning = true;
// while (mThreadRuning) {
// for (auto &keyHalImpl : mKeys) {
// }
// std::this_thread::sleep_for(std::chrono::milliseconds(PERIPHERAL_CHECK_PERIOD_MS));
// }
}

View File

@ -16,6 +16,7 @@
#define HALCPP_H #define HALCPP_H
#include "IHalCpp.h" #include "IHalCpp.h"
#include "KeyControl.h" #include "KeyControl.h"
#include "LedControl.h"
#include <memory> #include <memory>
#include <thread> #include <thread>
class HalCpp : public IHalCpp, public std::enable_shared_from_this<HalCpp> class HalCpp : public IHalCpp, public std::enable_shared_from_this<HalCpp>
@ -27,17 +28,15 @@ public:
StatusCode UnInit(void) override; StatusCode UnInit(void) override;
StatusCode GetWifiHal(std::shared_ptr<VWifiHal> &wifi) override; StatusCode GetWifiHal(std::shared_ptr<VWifiHal> &wifi) override;
StatusCode GetSdCardHal(std::shared_ptr<VSdCardHal> &sdCard) override; StatusCode GetSdCardHal(std::shared_ptr<VSdCardHal> &sdCard) override;
StatusCode GetAllLeds(std::map<std::string, std::shared_ptr<VLedHal>> &allLeds) override;
StatusCode GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys) override; StatusCode GetAllKeys(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys) override;
private: private:
void CheckAllPinVauleThread(void);
private: private:
std::vector<std::shared_ptr<VLedHal>> mLedHals; std::vector<std::shared_ptr<VLedHal>> mLedHals;
std::shared_ptr<VWifiHal> mWifiHal; std::shared_ptr<VWifiHal> mWifiHal;
std::shared_ptr<VSdCardHal> mSdCardHal; std::shared_ptr<VSdCardHal> mSdCardHal;
std::vector<std::shared_ptr<VKeyControl>> mKeys; std::vector<std::shared_ptr<VKeyControl>> mKeys;
bool mThreadRuning = false; std::vector<std::shared_ptr<VLedControl>> mLeds;
std::thread mCheckPinThread;
}; };
#endif #endif

View File

@ -15,14 +15,21 @@
#include "HalMakePtr.h" #include "HalMakePtr.h"
#include "Hal.h" #include "Hal.h"
#include "HalCpp.h" #include "HalCpp.h"
#include "IHal.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "KeyControl.h"
#include "LedControl.h"
#include "SdCardHal.h" #include "SdCardHal.h"
#include "StatusCode.h"
#include "WifiHal.h" #include "WifiHal.h"
#include <memory>
#include <vector>
StatusCode CreateHalModule(void) StatusCode CreateHalModule(void)
{ {
IHal *hal = NULL; IHal *hal = nullptr;
StatusCode code = HalMakePtr::GetInstance()->CreateHalPtr(&hal); StatusCode code = HalMakePtr::GetInstance()->CreateHalPtr(&hal);
if (IsCodeOK(code) && NULL != hal) { if (IsCodeOK(code) && nullptr != hal) {
LogInfo("Create Hal instance ok.\n"); LogInfo("Create Hal instance ok.\n");
ResetHalImpl((IHal *)hal); ResetHalImpl((IHal *)hal);
} }
@ -82,10 +89,11 @@ StatusCode HalMakePtr::CreateWifiHal(std::shared_ptr<VWifiHal> &impl)
impl = std::make_shared<WifiHal>(); impl = std::make_shared<WifiHal>();
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode HalMakePtr::CreateCameraHal(std::shared_ptr<VCameraHal> &impl) std::shared_ptr<VCameraHal> HalMakePtr::CreateCameraHal(const CameraType &type)
{ {
LogWarning("CreateCameraHal.\n"); LogWarning("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); auto camera = std::make_shared<VCameraHal>();
return camera;
} }
StatusCode HalMakePtr::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl) StatusCode HalMakePtr::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl)
{ {
@ -93,7 +101,12 @@ StatusCode HalMakePtr::CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl)
impl = std::make_shared<SdCardHal>(); impl = std::make_shared<SdCardHal>();
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode HalMakePtr::CreateAllKeyHal(std::vector<std::shared_ptr<VKeyControl>> &keys) StatusCode HalMakePtr::CreateAllKeysHal(std::vector<std::shared_ptr<VKeyControl>> &keys)
{
LogInfo("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
StatusCode HalMakePtr::CreateAllLedsHal(std::vector<std::shared_ptr<VLedControl>> &leds)
{ {
LogInfo("STATUS_CODE_VIRTUAL_FUNCTION.\n"); LogInfo("STATUS_CODE_VIRTUAL_FUNCTION.\n");
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);

View File

@ -16,8 +16,9 @@
#define HALMAKEPTR_H #define HALMAKEPTR_H
#include "IHal.h" #include "IHal.h"
#include "IHalCpp.h" #include "IHalCpp.h"
#include "StatusCode.h"
#include "KeyControl.h" #include "KeyControl.h"
#include "LedControl.h"
#include "StatusCode.h"
#include <memory> #include <memory>
class HalMakePtr class HalMakePtr
{ {
@ -25,19 +26,12 @@ public:
HalMakePtr() = default; HalMakePtr() = default;
virtual ~HalMakePtr() = default; virtual ~HalMakePtr() = default;
static std::shared_ptr<HalMakePtr> &GetInstance(std::shared_ptr<HalMakePtr> *impl = nullptr); static std::shared_ptr<HalMakePtr> &GetInstance(std::shared_ptr<HalMakePtr> *impl = nullptr);
virtual StatusCode Init()
{
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
virtual StatusCode UnInit()
{
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
virtual StatusCode CreateHalPtr(IHal **hal); virtual StatusCode CreateHalPtr(IHal **hal);
virtual StatusCode CreateHalSharePtr(std::shared_ptr<IHalCpp> &impl); virtual StatusCode CreateHalSharePtr(std::shared_ptr<IHalCpp> &impl);
virtual StatusCode CreateWifiHal(std::shared_ptr<VWifiHal> &impl); virtual StatusCode CreateWifiHal(std::shared_ptr<VWifiHal> &impl);
virtual StatusCode CreateCameraHal(std::shared_ptr<VCameraHal> &impl); virtual std::shared_ptr<VCameraHal> CreateCameraHal(const CameraType &type);
virtual StatusCode CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl); virtual StatusCode CreateSdCardHal(std::shared_ptr<VSdCardHal> &impl);
virtual StatusCode CreateAllKeyHal(std::vector<std::shared_ptr<VKeyControl>> &keys); virtual StatusCode CreateAllKeysHal(std::vector<std::shared_ptr<VKeyControl>> &keys);
virtual StatusCode CreateAllLedsHal(std::vector<std::shared_ptr<VLedControl>> &leds);
}; };
#endif #endif

View File

@ -13,17 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
#include "SdCardHal.h" #include "SdCardHal.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "LinuxApi.h" #include "LinuxApi.h"
#include <errno.h> #include "StatusCode.h"
#include <chrono>
#include <fcntl.h> #include <fcntl.h>
#include <memory>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/statvfs.h> #include <sys/statfs.h>
#include <sys/types.h>
#include <sys/vfs.h> #include <sys/vfs.h>
#include <thread>
#include <unistd.h> #include <unistd.h>
const char *SD_CARD_DEVICE = SD_CARD_DEV; const char *SD_CARD_DEVICE = SD_CARD_DEV;
const char *SD_MOUNT_PATH = SD_CARD_MOUNT_PATH; const char *SD_MOUNT_PATH = SD_CARD_MOUNT_PATH;

View File

@ -23,7 +23,8 @@ public:
virtual ~SdCardHal() = default; virtual ~SdCardHal() = default;
void SetSdCardMonitor(std::shared_ptr<VSdCardHalMonitor> &monitor) override; void SetSdCardMonitor(std::shared_ptr<VSdCardHalMonitor> &monitor) override;
SdCardHalStatus GetSdCardStatus(void) override; SdCardHalStatus GetSdCardStatus(void) override;
StatusCode GetCapacity(unsigned long long &totalSizeMB, unsigned long long &freeSizeMB, unsigned long long &usedSizeMB) override; StatusCode GetCapacity(unsigned long long &totalSizeMB, unsigned long long &freeSizeMB,
unsigned long long &usedSizeMB) override;
void Init(void); void Init(void);
void UnInit(void); void UnInit(void);
void DevDetectingThread(void); void DevDetectingThread(void);

View File

@ -15,6 +15,8 @@
#include "WifiHal.h" #include "WifiHal.h"
#include "ILog.h" #include "ILog.h"
#include "LinuxApi.h" #include "LinuxApi.h"
#include "StatusCode.h"
#include <chrono>
#include <dirent.h> #include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,12 +31,22 @@ StatusCode WifiHal::OpenApMode(void)
constexpr int SLEEP_TIME_MS = 5; constexpr int SLEEP_TIME_MS = 5;
constexpr int WAITING_TIME_MS = 1000 * 10; constexpr int WAITING_TIME_MS = 1000 * 10;
unsigned int sleepingTime_ms = 0; unsigned int sleepingTime_ms = 0;
unsigned int resetWifiPowerCount = 0;
mInitRunning = true; mInitRunning = true;
while (CheckWlan0IfExist() == false) { while (CheckWlan0IfExist() == false) {
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS)); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
sleepingTime_ms += SLEEP_TIME_MS; sleepingTime_ms += SLEEP_TIME_MS;
if (sleepingTime_ms > WAITING_TIME_MS) { if (sleepingTime_ms > WAITING_TIME_MS) {
LogError("wlan0 not found. \n"); if (0 == resetWifiPowerCount) {
LogWarning("wlan0 not found, try to reset. \n");
PowerOff();
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
PowerOn();
sleepingTime_ms = 0;
resetWifiPowerCount++;
continue;
}
LogError("wlan0 not found, reset wifi power count: %d. \n", resetWifiPowerCount);
return CreateStatusCode(STATUS_CODE_NOT_OK); return CreateStatusCode(STATUS_CODE_NOT_OK);
} }
if (false == mInitRunning) { if (false == mInitRunning) {
@ -84,7 +96,5 @@ bool WifiHal::CheckWlan0IfExist(void)
if (wlan0_found) { if (wlan0_found) {
return true; return true;
} }
else {
return false; return false;
}
} }

20
merge.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# 获取所有由我们删除的文件列表
deleted_files=$(git status --short | grep '^DU' | awk '{print $2}')
# 检查是否找到了任何文件
if [[ -z "$deleted_files" ]]; then
echo "没有找到由我们删除的文件。"
exit 0
fi
# 遍历文件列表并忽略它们
for file in $deleted_files; do
echo "忽略文件: $file"
git rm --cached "$file"
done
# 提示用户提交更改
echo "已忽略所有由我们删除的文件。"
echo "你可以使用 'git commit' 来提交这些更改。"

View File

@ -27,7 +27,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} WebServer TcpModule Hal cjson-static StatusCode Log) target_link_libraries(${TARGET_NAME} WebServer TcpModule Hal cjson-static StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
AppManager_code_check AppManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -47,6 +46,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/AppManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/AppManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -13,9 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "AppClient.h" #include "AppClient.h"
#include "IAppManager.h"
#include "IAppProtocolHandle.h" #include "IAppProtocolHandle.h"
#include "ILog.h" #include "ILog.h"
#include "TcpModule.h" #include "TcpModule.h"
#include <memory>
#include <string>
AppClient::AppClient(const void *clientObject) : mClientObject(clientObject) AppClient::AppClient(const void *clientObject) : mClientObject(clientObject)
{ {
} }

View File

@ -15,10 +15,15 @@
#include "AppManager.h" #include "AppManager.h"
#include "AppClient.h" #include "AppClient.h"
#include "AppManagerMakePtr.h" #include "AppManagerMakePtr.h"
#include "IAppManager.h"
#include "IAppProtocolHandle.h"
#include "IHalCpp.h" #include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include "TcpModule.h" #include "TcpModule.h"
#include "WebServer.h" #include "WebServer.h"
#include <memory>
#include <sys/types.h>
AppManager::AppManager() : mTcpServer(nullptr), mInitRuning(false) AppManager::AppManager() : mTcpServer(nullptr), mInitRuning(false)
{ {
} }

View File

@ -14,7 +14,11 @@
*/ */
#include "AppManagerMakePtr.h" #include "AppManagerMakePtr.h"
#include "AppManager.h" #include "AppManager.h"
#include "IAppManager.h"
#include "IAppProtocolHandle.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
// extern bool CreateProtocolHandleImpl(); // extern bool CreateProtocolHandleImpl();
bool CreateAppManagerModule(void) bool CreateAppManagerModule(void)
{ {

View File

@ -14,6 +14,10 @@
*/ */
#include "IAppManager.h" #include "IAppManager.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
#include <string>
#include <vector>
app_get_product_info::app_get_product_info() app_get_product_info::app_get_product_info()
{ {
} }

View File

@ -13,7 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "IAppProtocolHandle.h" #include "IAppProtocolHandle.h"
#include "IAppManager.h"
#include "ILog.h" #include "ILog.h"
#include "WebServer.h"
#include <cstdlib>
#include <memory>
#include <string>
protocol_packet::~protocol_packet() protocol_packet::~protocol_packet()
{ {
if (nullptr != mData) { if (nullptr != mData) {

View File

@ -13,11 +13,21 @@
* limitations under the License. * limitations under the License.
*/ */
#include "SixFrameHandle.h" #include "SixFrameHandle.h"
#include "IAppManager.h"
#include "IAppProtocolHandle.h"
#include "ILog.h" #include "ILog.h"
#include <WebServer.h>
#include <cJSON.h>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <functional>
#include <map>
#include <memory>
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <string>
#include <time.h> #include <time.h>
#include <vector>
using std::placeholders::_1; using std::placeholders::_1;
using std::placeholders::_2; using std::placeholders::_2;
using std::placeholders::_3; using std::placeholders::_3;
@ -423,8 +433,8 @@ void SixFrameHandle::ResponseGetParamItems(cJSON *result, const AppGetCapability
cJSON_AddItemToObject(mic, CJSON_INDEX_STRING, index); cJSON_AddItemToObject(mic, CJSON_INDEX_STRING, index);
cJSON_AddItemToArray(items, cJSON_CreateString("on")); cJSON_AddItemToArray(items, cJSON_CreateString("on"));
cJSON_AddItemToArray(items, cJSON_CreateString("off")); cJSON_AddItemToArray(items, cJSON_CreateString("off"));
cJSON_AddItemToArray(index, cJSON_CreateNumber(0));
cJSON_AddItemToArray(index, cJSON_CreateNumber(1)); cJSON_AddItemToArray(index, cJSON_CreateNumber(1));
cJSON_AddItemToArray(index, cJSON_CreateNumber(0));
} }
} }
// { // {
@ -714,16 +724,10 @@ AppSetParamValue inline SixFrameHandle::RequestSetParamValueParse(const std::str
auto parseFunc = [](const std::string &key, const std::string &value, std::shared_ptr<VParseUrl> &parse) { auto parseFunc = [](const std::string &key, const std::string &value, std::shared_ptr<VParseUrl> &parse) {
std::shared_ptr<ParseUrl<AppSetParamValue>> parseImpl = std::shared_ptr<ParseUrl<AppSetParamValue>> parseImpl =
std::dynamic_pointer_cast<ParseUrl<AppSetParamValue>>(parse); std::dynamic_pointer_cast<ParseUrl<AppSetParamValue>>(parse);
if ("switchcam" == key) { if ("param" == key) {
parseImpl->mData.mName = "switchcam"; parseImpl->mData.mName = value;
parseImpl->mData.mValue = std::stoi(value);
} }
if ("rec" == key) { if ("value" == key) {
parseImpl->mData.mName = "rec";
parseImpl->mData.mValue = std::stoi(value);
}
if ("mic" == key) {
parseImpl->mData.mName = "mic";
parseImpl->mData.mValue = std::stoi(value); parseImpl->mData.mValue = std::stoi(value);
} }
}; };
@ -1010,10 +1014,8 @@ std::shared_ptr<ProtocolPacket> SixFrameHandle::MakePacket(const cJSON *json)
if (nullptr != resultStr) { if (nullptr != resultStr) {
return std::make_shared<ProtocolPacket>(resultStr, strlen(resultStr)); return std::make_shared<ProtocolPacket>(resultStr, strlen(resultStr));
} }
else {
LogError("MakePacket failed.\n"); LogError("MakePacket failed.\n");
return std::make_shared<ProtocolPacket>(); return std::make_shared<ProtocolPacket>();
}
} }
void SixFrameHandle::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) void SixFrameHandle::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
{ {

View File

@ -13,8 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "SixFrameMakePtr.h" #include "SixFrameMakePtr.h"
#include "AppManagerMakePtr.h"
#include "IAppProtocolHandle.h"
#include "ILog.h" #include "ILog.h"
#include "SixFrameHandle.h" #include "SixFrameHandle.h"
#include "StatusCode.h"
#include <memory>
bool CreateProtocolHandleImpl(void) bool CreateProtocolHandleImpl(void)
{ {
LogInfo("CreateProtocolHandleImpl SixFrameMakePtr.\n"); LogInfo("CreateProtocolHandleImpl SixFrameMakePtr.\n");

View File

@ -22,7 +22,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} LedControl Hal StatusCode Log) target_link_libraries(${TARGET_NAME} LedControl Hal StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
DeviceManager_code_check DeviceManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -42,6 +41,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/DeviceManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/DeviceManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -13,10 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "DeviceManager.h" #include "DeviceManager.h"
#include "IDeviceManager.h"
#include "ILog.h" #include "ILog.h"
#include "KeyManager.h" #include "KeyManager.h"
#include "LedManager.h" #include "LedManager.h"
#include <vector> #include "StatusCode.h"
#include <memory>
#include <string>
const StatusCode DeviceManager::Init(void) const StatusCode DeviceManager::Init(void)
{ {
KeyManager::GetInstance()->Init(); KeyManager::GetInstance()->Init();

View File

@ -14,7 +14,10 @@
*/ */
#include "DeviceManagerMakePtr.h" #include "DeviceManagerMakePtr.h"
#include "DeviceManager.h" #include "DeviceManager.h"
#include "IDeviceManager.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
bool CreateDeviceManagerModule(void) bool CreateDeviceManagerModule(void)
{ {
auto instance = std::make_shared<IDeviceManager>(); auto instance = std::make_shared<IDeviceManager>();

View File

@ -14,6 +14,9 @@
*/ */
#include "IDeviceManager.h" #include "IDeviceManager.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
#include <string>
void VKeyMonitor::KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs) void VKeyMonitor::KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs)
{ {
} }

View File

@ -13,7 +13,17 @@
* limitations under the License. * limitations under the License.
*/ */
#include "KeyManager.h" #include "KeyManager.h"
#include "IDeviceManager.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
// #include "KeyControl.h"
#include "StatusCode.h"
#include <chrono>
#include <map>
#include <memory>
#include <string>
#include <thread>
#include <utility>
std::shared_ptr<KeyManager> &KeyManager::GetInstance(std::shared_ptr<KeyManager> *impl) std::shared_ptr<KeyManager> &KeyManager::GetInstance(std::shared_ptr<KeyManager> *impl)
{ {
static auto instance = std::make_shared<KeyManager>(); static auto instance = std::make_shared<KeyManager>();

View File

@ -13,7 +13,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "LedManager.h" #include "LedManager.h"
#include "IDeviceManager.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "LedControl.h"
#include <chrono>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
std::shared_ptr<LedManager> &LedManager::GetInstance(std::shared_ptr<LedManager> *impl) std::shared_ptr<LedManager> &LedManager::GetInstance(std::shared_ptr<LedManager> *impl)
{ {
static auto instance = std::make_shared<LedManager>(); static auto instance = std::make_shared<LedManager>();

View File

@ -24,7 +24,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} sqlite3 StatusCode Log) target_link_libraries(${TARGET_NAME} sqlite3 StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
FilesManager_code_check FilesManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -36,12 +35,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/FilesManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/FilesManager
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make FilesManager_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
FilesManager_code_format FilesManager_code_format
@ -50,6 +43,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/FilesManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/FilesManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -14,9 +14,9 @@
*/ */
#ifndef FILES_DATABASE_H #ifndef FILES_DATABASE_H
#define FILES_DATABASE_H #define FILES_DATABASE_H
#include "StatusCode.h"
#include "FilesHandle.h" #include "FilesHandle.h"
#include "IFilesManager.h" #include "IFilesManager.h"
#include "StatusCode.h"
class FilesDatabase : public FilesHandle class FilesDatabase : public FilesHandle
{ {
public: public:

View File

@ -14,17 +14,14 @@
*/ */
#include "FilesHandle.h" #include "FilesHandle.h"
#include "ILog.h" #include "ILog.h"
#include <algorithm>
#include <cctype> #include <cctype>
#include <chrono> #include <chrono>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#include <fstream>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <sys/stat.h> #include <string>
#include <sys/types.h>
std::string FilesHandle::CreateFilePathName(const std::string &sourceFile) std::string FilesHandle::CreateFilePathName(const std::string &sourceFile)
{ {
const std::string ERROR_SUFFIX = ""; const std::string ERROR_SUFFIX = "";

View File

@ -13,7 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "FilesManagerImpl.h" #include "FilesManagerImpl.h"
#include "IStorageManager.h" #include "IFilesManager.h"
// #include "IStorageManager.h"
#include "FilesDatabase.h"
#include "StatusCode.h"
StatusCode FilesManagerImpl::Init(void) StatusCode FilesManagerImpl::Init(void)
{ {
FilesDatabase::Init(); FilesDatabase::Init();

View File

@ -13,8 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "FilesManagerMakePtr.h" #include "FilesManagerMakePtr.h"
#include "ILog.h"
#include "FilesManagerImpl.h" #include "FilesManagerImpl.h"
#include "IFilesManager.h"
#include "ILog.h"
#include "StatusCode.h"
#include <memory>
bool CreateFilesManagerModule(void) bool CreateFilesManagerModule(void)
{ {
auto instance = std::make_shared<IFilesManager>(); auto instance = std::make_shared<IFilesManager>();

View File

@ -14,6 +14,9 @@
*/ */
#include "IFilesManager.h" #include "IFilesManager.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
#include <string>
save_file_info::save_file_info(const std::string &fileName) : mFileName(fileName) save_file_info::save_file_info(const std::string &fileName) : mFileName(fileName)
{ {
} }

View File

@ -13,9 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "FilesDatabase.h" #include "FilesDatabase.h"
#include "FilesHandle.h"
#include "IFilesManager.h"
#include "ILog.h" #include "ILog.h"
#include "IStorageManager.h" #include "IStorageManager.h"
#include "SqliteHandle.h" #include "SqliteHandle.h"
#include "StatusCode.h"
#include <string>
void FilesDatabase::Init(void) void FilesDatabase::Init(void)
{ {
SqliteHandle::GetInstance()->Init(); SqliteHandle::GetInstance()->Init();

View File

@ -15,6 +15,8 @@
#include "SqliteHandle.h" #include "SqliteHandle.h"
#include "ILog.h" #include "ILog.h"
#include "sqlite3.h" #include "sqlite3.h"
#include <memory>
#include <stdio.h>
std::shared_ptr<SqliteHandle> &SqliteHandle::GetInstance(std::shared_ptr<SqliteHandle> *impl) std::shared_ptr<SqliteHandle> &SqliteHandle::GetInstance(std::shared_ptr<SqliteHandle> *impl)
{ {
static auto instance = std::make_shared<SqliteHandle>(); static auto instance = std::make_shared<SqliteHandle>();
@ -42,5 +44,4 @@ void SqliteHandle::Init(void)
} }
void SqliteHandle::UnInit(void) void SqliteHandle::UnInit(void)
{ {
} }

View File

@ -23,7 +23,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} UpgradeBase StatusCode Log) target_link_libraries(${TARGET_NAME} UpgradeBase StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
HuntingUpgrade_code_check HuntingUpgrade_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -43,6 +42,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/HuntingUpgrade
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -14,6 +14,8 @@
*/ */
#include "HuntingUpgradeImpl.h" #include "HuntingUpgradeImpl.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include "UpgradeBase.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -14,7 +14,10 @@
*/ */
#include "HuntingUpgradeMakePtr.h" #include "HuntingUpgradeMakePtr.h"
#include "HuntingUpgradeImpl.h" #include "HuntingUpgradeImpl.h"
#include "IHuntingUpgrade.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
bool CreateHuntingUpgradeModule(void) bool CreateHuntingUpgradeModule(void)
{ {
auto instance = std::make_shared<IHuntingUpgrade>(); auto instance = std::make_shared<IHuntingUpgrade>();

View File

@ -14,6 +14,8 @@
*/ */
#include "IHuntingUpgrade.h" #include "IHuntingUpgrade.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
std::shared_ptr<IHuntingUpgrade> &IHuntingUpgrade::GetInstance(std::shared_ptr<IHuntingUpgrade> *impl) std::shared_ptr<IHuntingUpgrade> &IHuntingUpgrade::GetInstance(std::shared_ptr<IHuntingUpgrade> *impl)
{ {
static auto instance = std::make_shared<IHuntingUpgrade>(); static auto instance = std::make_shared<IHuntingUpgrade>();

View File

@ -23,7 +23,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} LinuxApi ConfigBase StatusCode Log) target_link_libraries(${TARGET_NAME} LinuxApi ConfigBase StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
IpcConfig_code_check IpcConfig_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -35,12 +34,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/IpcConfig WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/IpcConfig
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make IpcConfig_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
IpcConfig_code_format IpcConfig_code_format
@ -49,6 +42,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/IpcConfig WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/IpcConfig
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -14,6 +14,9 @@
*/ */
#include "IIpcConfig.h" #include "IIpcConfig.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
#include <string>
working_time::working_time() : mHourFrom(0), mHourTo(0), mMinuteFrom(0), mMinuteTo(0) working_time::working_time() : mHourFrom(0), mHourTo(0), mMinuteFrom(0), mMinuteTo(0)
{ {
} }

View File

@ -13,13 +13,22 @@
* limitations under the License. * limitations under the License.
*/ */
#include "IpcConfigImpl.h" #include "IpcConfigImpl.h"
#include "ConfigBase.h"
#include "IIpcConfig.h"
#include "ILog.h" #include "ILog.h"
#include "LinuxApi.h" #include "LinuxApi.h"
#include <dirent.h> #include "StatusCode.h"
#include <chrono>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <string>
#include <thread>
#include <utility>
#define CHECK_MAP(map) (map.size() == 1 ? true : false) #define CHECK_MAP(map) (map.size() == 1 ? true : false)
const char *CONFIG_WIFI_SSID = "wifi_ssid"; const char *CONFIG_WIFI_SSID = "wifi_ssid";
const char *CONFIG_WIFI_SSID_DEFAULT = "Hunting 2024"; const char *CONFIG_WIFI_SSID_DEFAULT = "Hunting 2024";

View File

@ -13,8 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "IpcConfigMakePtr.h" #include "IpcConfigMakePtr.h"
#include "IIpcConfig.h"
#include "ILog.h" #include "ILog.h"
#include "IpcConfigImpl.h" #include "IpcConfigImpl.h"
#include "StatusCode.h"
#include <memory>
bool CreateIpcConfigModule(void) bool CreateIpcConfigModule(void)
{ {
auto instance = std::make_shared<IIpcConfig>(); auto instance = std::make_shared<IIpcConfig>();

View File

@ -31,7 +31,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} McuManager StatusCode Log) target_link_libraries(${TARGET_NAME} McuManager StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
McuAskBase_code_check McuAskBase_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -43,12 +42,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuAskBase WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuAskBase
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make McuAskBase_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
McuAskBase_code_format McuAskBase_code_format
@ -57,6 +50,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuAskBase WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuAskBase
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -13,7 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "McuAskBase.h" #include "McuAskBase.h"
#include "ILog.h" #include "IMcuManager.h"
#include <semaphore.h>
McuAskBase::McuAskBase(const McuAskBlock isBlock, const McuAskReply needReply, const unsigned int timeoutMs) McuAskBase::McuAskBase(const McuAskBlock isBlock, const McuAskReply needReply, const unsigned int timeoutMs)
: mIsBlock(isBlock), mNeedReply(needReply), mTimeout(timeoutMs) : mIsBlock(isBlock), mNeedReply(needReply), mTimeout(timeoutMs)
{ {

View File

@ -28,7 +28,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} UartDevice McuAskBase McuProtocol StatusCode Log) target_link_libraries(${TARGET_NAME} UartDevice McuAskBase McuProtocol StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
McuManager_code_check McuManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -40,12 +39,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuManager
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make McuManager_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
McuManager_code_format McuManager_code_format
@ -54,6 +47,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/McuManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -14,6 +14,9 @@
*/ */
#include "IMcuManager.h" #include "IMcuManager.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "StatusCode.h"
#include <memory>
mcu_ask_date_time::mcu_ask_date_time(const unsigned short year, const unsigned char mon, const unsigned char day, mcu_ask_date_time::mcu_ask_date_time(const unsigned short year, const unsigned char mon, const unsigned char day,
const unsigned char hour, const unsigned char min, const unsigned char second) const unsigned char hour, const unsigned char min, const unsigned char second)
: mYear(year), mMon(mon), mDay(day), mHour(hour), mMin(min), mSecond(second) : mYear(year), mMon(mon), mDay(day), mHour(hour), mMin(min), mSecond(second)

View File

@ -14,7 +14,19 @@
*/ */
#include "McuDevice.h" #include "McuDevice.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "McuProtocol.h"
#include "StatusCode.h"
#include "UartDevice.h"
#include <chrono>
#include <cstdlib>
#include <list>
#include <memory>
#include <mutex>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <thread>
constexpr int SLEEP_TIME_MS = 1000; constexpr int SLEEP_TIME_MS = 1000;
constexpr bool REMOVE_THE_ASK = true; constexpr bool REMOVE_THE_ASK = true;
constexpr bool KEEP_THE_ASK = false; constexpr bool KEEP_THE_ASK = false;

View File

@ -14,7 +14,19 @@
*/ */
#include "McuManagerImpl.h" #include "McuManagerImpl.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "McuAskBase.h" #include "McuAskBase.h"
#include "McuDevice.h"
#include "McuProtocol.h"
#include "StatusCode.h"
#include <chrono>
#include <condition_variable>
#include <functional>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <thread>
class McuRecvImpl class McuRecvImpl
{ {
public: public:

View File

@ -14,7 +14,10 @@
*/ */
#include "McuManagerMakePtr.h" #include "McuManagerMakePtr.h"
#include "ILog.h" #include "ILog.h"
#include "IMcuManager.h"
#include "McuManagerImpl.h" #include "McuManagerImpl.h"
#include "StatusCode.h"
#include <memory>
bool CreateMcuManager(void) bool CreateMcuManager(void)
{ {
auto instance = std::make_shared<IMcuManager>(); auto instance = std::make_shared<IMcuManager>();

View File

@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "UartRecvAsk.h" #include "UartRecvAsk.h"
#include "McuAskBase.h"
UartRecvAsk::UartRecvAsk() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY) UartRecvAsk::UartRecvAsk() : McuAskBase(McuAskBlock::NOT_BLOCK, McuAskReply::NEED_REPLY)
{ {
} }

View File

@ -29,7 +29,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} Hal StatusCode Log) target_link_libraries(${TARGET_NAME} Hal StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
MediaManager_code_check MediaManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -41,12 +40,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/MediaManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/MediaManager
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make MediaManager_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
MediaManager_code_format MediaManager_code_format
@ -55,6 +48,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/MediaManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/MediaManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -14,6 +14,10 @@
*/ */
#include "IMediaManager.h" #include "IMediaManager.h"
#include "ILog.h" #include "ILog.h"
#include "StatusCode.h"
#include <memory>
#include <string>
#include <vector>
media_report_event::media_report_event(const std::string &fileName, const MediaChannel &mediaChannedl) media_report_event::media_report_event(const std::string &fileName, const MediaChannel &mediaChannedl)
: mFileName(fileName), mMediaChannedl(mediaChannedl) : mFileName(fileName), mMediaChannedl(mediaChannedl)
{ {

View File

@ -13,11 +13,48 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MediaHandle.h" #include "MediaHandle.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h"
#include "SaveStream.h"
#include "StatusCode.h"
#include <chrono>
#include <functional>
#include <memory>
#include <mutex>
#include <thread>
#include <vector>
MediaHandle::MediaHandle(const MediaChannel &mediaChannel, const std::shared_ptr<VCameraHal> &cameraHal) MediaHandle::MediaHandle(const MediaChannel &mediaChannel, const std::shared_ptr<VCameraHal> &cameraHal)
: mMediaChannel(mediaChannel), mCameraHal(cameraHal) : mMediaChannel(mediaChannel), mCameraHal(cameraHal), mTaskRuning(false)
{ {
} }
void MediaHandle::Init(void)
{
if (mCameraHal == nullptr) {
LogError("CameraHal is null.\n");
return;
}
auto audioFunc = std::bind(&MediaHandle::GetAudioStreamCallback, this, _1, _2, _3);
mCameraHal->SetAudioStreamCallback(audioFunc);
auto videoFunc = std::bind(&MediaHandle::GetVideoStreamCallback, this, _1, _2, _3);
mCameraHal->SetVideoStreamCallback(videoFunc);
}
void MediaHandle::UnInit(void)
{
mTaskRuning = false;
mCv.notify_one();
if (mTaskTimerThread.joinable()) {
mTaskTimerThread.join();
}
if (mCameraHal) {
/**
* @brief Before releasing the class instance, it is necessary to call the UnInit function to ensure that the
* callback function is cleared elsewhere, otherwise it will crash.
*/
mCameraHal->SetAudioStreamCallback(nullptr);
mCameraHal->SetVideoStreamCallback(nullptr);
}
}
StatusCode MediaHandle::ExecuteTask(std::shared_ptr<VMediaTask> &task) StatusCode MediaHandle::ExecuteTask(std::shared_ptr<VMediaTask> &task)
{ {
std::lock_guard<std::mutex> locker(mMutex); std::lock_guard<std::mutex> locker(mMutex);
@ -29,11 +66,18 @@ StatusCode MediaHandle::ExecuteTask(std::shared_ptr<VMediaTask> &task)
return CreateStatusCode(STATUS_CODE_NOT_OK); return CreateStatusCode(STATUS_CODE_NOT_OK);
} }
} }
mStreamHandle = std::make_shared<SaveStream>();
if (nullptr == mStreamHandle) {
LogError("Create stream handle failed.\n");
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
mStreamHandle->Init();
CameraTaskType taskType = TaskTypeConvert(task->GetTaskType()); CameraTaskType taskType = TaskTypeConvert(task->GetTaskType());
CameraTaskParam data(taskType); CameraTaskParam data(taskType);
auto code = mCameraHal->StartSingleTask(data); auto code = mCameraHal->StartSingleTask(data);
if (IsCodeOK(code)) { if (IsCodeOK(code)) {
mCurrentTask = task; mCurrentTask = task;
StartTaskTimer();
} }
else { else {
LogError("Execute task failed.\n"); LogError("Execute task failed.\n");
@ -48,7 +92,53 @@ StatusCode MediaHandle::ClearTask(void)
{ {
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
void MediaHandle::StartTaskTimer(void)
{
auto taskTimerThread = [=](std::shared_ptr<MediaHandle> media) {
LogInfo("StartTaskTimer start.\n");
media->TaskTimer();
};
std::shared_ptr<MediaHandle> media = shared_from_this();
mTaskTimerThread = std::thread(taskTimerThread, media);
}
void MediaHandle::TaskTimer(void)
{
constexpr int TASK_TIMER = 1000 * 10;
mTaskRuning = true;
while (mTaskRuning) {
std::unique_lock<std::mutex> lock(mMutex);
mCv.wait_for(lock, std::chrono::milliseconds(TASK_TIMER), [&] {
return !mTaskRuning;
});
/**
* @brief If the recording time is over, you need to stop the recording timer here.
*/
mTaskRuning = false;
}
if (mCameraHal) {
mCameraHal->StopTask();
}
mMutex.lock();
auto runingTask = mCurrentTask.lock();
if (mCurrentTask.expired()) {
LogWarning("SdCardHal: monitor is expired.\n");
return;
}
LogInfo("Task finished response to application.\n");
std::vector<MediaTaskResponse> responses;
runingTask->Response(responses);
mCurrentTask.reset();
mMutex.unlock();
}
CameraTaskType MediaHandle::TaskTypeConvert(const MediaTaskType &type) CameraTaskType MediaHandle::TaskTypeConvert(const MediaTaskType &type)
{ {
return CameraTaskType::END; return CameraTaskType::END;
} }
void MediaHandle::GetVideoStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp)
{
mStreamHandle->GetVideoStream(stream, length, timeStamp);
}
void MediaHandle::GetAudioStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp)
{
mStreamHandle->GetAudioStream(stream, length, timeStamp);
}

View File

@ -16,23 +16,41 @@
#define MEDI_AHANDLE_H #define MEDI_AHANDLE_H
#include "IHalCpp.h" #include "IHalCpp.h"
#include "IMediaManager.h" #include "IMediaManager.h"
#include "VStreamHandle.h"
#include <condition_variable>
#include <mutex> #include <mutex>
#include <thread>
using std::placeholders::_1;
using std::placeholders::_2;
using std::placeholders::_3;
class MediaHandle : public VMediaHandle, public std::enable_shared_from_this<MediaHandle> class MediaHandle : public VMediaHandle, public std::enable_shared_from_this<MediaHandle>
{ {
public: public:
MediaHandle(const MediaChannel &mediaChannel, const std::shared_ptr<VCameraHal> &cameraHal); MediaHandle(const MediaChannel &mediaChannel, const std::shared_ptr<VCameraHal> &cameraHal);
virtual ~MediaHandle() = default; virtual ~MediaHandle() = default;
void Init(void);
void UnInit(void);
protected:
StatusCode ExecuteTask(std::shared_ptr<VMediaTask> &task) override; StatusCode ExecuteTask(std::shared_ptr<VMediaTask> &task) override;
StatusCode StopTask(void) override; StatusCode StopTask(void) override;
StatusCode ClearTask(void) override; StatusCode ClearTask(void) override;
private: private:
void StartTaskTimer(void);
void TaskTimer(void);
CameraTaskType TaskTypeConvert(const MediaTaskType &type); CameraTaskType TaskTypeConvert(const MediaTaskType &type);
void GetVideoStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp);
void GetAudioStreamCallback(const void *stream, const int &length, const unsigned long long &timeStamp);
private: private:
std::mutex mMutex; std::mutex mMutex;
std::condition_variable mCv;
const MediaChannel &mMediaChannel; const MediaChannel &mMediaChannel;
std::shared_ptr<VCameraHal> mCameraHal; std::shared_ptr<VCameraHal> mCameraHal;
std::weak_ptr<VMediaTask> mCurrentTask; std::weak_ptr<VMediaTask> mCurrentTask;
std::shared_ptr<VStreamHandle> mStreamHandle;
bool mTaskRuning;
std::thread mTaskTimerThread;
}; };
#endif #endif

View File

@ -13,8 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include "MediaManagerImpl.h" #include "MediaManagerImpl.h"
#include "IHalCpp.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h"
#include "MediaHandle.h" #include "MediaHandle.h"
#include "StatusCode.h"
#include <map>
#include <memory>
#include <string>
StatusCode MediaManagerImpl::Init(void) StatusCode MediaManagerImpl::Init(void)
{ {
IHalCpp::GetInstance()->GetCameraHal(mAllCameras); IHalCpp::GetInstance()->GetCameraHal(mAllCameras);
@ -23,6 +29,7 @@ StatusCode MediaManagerImpl::Init(void)
} }
StatusCode MediaManagerImpl::UnInit(void) StatusCode MediaManagerImpl::UnInit(void)
{ {
UnInitMediaHandles();
return CreateStatusCode(STATUS_CODE_OK); return CreateStatusCode(STATUS_CODE_OK);
} }
StatusCode MediaManagerImpl::GetMediaChannel(const MediaChannel &channel, std::shared_ptr<VMediaHandle> &handle) StatusCode MediaManagerImpl::GetMediaChannel(const MediaChannel &channel, std::shared_ptr<VMediaHandle> &handle)
@ -76,8 +83,21 @@ void MediaManagerImpl::InitMediaHandles(std::map<CameraType, std::shared_ptr<VCa
continue; continue;
} }
MediaChannel channel = static_cast<MediaChannel>(i); MediaChannel channel = static_cast<MediaChannel>(i);
std::shared_ptr<VMediaHandle> media = std::make_shared<MediaHandle>(channel, camera->second); std::shared_ptr<MediaHandle> media = std::make_shared<MediaHandle>(channel, camera->second);
media->Init();
mAllMediaChannels[channel] = media; mAllMediaChannels[channel] = media;
LogInfo("InitMediaHandles. channel = %d \n", static_cast<MediaChannel>(i)); LogInfo("InitMediaHandles. channel = %d \n", static_cast<MediaChannel>(i));
} }
} }
void MediaManagerImpl::UnInitMediaHandles(void)
{
for (auto &media : mAllMediaChannels) {
LogInfo("UnInitMediaHandles. channel = %d \n", media.first);
std::shared_ptr<MediaHandle> mediaImpl = std::dynamic_pointer_cast<MediaHandle>(media.second);
if (nullptr == mediaImpl) {
LogWarning("mediaImpl is null.\n");
continue;
}
mediaImpl->UnInit();
}
}

View File

@ -33,6 +33,7 @@ public:
private: private:
void SetCamerasMonitor(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras); void SetCamerasMonitor(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras);
void InitMediaHandles(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras); void InitMediaHandles(std::map<CameraType, std::shared_ptr<VCameraHal>> &allCameras);
void UnInitMediaHandles(void);
private: private:
std::map<CameraType, std::shared_ptr<VCameraHal>> mAllCameras; std::map<CameraType, std::shared_ptr<VCameraHal>> mAllCameras;

View File

@ -14,7 +14,10 @@
*/ */
#include "MediaManagerMakePtr.h" #include "MediaManagerMakePtr.h"
#include "ILog.h" #include "ILog.h"
#include "IMediaManager.h"
#include "MediaManagerImpl.h" #include "MediaManagerImpl.h"
#include "StatusCode.h"
#include <memory>
bool CreateMediaManagerModule(void) bool CreateMediaManagerModule(void)
{ {
auto instance = std::make_shared<IMediaManager>(); auto instance = std::make_shared<IMediaManager>();

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Fancy Code.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this mFileAudio 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.
*/
#include "SaveStream.h"
#include "ILog.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
SaveStream::SaveStream() : mFileAudio(nullptr), mFileVideo(nullptr)
{
}
void SaveStream::Init(void)
{
mFileAudio = fopen("./audio.g711", "a+"); // TODO:
mFileVideo = fopen("./video.h264", "a+"); // TODO:
}
void SaveStream::UnInit(void)
{
if (mFileAudio) {
fclose(mFileAudio);
mFileAudio = nullptr;
}
if (mFileVideo) {
fclose(mFileVideo);
mFileVideo = nullptr;
}
}
void SaveStream::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{
if (mFileVideo) {
// LogInfo("Get video stream, length: %d\n", length);
size_t writeLength = fwrite(stream, 1, length, mFileVideo);
if (writeLength != length) {
LogError("Write video stream failed.\n");
}
fflush(mFileVideo);
}
}
void SaveStream::GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{
if (mFileAudio) {
// LogInfo("Get audio stream, length: %d\n", length);
size_t writeLength = fwrite(stream, 1, length, mFileAudio);
if (writeLength != length) {
LogError("Write video stream failed.\n");
}
fflush(mFileAudio);
}
}

View File

@ -0,0 +1,33 @@
/*
* 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 SAVE_STREAM_H
#define SAVE_STREAM_H
#include "VStreamHandle.h"
#include <cstdio>
class SaveStream : public VStreamHandle
{
public:
SaveStream();
virtual ~SaveStream() = default;
void Init(void) override;
void UnInit(void) override;
void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
private:
FILE *mFileAudio;
FILE *mFileVideo;
};
#endif

View File

@ -0,0 +1,27 @@
/*
* 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.
*/
#include "VStreamHandle.h"
void VStreamHandle::Init(void)
{
}
void VStreamHandle::UnInit(void)
{
}
void VStreamHandle::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{
}
void VStreamHandle::GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{
}

View File

@ -0,0 +1,27 @@
/*
* 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 V_STREAM_HANDLE_H
#define V_STREAM_HANDLE_H
class VStreamHandle
{
public:
VStreamHandle() = default;
virtual ~VStreamHandle() = default;
virtual void Init(void);
virtual void UnInit(void);
virtual void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
virtual void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
};
#endif

View File

@ -23,7 +23,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES} ${SRC_FILES_OPENHARMONY})
target_link_libraries(${TARGET_NAME} Log) target_link_libraries(${TARGET_NAME} Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
StateMachine_code_check StateMachine_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -35,12 +34,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StateMachine WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StateMachine
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make StateMachine_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
StateMachine_code_format StateMachine_code_format
@ -49,6 +42,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StateMachine WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StateMachine
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

View File

@ -14,7 +14,10 @@
*/ */
#include "IStateMachine.h" #include "IStateMachine.h"
#include "ILog.h" #include "ILog.h"
#include <thread> #include "StatusCode.h"
#include <cstdint>
#include <memory>
#include <string>
std::string State::GetStateName() std::string State::GetStateName()
{ {
return mStateName; return mStateName;

View File

@ -13,7 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "StateMachineImpl.h" #include "StateMachineImpl.h"
#include "IStateMachine.h"
#include "StateMachineMakePtr.h" #include "StateMachineMakePtr.h"
#include "StatusCode.h"
#include <memory>
const StatusCode StateMachineImpl::CreateStateMachine(std::shared_ptr<VStateMachineHandle> &stateMachine) const StatusCode StateMachineImpl::CreateStateMachine(std::shared_ptr<VStateMachineHandle> &stateMachine)
{ {
return StateMachineMakePtr::GetInstance()->CreateStateMachine(stateMachine); return StateMachineMakePtr::GetInstance()->CreateStateMachine(stateMachine);

View File

@ -16,8 +16,10 @@
#include "ILog.h" #include "ILog.h"
#include "IStateMachine.h" #include "IStateMachine.h"
#include "StateMachineImpl.h" #include "StateMachineImpl.h"
#include "StatusCode.h"
#include "state_machine.h" #include "state_machine.h"
#include <thread> #include <memory>
#include <utility>
bool CreateStateMachine(void) bool CreateStateMachine(void)
{ {
auto instance = std::make_shared<IStateMachine>(); auto instance = std::make_shared<IStateMachine>();

View File

@ -26,7 +26,6 @@ add_library(${TARGET_NAME} STATIC ${SRC_FILES})
target_link_libraries(${TARGET_NAME} StatusCode Log) target_link_libraries(${TARGET_NAME} StatusCode Log)
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_target( add_custom_target(
StorageManager_code_check StorageManager_code_check
COMMAND ${CLANG_TIDY_EXE} COMMAND ${CLANG_TIDY_EXE}
@ -38,12 +37,6 @@ add_custom_target(
-p ${PLATFORM_PATH}/cmake-shell -p ${PLATFORM_PATH}/cmake-shell
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StorageManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StorageManager
) )
add_custom_command(
TARGET ${TARGET_NAME}
PRE_BUILD
COMMAND make StorageManager_code_check
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
)
file(GLOB_RECURSE HEADER_FILES *.h) file(GLOB_RECURSE HEADER_FILES *.h)
add_custom_target( add_custom_target(
StorageManager_code_format StorageManager_code_format
@ -52,6 +45,7 @@ add_custom_target(
-i ${SRC_FILES} ${HEADER_FILES} -i ${SRC_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StorageManager WORKING_DIRECTORY ${MIDDLEWARE_SOURCE_PATH}/StorageManager
) )
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} TARGET ${TARGET_NAME}
PRE_BUILD PRE_BUILD

Some files were not shown because too many files have changed in this diff Show More