Commit 86932e76 authored by 957dd's avatar 957dd

加入控制台推送,未完成

parent 1201386e
No preview for this file type
...@@ -124,6 +124,8 @@ const gpiocontrol_t gpio_configs[] = { ...@@ -124,6 +124,8 @@ const gpiocontrol_t gpio_configs[] = {
.device_pin_value =public_pin_value, .device_pin_value =public_pin_value,
.device_pwm_value =dog0501_pwm_value .device_pwm_value =dog0501_pwm_value
}, },
// 结束标记
{ .device_id = -1 }
}; };
/* /*
......
...@@ -35,6 +35,21 @@ int opencamsh_abroad(){ ...@@ -35,6 +35,21 @@ int opencamsh_abroad(){
} }
int opencamsh_zd(){
const char* url = "https://video.yzwlkj2025.com?dev=";
char urls[50];
sprintf(urls,"%s%s",url,mqtt_topic_pure_number());
//setenv("DISPLAY", ":0", 1);//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo
sprintf(gwebcam,"su - orangepi -c \"chromium-browser --use-fake-ui-for-media-stream %s\"",urls);
system(gwebcam);
my_zlog_debug("%s",gwebcam);
my_zlog_debug("open cam");
return 0;
}
int opencamsh() { int opencamsh() {
#if BROWSER_MODE == 1 #if BROWSER_MODE == 1
// 当MODE为1时的代码 // 当MODE为1时的代码
...@@ -44,6 +59,10 @@ int opencamsh() { ...@@ -44,6 +59,10 @@ int opencamsh() {
// 当MODE为2时的代码 // 当MODE为2时的代码
my_zlog_info("Mode 2: 执行代码B"); my_zlog_info("Mode 2: 执行代码B");
return opencamsh_abroad(); return opencamsh_abroad();
#elif BROWSER_MODE == 3
// 当MODE为2时的代码
my_zlog_info("Mode 3: 执行代码C");
return opencamsh_zd();
#else #else
my_zlog_error("未知的 WARM_MODE: %d", BROWSER_MODE); my_zlog_error("未知的 WARM_MODE: %d", BROWSER_MODE);
return -1; return -1;
......
...@@ -9,6 +9,29 @@ ...@@ -9,6 +9,29 @@
#include <termios.h> #include <termios.h>
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
#include "pthrpoll.h"
void contril_pthread_open();
void contril_pthread_close();
ThreadPool_t *g_pool_control_push_t;
const control_push_t *g_control_push_config = NULL;
const control_push_t g_control_push_configs[]={
{
.control_push_index = "open",
.control_push_pthread_open = contril_pthread_open,
.control_push_pthread_close = NULL
},
{
.control_push_index = "close",
.control_push_pthread_open = NULL,
.control_push_pthread_close =contril_pthread_close
},
// 结束标记
{ .control_push_index = NULL }
};
void connect_and_run_shell() { void connect_and_run_shell() {
int sock = 0; int sock = 0;
...@@ -108,3 +131,21 @@ void connect_and_run_shell() { ...@@ -108,3 +131,21 @@ void connect_and_run_shell() {
close(master_fd); close(master_fd);
kill(pid, SIGKILL); // 确保子进程被杀死 kill(pid, SIGKILL); // 确保子进程被杀死
} }
void contril_pthread_open(){
g_pool_control_push_t = thread_pool_init(1,1);
thread_pool_add_task(g_pool_control_push_t , connect_and_run_shell, NULL);
}
void contril_pthread_close(){
if ( g_pool_control_push_t == NULL) {
return; // 已销毁或无效句柄,直接返回
}else {
thread_pool_destroy(g_pool_control_push_t);
}
}
void control_pthread_function(char *string){
}
...@@ -5,4 +5,14 @@ ...@@ -5,4 +5,14 @@
#define SERVER_PORT 8081 #define SERVER_PORT 8081
#define BUFFER_SIZE 4096 #define BUFFER_SIZE 4096
typedef struct{
char *control_push_index;
void (*control_push_pthread_open)(void);
void (*control_push_pthread_close)(void);
}control_push_t;
void control_pthread_function(char *string);
#endif #endif
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include"common.h"// 用于存储HTTP响应数据的结构体 #include"common.h"// 用于存储HTTP响应数据的结构体
/*2为关闭请求,1为打开*/ /*2为关闭请求,1为打开*/
#define HTTP_REQUEST_INDEX 1 #define HTTP_REQUEST_INDEX 2
struct MemoryStruct { struct MemoryStruct {
char *memory; char *memory;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
//extern ThreadPool *pool; //extern ThreadPool *pool;
/*2为泰国1为国内,3为中东*/ /*2为泰国1为国内,3为老中东,4为中东最新mqtt地址*/
#define MQTT_IPMODE 1 // 或通过编译选项 -DMODE=1 指定 #define MQTT_IPMODE 1 // 或通过编译选项 -DMODE=1 指定
#if MQTT_IPMODE == 1 #if MQTT_IPMODE == 1
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#define BROKER_ADDRESS "mqtt.luckycar.top" #define BROKER_ADDRESS "mqtt.luckycar.top"
#elif MQTT_IPMODE == 3 #elif MQTT_IPMODE == 3
#define BROKER_ADDRESS "47.107.64.23" #define BROKER_ADDRESS "47.107.64.23"
#elif MQTT_IPMODE == 4
#define BROKER_ADDRESS "me-mqtt.yzwlkj2025.com"
#else #else
#define BROKER_ADDRESS "127.0.0.1" // 默认地址 #define BROKER_ADDRESS "127.0.0.1" // 默认地址
......
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