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
4cb33b70
Commit
4cb33b70
authored
May 23, 2025
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:加入了霍尔传感器和修复了角度上传的问题
parent
170e1f10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
7 deletions
+9
-7
main
build/main
+0
-0
common.h
include/common.h
+1
-0
mqtt.c
src/mqtt.c
+6
-5
thread_main.c
src/thread_main.c
+2
-2
No files found.
build/main
View file @
4cb33b70
No preview for this file type
include/common.h
View file @
4cb33b70
...
...
@@ -17,6 +17,7 @@
#include<curl/curl.h>
#include <sys/stat.h>
#include <dirent.h>
#include <math.h>
#include "gpio_common.h"
#include "log.h"
#include "delay.h"
...
...
src/mqtt.c
View file @
4cb33b70
...
...
@@ -100,9 +100,9 @@ void heartbeat_send() {//心跳发送格式
cJSON_AddStringToObject
(
body
,
"ip"
,
ip_address
);
//发送设备id
cJSON_AddStringToObject
(
body
,
"ID"
,
TOPIC
);
//发送设备号
cJSON_AddStringToObject
(
body
,
"V
:
"
,
voltage_str
);
//心跳发送电压
cJSON_AddStringToObject
(
body
,
"I
:
"
,
current_str
);
//心跳发送电流
cJSON_AddStringToObject
(
body
,
"Tem
:
"
,
temperature
);
//发送温度
cJSON_AddStringToObject
(
body
,
"V"
,
voltage_str
);
//心跳发送电压
cJSON_AddStringToObject
(
body
,
"I"
,
current_str
);
//心跳发送电流
cJSON_AddStringToObject
(
body
,
"Tem"
,
temperature
);
//发送温度
cJSON_AddStringToObject
(
body
,
"N"
,
glat
);
//gps
cJSON_AddStringToObject
(
body
,
"E"
,
glon
);
//gps
cJSON_AddStringToObject
(
body
,
"version"
,
version_num
);
//gps
...
...
@@ -129,9 +129,10 @@ void angle_mqtt_send() {
topic_middle_value
();
cJSON
*
root
=
cJSON_CreateObject
();
char
TOPIC_send_angle
[
26
];
double
rounded_angle
=
round
(
angle_shot
*
100
)
/
100
;
sprintf
(
TOPIC_send_angle
,
"dev_rtinfo/%s"
,
TOPIC3
);
cJSON_AddStringToObject
(
root
,
"type"
,
"tank_angle"
);
cJSON_AddNumberToObject
(
root
,
"angle
:"
,
angle_shot
);
cJSON_AddNumberToObject
(
root
,
"angle
"
,
rounded_angle
);
char
*
payload
=
cJSON_PrintUnformatted
(
root
);
my_zlog_debug
(
"%s"
,
payload
);
mosquitto_publish
(
mosq
,
NULL
,
TOPIC_send_angle
,
strlen
(
payload
),
payload
,
0
,
false
);
...
...
@@ -144,7 +145,7 @@ void angle_mqtt_send() {
void
mqtt_wirte
(){
//心跳格式,每5s一次心跳
if
(
AppExit_pin_pwm
==
202
)
angle_mqtt_send
();
if
(
heartbeat_count
>=
10
0
)
heartbeat_send
();
if
(
heartbeat_count
>=
3
0
)
heartbeat_send
();
}
...
...
src/thread_main.c
View file @
4cb33b70
...
...
@@ -67,11 +67,11 @@ void *Mqttbeat(void *arg) {
Delay_Ms
(
15
,
0
);
while
(
1
)
{
ipaddr
();
//获取ip
if
(
AppExit_pin_pwm
==
202
)
Delay_Ms
(
0
,
9
0
);
if
(
AppExit_pin_pwm
==
202
)
Delay_Ms
(
0
,
8
0
);
if
(
AppExit_pin_pwm
!=
202
)
Delay_Ms
(
0
,
100
);
heartbeat_count
++
;
mqtt_wirte
();
//心跳,3s一个
if
(
heartbeat_count
>=
10
0
)
heartbeat_count
=
0
;
if
(
heartbeat_count
>=
3
0
)
heartbeat_count
=
0
;
}
return
NULL
;
...
...
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