Commit f81fc9a1 authored by 957dd's avatar 957dd

加入了验证清空功能

parent 41cc8add
...@@ -153,7 +153,10 @@ void *thread_open_browser(void *arg) ...@@ -153,7 +153,10 @@ void *thread_open_browser(void *arg)
// 进程未运行,启动它 // 进程未运行,启动它
my_zlog_info("启动 go_video 程序并跳过浏览器"); my_zlog_info("启动 go_video 程序并跳过浏览器");
system("sudo -u orangepi nohup /home/orangepi/go_video/go_video > /dev/null 2>&1 &"); int res=system("sudo -u orangepi nohup /home/orangepi/go_video/go_video > /dev/null 2>&1 &");
if(res!=0){
my_zlog_error("启动 go_video 失败");
}
return NULL; return NULL;
} }
...@@ -162,7 +165,7 @@ void *thread_open_browser(void *arg) ...@@ -162,7 +165,7 @@ void *thread_open_browser(void *arg)
{ {
my_zlog_error("system error"); my_zlog_error("system error");
} }
delay_s(5); delay_s(5);
while (1) while (1)
{ {
......
No preview for this file type
...@@ -376,6 +376,10 @@ int device_message_receive(cJSON *json) ...@@ -376,6 +376,10 @@ int device_message_receive(cJSON *json)
control_pthread_function("close"); control_pthread_function("close");
my_zlog_debug("关闭控制台推送"); my_zlog_debug("关闭控制台推送");
break; break;
case 2016:
mqtt_verify_data_clear(body);
my_zlog_debug("清除验证数据");
break;
case 2025: case 2025:
receive_self_contorl_mqtt(body); receive_self_contorl_mqtt(body);
my_zlog_debug("device self comtrol"); my_zlog_debug("device self comtrol");
......
...@@ -17,7 +17,7 @@ bool VERIFIED_MODE=FALSE; ...@@ -17,7 +17,7 @@ bool VERIFIED_MODE=FALSE;
bool g_service_verify=TRUE;//验证判断 bool g_service_verify=TRUE;//验证判断
int g_verify_count =12000;//判断是否有一分钟 int g_verify_count =6000;//判断是否有一分钟
char g_only_id_middle[11]; char g_only_id_middle[11];
...@@ -239,4 +239,65 @@ int verify_open_index_init(){ ...@@ -239,4 +239,65 @@ int verify_open_index_init(){
} }
return 0; return 0;
} }
\ No newline at end of file
int mqtt_verify_clear_send(char *status){
cJSON *root = cJSON_CreateObject();
cJSON *body = cJSON_CreateObject();
cJSON *head = cJSON_CreateObject();
// 设置body字段
cJSON_AddStringToObject(body, "verify_clear_item", "clear");
cJSON_AddStringToObject(body, "verify_clear_status", status);
// 设置head字段
cJSON_AddNumberToObject(head, "message_type", 3021);
// 将body和head添加到根对象
cJSON_AddItemToObject(root, "body", body);
cJSON_AddItemToObject(root, "head", head);
// 生成JSON字符串
char *payload = cJSON_PrintUnformatted(root);
if(payload==NULL){
my_zlog_debug("send verify am null");
return -1;
}
my_zlog_debug("%s",payload);
for(int i=0;i<g_mqtt_cam_config_t->mqtt_count;i++){
mosquitto_publish(g_clients_t[i].mosq, NULL, mqtt_topic_pure_number(), strlen(payload), payload, 0, false);
}
cJSON_Delete(root); // 释放 cJSON 对象
return 0;
}
void mqtt_verify_data_clear(cJSON *body){
cJSON *verify_clear_item = cJSON_GetObjectItem(body, "verify_clear_item");
if (verify_clear_item != NULL && cJSON_IsString(verify_clear_item)) {
const char *status = verify_clear_item->valuestring;
if (strcmp(status, "clear") == 0) {
my_zlog_info("状态为 clear,执行清理操作");
pthread_mutex_lock(&g_verify_mutex);
g_verify_count = 12001;
pthread_mutex_unlock(&g_verify_mutex);
// 执行清理逻辑
mqtt_verify_clear_send("1");
} else {
my_zlog_info("状态为: %s", status);
mqtt_verify_clear_send("0");
}
} else {
my_zlog_info("verify_clear_item 字段不存在或不是字符串类型");
mqtt_verify_clear_send("2");
}
}
...@@ -23,4 +23,6 @@ int message2013_recverigy_open(cJSON *body); ...@@ -23,4 +23,6 @@ int message2013_recverigy_open(cJSON *body);
/*发送是否打开验证的mqtt给后端验证初始化*/ /*发送是否打开验证的mqtt给后端验证初始化*/
int verify_open_index_init(); int verify_open_index_init();
void mqtt_verify_data_clear(cJSON *body);
#endif #endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment