Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
car-controlserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenzhongjian
car-controlserver
Commits
3d5b2c74
Commit
3d5b2c74
authored
Dec 25, 2024
by
957dd
Browse files
Options
Browse Files
Download
Plain Diff
update mqtt
parents
ecafc958
de752264
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
19 deletions
+19
-19
log.txt
log/log.txt
+0
-0
main.c
main.c
+6
-5
mqtt.c
mqtt.c
+12
-13
opensh.c
opensh.c
+1
-1
No files found.
log/log.txt
View file @
3d5b2c74
This source diff could not be displayed because it is too large. You can
view the blob
instead.
main.c
View file @
3d5b2c74
...
@@ -81,20 +81,21 @@ void *serial_usart2(void *arg)
...
@@ -81,20 +81,21 @@ void *serial_usart2(void *arg)
void
*
Mqtt_onnect
(
void
*
arg
)
void
*
Mqtt_onnect
(
void
*
arg
)
{
{
Delay_Ms
(
5
,
0
);
Delay_Ms
(
5
,
0
);
//mqtt_wirte();//mqtt心跳首次发送
while
(
1
)
{
mqtt_init
();
//mqtt初始化
mqtt_init
();
//mqtt初始化
mqtt_create
(
mosq
);
//创建mqtt客户端
mqtt_create
(
mosq
);
//创建mqtt客户端
mqtt_create
(
mosq
);
mqtt_create
(
mosq
);
//mqtt_wirte();//mqtt心跳首次发送
while
(
1
)
{
if
(
mqtt_create
(
mosq
)
!=-
1
)
if
(
mqtt_create
(
mosq
)
!=-
1
)
{
{
mqtt_cycle
(
mosq
);
mqtt_cycle
(
mosq
);
}
}
mqtt_clean
(
mosq
);
}
}
mqtt_clean
(
mosq
);
return
NULL
;
return
NULL
;
}
}
...
...
mqtt.c
View file @
3d5b2c74
...
@@ -16,6 +16,18 @@ unsigned char gpinTemp=0;
...
@@ -16,6 +16,18 @@ unsigned char gpinTemp=0;
unsigned
char
gvalTemp
=
0
;
unsigned
char
gvalTemp
=
0
;
unsigned
char
gvalt
[
4
];
unsigned
char
gvalt
[
4
];
int
mqtt_init
()
{
// 初始化 mosquitto 库
mosquitto_lib_init
();
mosq
=
mosquitto_new
(
NULL
,
true
,
NULL
);
if
(
!
mosq
)
{
fprintf
(
stderr
,
"Failed to create Mosquitto client
\n
"
);
return
-
1
;
}
mosquitto_int_option
(
mosq
,
MOSQ_OPT_PROTOCOL_VERSION
,
MQTT_PROTOCOL_V5
);
}
void
on_connect
(
struct
mosquitto
*
mosq
,
void
*
obj
,
int
rc
)
//回调函数
void
on_connect
(
struct
mosquitto
*
mosq
,
void
*
obj
,
int
rc
)
//回调函数
{
{
...
@@ -33,19 +45,6 @@ void on_connect(struct mosquitto *mosq, void *obj, int rc) //回调函数
...
@@ -33,19 +45,6 @@ void on_connect(struct mosquitto *mosq, void *obj, int rc) //回调函数
}
}
int
mqtt_init
()
{
// 初始化 mosquitto 库
mosquitto_lib_init
();
mosq
=
mosquitto_new
(
NULL
,
true
,
NULL
);
if
(
!
mosq
)
{
fprintf
(
stderr
,
"Failed to create Mosquitto client
\n
"
);
return
-
1
;
}
mosquitto_int_option
(
mosq
,
MOSQ_OPT_PROTOCOL_VERSION
,
MQTT_PROTOCOL_V5
);
}
//int init_mqtt(struct mosquitto *mosq)
//int init_mqtt(struct mosquitto *mosq)
/*
/*
void mqtt_MAC_wirte()
void mqtt_MAC_wirte()
...
...
opensh.c
View file @
3d5b2c74
...
@@ -10,7 +10,7 @@ int opencamsh()
...
@@ -10,7 +10,7 @@ int opencamsh()
setenv
(
"DISPLAY"
,
":0"
,
1
);
//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo
setenv
(
"DISPLAY"
,
":0"
,
1
);
//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo
//sprintf(gwebcam,"sudo firefox --new-window https://jywy.yd-ss.com?dev=%s &",gsite);
//sprintf(gwebcam,"sudo firefox --new-window https://jywy.yd-ss.com?dev=%s &",gsite);
system
(
"sudo firefox https://jywy.yd-ss.com?dev=controlcar000
1
"
);
system
(
"sudo firefox https://jywy.yd-ss.com?dev=controlcar000
2
"
);
printf
(
"%s
\n
"
,
gwebcam
);
printf
(
"%s
\n
"
,
gwebcam
);
printf
(
"close cam
\n
"
);
printf
(
"close cam
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment