Improve:SifxFrame app test.
This commit is contained in:
parent
b68ef7834a
commit
5ba829db67
|
@ -20,6 +20,19 @@
|
||||||
#include "IMissionManager.h"
|
#include "IMissionManager.h"
|
||||||
#include "IStateMachine.h"
|
#include "IStateMachine.h"
|
||||||
#include <thread>
|
#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; }
|
MainThread::MainThread() { mMainThreadRuning = false; }
|
||||||
std::shared_ptr<MainThread> &MainThread::GetInstance(std::shared_ptr<MainThread> *impl)
|
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)
|
StatusCode MainThread::Init(void)
|
||||||
{
|
{
|
||||||
|
InitSignalHandle();
|
||||||
CreateLogModule();
|
CreateLogModule();
|
||||||
ILogInit(LOG_EASYLOGGING);
|
ILogInit(LOG_EASYLOGGING);
|
||||||
CustomizationInit();
|
CustomizationInit();
|
||||||
|
|
|
@ -40,9 +40,9 @@ StatusCode AppMonitor::GetDeviceAttr(AppGetDeviceAttr ¶m)
|
||||||
StatusCode AppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m)
|
StatusCode AppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m)
|
||||||
{
|
{
|
||||||
LogInfo("AppMonitor::GetMediaInfo.\n");
|
LogInfo("AppMonitor::GetMediaInfo.\n");
|
||||||
param.mRtspUrl = "test";
|
param.mRtspUrl = "rtsp://192.168.169.1/stream.mp4";
|
||||||
param.mTransport = "test";
|
param.mTransport = "tcp";
|
||||||
param.mPort = 123;
|
param.mPort = 6035;
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
StatusCode AppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
StatusCode AppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m)
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
#include "LinuxApi.h"
|
#include "LinuxApi.h"
|
||||||
StatusCode WifiHal::OpenApMode(void)
|
StatusCode WifiHal::OpenApMode(void)
|
||||||
{
|
{
|
||||||
fx_system("ifconfig wlan0 192.168.169.1 netmask 255.255.255.0");
|
// fx_system("ifconfig wlan0 192.168.169.1 netmask 255.255.255.0");
|
||||||
fx_system("hostapd -d /etc/hostapd.conf &");
|
// fx_system("hostapd -d /etc/hostapd.conf &");
|
||||||
fx_system("touch /var/lib/misc/udhcpd.leases");
|
// fx_system("touch /var/lib/misc/udhcpd.leases");
|
||||||
fx_system("udhcpd -f /etc/udhcpd.conf &");
|
// fx_system("udhcpd -f /etc/udhcpd.conf &");
|
||||||
return CreateStatusCode(STATUS_CODE_OK);
|
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)
|
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)
|
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)
|
void SixFrameHandle::RequestGetMediaInfo(const std::string &url, ResponseHandle responseHandle, void *context)
|
||||||
{
|
{
|
||||||
LogInfo("RequestGetDeviceAttr.\n");
|
LogInfo("RequestGetMediaInfo.\n");
|
||||||
char *resultStr = nullptr;
|
char *resultStr = nullptr;
|
||||||
AppGetMeidaInfo param;
|
AppGetMeidaInfo param;
|
||||||
mAppMonitor->GetMediaInfo(param);
|
mAppMonitor->GetMediaInfo(param);
|
||||||
|
@ -157,6 +162,7 @@ void SixFrameHandle::RequestGetMediaInfo(const std::string &url, ResponseHandle
|
||||||
ResponseGetMediaInfo(result, param);
|
ResponseGetMediaInfo(result, param);
|
||||||
resultStr = cJSON_Print(result);
|
resultStr = cJSON_Print(result);
|
||||||
responseHandle(resultStr, context);
|
responseHandle(resultStr, context);
|
||||||
|
LogInfo("resultStr = \n%s\n", resultStr);
|
||||||
free(resultStr);
|
free(resultStr);
|
||||||
cJSON_Delete(result);
|
cJSON_Delete(result);
|
||||||
}
|
}
|
||||||
|
@ -164,9 +170,9 @@ void inline SixFrameHandle::ResponseGetMediaInfo(cJSON *result, const AppGetMeid
|
||||||
{
|
{
|
||||||
cJSON *info = nullptr;
|
cJSON *info = nullptr;
|
||||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info = cJSON_CreateObject());
|
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info = cJSON_CreateObject());
|
||||||
cJSON_AddStringToObject(info, "uuid", param.mRtspUrl.c_str());
|
cJSON_AddStringToObject(info, "rtsp", param.mRtspUrl.c_str());
|
||||||
cJSON_AddStringToObject(info, "softver", param.mTransport.c_str());
|
cJSON_AddStringToObject(info, "transport", param.mTransport.c_str());
|
||||||
cJSON_AddNumberToObject(info, "otaver", param.mPort);
|
cJSON_AddNumberToObject(info, "port", param.mPort);
|
||||||
}
|
}
|
||||||
void SixFrameHandle::RequestGetSdCardInfo(const std::string &url, ResponseHandle responseHandle, void *context)
|
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/")
|
set(GOAHEAD_CONFIG_FILE_PATH "${PLATFORM_PATH}/cmake-shell/")
|
||||||
add_definitions(-DGOAHEAD_CONFIG_FILE_PATH=\"./\")
|
add_definitions(-DGOAHEAD_CONFIG_FILE_PATH=\"./\")
|
||||||
else()
|
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()
|
endif()
|
||||||
add_definitions(-DGOAHEAD_DOCUMENTS_PATH=\"${GOAHEAD_DOCUMENTS_PATH}\")
|
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(routePath, BUF_LENGTH, "%s/route.txt", GOAHEAD_CONFIG_FILE_PATH);
|
||||||
snprintf(authPath, BUF_LENGTH, "%s/auth.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);
|
snprintf(listen, BUF_LENGTH, "%s:%d", webParam.mIp, webParam.mPort);
|
||||||
initPlatform();
|
// initPlatform();
|
||||||
if (websOpen(documents, routePath) < 0) {
|
if (websOpen(documents, routePath) < 0) {
|
||||||
LogError("Cannot initialize server. Exiting.\n");
|
LogError("Cannot initialize server. Exiting.\n");
|
||||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user