mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Improve:SifxFrame app test.
This commit is contained in:
parent
b68ef7834a
commit
5ba829db67
|
@ -20,6 +20,19 @@
|
|||
#include "IMissionManager.h"
|
||||
#include "IStateMachine.h"
|
||||
#include <thread>
|
||||
#include <signal.h>
|
||||
static void sigHandler(int signo)
|
||||
{
|
||||
LogInfo("Stop main application.\n");
|
||||
MainThread::GetInstance()->Exit();
|
||||
}
|
||||
void InitSignalHandle(void)
|
||||
{
|
||||
signal(SIGINT, sigHandler);
|
||||
signal(SIGTERM, sigHandler);
|
||||
signal(SIGKILL, sigHandler);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
}
|
||||
MainThread::MainThread() { mMainThreadRuning = false; }
|
||||
std::shared_ptr<MainThread> &MainThread::GetInstance(std::shared_ptr<MainThread> *impl)
|
||||
{
|
||||
|
@ -37,6 +50,7 @@ std::shared_ptr<MainThread> &MainThread::GetInstance(std::shared_ptr<MainThread>
|
|||
}
|
||||
StatusCode MainThread::Init(void)
|
||||
{
|
||||
InitSignalHandle();
|
||||
CreateLogModule();
|
||||
ILogInit(LOG_EASYLOGGING);
|
||||
CustomizationInit();
|
||||
|
|
|
@ -40,9 +40,9 @@ StatusCode AppMonitor::GetDeviceAttr(AppGetDeviceAttr ¶m)
|
|||
StatusCode AppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m)
|
||||
{
|
||||
LogInfo("AppMonitor::GetMediaInfo.\n");
|
||||
param.mRtspUrl = "test";
|
||||
param.mTransport = "test";
|
||||
param.mPort = 123;
|
||||
param.mRtspUrl = "rtsp://192.168.169.1/stream.mp4";
|
||||
param.mTransport = "tcp";
|
||||
param.mPort = 6035;
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode AppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#include "LinuxApi.h"
|
||||
StatusCode WifiHal::OpenApMode(void)
|
||||
{
|
||||
fx_system("ifconfig wlan0 192.168.169.1 netmask 255.255.255.0");
|
||||
fx_system("hostapd -d /etc/hostapd.conf &");
|
||||
fx_system("touch /var/lib/misc/udhcpd.leases");
|
||||
fx_system("udhcpd -f /etc/udhcpd.conf &");
|
||||
// fx_system("ifconfig wlan0 192.168.169.1 netmask 255.255.255.0");
|
||||
// fx_system("hostapd -d /etc/hostapd.conf &");
|
||||
// fx_system("touch /var/lib/misc/udhcpd.leases");
|
||||
// fx_system("udhcpd -f /etc/udhcpd.conf &");
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
|
@ -95,8 +95,13 @@ void SixFrameHandle::RequestHandle2(const std::string command, const std::string
|
|||
}
|
||||
void SixFrameHandle::DoNothing(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
//
|
||||
responseHandle("Unknown command.", context);
|
||||
// responseHandle("Unknown command.", context);
|
||||
char *resultStr = nullptr;
|
||||
cJSON *result = MakeResponseResult(ResposeResult::FAILED);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void SixFrameHandle::RequestGetProductInfo(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
|
@ -149,7 +154,7 @@ void inline SixFrameHandle::ResponseGetDeviceAttr(cJSON *result, const AppGetDev
|
|||
}
|
||||
void SixFrameHandle::RequestGetMediaInfo(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
LogInfo("RequestGetDeviceAttr.\n");
|
||||
LogInfo("RequestGetMediaInfo.\n");
|
||||
char *resultStr = nullptr;
|
||||
AppGetMeidaInfo param;
|
||||
mAppMonitor->GetMediaInfo(param);
|
||||
|
@ -157,6 +162,7 @@ void SixFrameHandle::RequestGetMediaInfo(const std::string &url, ResponseHandle
|
|||
ResponseGetMediaInfo(result, param);
|
||||
resultStr = cJSON_Print(result);
|
||||
responseHandle(resultStr, context);
|
||||
LogInfo("resultStr = \n%s\n", resultStr);
|
||||
free(resultStr);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
|
@ -164,9 +170,9 @@ void inline SixFrameHandle::ResponseGetMediaInfo(cJSON *result, const AppGetMeid
|
|||
{
|
||||
cJSON *info = nullptr;
|
||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info = cJSON_CreateObject());
|
||||
cJSON_AddStringToObject(info, "uuid", param.mRtspUrl.c_str());
|
||||
cJSON_AddStringToObject(info, "softver", param.mTransport.c_str());
|
||||
cJSON_AddNumberToObject(info, "otaver", param.mPort);
|
||||
cJSON_AddStringToObject(info, "rtsp", param.mRtspUrl.c_str());
|
||||
cJSON_AddStringToObject(info, "transport", param.mTransport.c_str());
|
||||
cJSON_AddNumberToObject(info, "port", param.mPort);
|
||||
}
|
||||
void SixFrameHandle::RequestGetSdCardInfo(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ if (NOT DEFINED GOAHEAD_CONFIG_FILE_PATH)
|
|||
set(GOAHEAD_CONFIG_FILE_PATH "${PLATFORM_PATH}/cmake-shell/")
|
||||
add_definitions(-DGOAHEAD_CONFIG_FILE_PATH=\"./\")
|
||||
else()
|
||||
add_definitions(-DGOAHEAD_CONFIG_FILE_PATH=\"${GOAHEAD_CONFIG_FILE_PATH}\")
|
||||
add_definitions(-DGOAHEAD_CONFIG_FILE_PATH=\"${GOAHEAD_CONFIG_FILE_PATH}\") # 代码中使用该宏定义下的配置文件
|
||||
set(GOAHEAD_CONFIG_FILE_PATH "${PLATFORM_PATH}/cmake-shell/") # CMakeLists.txt文件会把配置文件拷贝到此目录
|
||||
endif()
|
||||
add_definitions(-DGOAHEAD_DOCUMENTS_PATH=\"${GOAHEAD_DOCUMENTS_PATH}\")
|
||||
|
|
|
@ -139,7 +139,7 @@ StatusCode WebServerInit(const WebServerParam webParam)
|
|||
snprintf(routePath, BUF_LENGTH, "%s/route.txt", GOAHEAD_CONFIG_FILE_PATH);
|
||||
snprintf(authPath, BUF_LENGTH, "%s/auth.txt", GOAHEAD_CONFIG_FILE_PATH);
|
||||
snprintf(listen, BUF_LENGTH, "%s:%d", webParam.mIp, webParam.mPort);
|
||||
initPlatform();
|
||||
// initPlatform();
|
||||
if (websOpen(documents, routePath) < 0) {
|
||||
LogError("Cannot initialize server. Exiting.\n");
|
||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
|
|
Loading…
Reference in New Issue
Block a user