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
279aa042
Commit
279aa042
authored
Jun 09, 2026
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了不发bug,找后端要验证失败会重复要验证
parent
e3206a35
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
187 additions
and
136 deletions
+187
-136
CMakeLists.txt
CMakeLists.txt
+1
-1
device_wifi_change.c
app/device_change/device_wifi_change.c
+1
-1
pthread_open.c
app/main/pthread_open.c
+5
-3
main
build/main
+0
-0
ptz_driver.c
drivers/devicecontrol/ptz_driver.c
+1
-1
tank_common.c
drivers/devicecontrol/tank_common.c
+4
-4
gpio_control.c
drivers/gpio/gpio_control.c
+73
-73
self_devicecontrol.c
drivers/selfcontrol/self_devicecontrol.c
+4
-4
browser_open.c
modules/browser/browser_open.c
+1
-1
mylog.c
modules/logger/mylog.c
+1
-1
mylog.h
modules/logger/mylog.h
+2
-2
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+21
-21
mqtt_init.c
modules/mqtt/mqtt_init.c
+2
-2
mqtt_verify.c
modules/mqtt/mqtt_verify.c
+65
-20
mqtt_verify.h
modules/mqtt/mqtt_verify.h
+5
-1
zlog.conf
zlog.conf
+1
-1
No files found.
CMakeLists.txt
View file @
279aa042
...
...
@@ -58,7 +58,7 @@ target_compile_definitions(main PRIVATE
PROJECT_ROOT_DIR=
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
)
# Release模式下定义LOG_PRODUCTION宏,编译时剔除debug
和info日志
# Release模式下定义LOG_PRODUCTION宏,编译时剔除debug
日志(info及以上保留)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
target_compile_definitions
(
main PRIVATE LOG_PRODUCTION
)
endif
()
...
...
app/device_change/device_wifi_change.c
View file @
279aa042
...
...
@@ -184,7 +184,7 @@ int connect_wifi_with_fallback(const char* ssid, const char* password, const cha
int
change_wifi_connect
(
const
char
*
wifi_ssid
,
const
char
*
wifi_password
)
{
get_current_wifi
();
int
ret
=
connect_wifi_with_fallback
(
wifi_ssid
,
wifi_password
,
g_current_ssid
);
my_zlog_
notice
(
"
返回代码:%d"
,
ret
);
my_zlog_
info
(
"WiFi连接
返回代码:%d"
,
ret
);
return
ret
;
}
...
...
app/main/pthread_open.c
View file @
279aa042
...
...
@@ -94,7 +94,7 @@ void *thread_mqtt_beat(void *arg)
// }
if
(
verify_open_index_init
()
!=
0
)
{
my_zlog_
info
(
"mqtt send verify is NULL"
);
my_zlog_
warn
(
"mqtt send verify is NULL"
);
}
// 如果为相关的不需要心跳或者游览器设备,提早结束线程
...
...
@@ -108,6 +108,8 @@ void *thread_mqtt_beat(void *arg)
{
delay_ms
(
100
);
verify_open_query_poll
();
g_heartbeat_count
++
;
set_tank_angle_count
();
// 角度发布计时,1开始计时,0清0
if
(
s_mqtt_grc
==
0
)
...
...
@@ -116,7 +118,7 @@ void *thread_mqtt_beat(void *arg)
if
(
get_device_self_control_configuration_initialization
()
==
0
)
{
my_zlog_
warn
(
"自控配置初始化成功"
);
my_zlog_
info
(
"自控配置初始化成功"
);
}
}
}
...
...
@@ -241,7 +243,7 @@ void *thread_mqtt_reconnect(void *arg)
remqtt_index
=
mqtt_init
();
if
(
remqtt_index
==
0
)
{
my_zlog_
warn
(
"mqtt success"
,
remqtt_index
);
my_zlog_
info
(
"mqtt success"
);
break
;
}
else
...
...
build/main
View file @
279aa042
No preview for this file type
drivers/devicecontrol/ptz_driver.c
View file @
279aa042
...
...
@@ -301,7 +301,7 @@ void ptz_driver_change(int *buf)
return
;
}
my_zlog_
info
(
"PTZ(%d) CMD: %d"
,
s_cfg
->
device_id
,
buf
[
1
]);
my_zlog_
debug
(
"PTZ(%d) CMD: %d"
,
s_cfg
->
device_id
,
buf
[
1
]);
switch
(
buf
[
1
])
{
case
1
:
...
...
drivers/devicecontrol/tank_common.c
View file @
279aa042
...
...
@@ -108,7 +108,7 @@ int tankshot_detection_backcount(int *cool_time,int flag){
pthread_mutex_lock
(
&
s_tankshot_detection_mutex
);
if
(
flag
==
0
){
cool_count_init
=*
cool_time
;
my_zlog_
info
(
"cool_count_init的值:%d"
,
cool_count_init
);
my_zlog_
debug
(
"cool_count_init的值:%d"
,
cool_count_init
);
}
else
if
(
flag
==
1
){
cool_count
++
;
...
...
@@ -121,7 +121,7 @@ int tankshot_detection_backcount(int *cool_time,int flag){
}
else
if
(
flag
==
3
){
cool_count
=
0
;
s_tankshot_detectionback_count
=
0
;
my_zlog_
info
(
"冷却计时重置"
);
my_zlog_
debug
(
"冷却计时重置"
);
}
else
if
(
flag
==
4
){
s_tankshot_detectionback_count
=
0
;
}
...
...
@@ -135,11 +135,11 @@ static void tankshot_detectionback(){
if
(
digitalRead
(
12
)
==
LOW
){
s_back_status
=
true
;
index
=
1
;
delay_ms
(
90
);
// 延时 100ms,防止抖动
delay_ms
(
90
);
// 延时 100ms,防止抖动
g_device_delay_back_count
=
0
;
softPwmWrite
(
27
,
0
);
set_backshotstatus
(
false
);
my_zlog_
info
(
"检测引脚12拉低"
);
my_zlog_
debug
(
"检测引脚12拉低"
);
}
}
...
...
drivers/gpio/gpio_control.c
View file @
279aa042
...
...
@@ -130,7 +130,7 @@ int device_fire_check(TankFireControl* this) {
if
(
this
->
state
==
TANK_STATE_COOLDOWN
)
{
if
(
current_time
-
this
->
last_shot_end_time
>=
this
->
shot_interval_ms
)
{
this
->
state
=
TANK_STATE_READY
;
my_zlog_
info
(
"coolend -> ready"
);
my_zlog_
debug
(
"coolend -> ready"
);
// 注意:这里不要 return,让代码继续往下执行,
// 这样如果冷却刚结束,马上就能在下面进入射击逻辑
}
else
{
...
...
@@ -148,7 +148,7 @@ int device_fire_check(TankFireControl* this) {
if
(
this
->
state
==
TANK_STATE_READY
)
{
// 双重检查:确保时间间隔满足(防止异常状态跳变)
if
(
current_time
-
this
->
last_shot_end_time
>=
this
->
shot_interval_ms
)
{
my_zlog_
info
(
"shot start"
);
my_zlog_
debug
(
"shot start"
);
this
->
shooting_start_time
=
current_time
;
this
->
state
=
TANK_STATE_SHOOTING
;
// 开始射击了,这里不需要立即 return,
...
...
@@ -165,7 +165,7 @@ int device_fire_check(TankFireControl* this) {
// -----------------------------------------------------------
if
(
this
->
state
==
TANK_STATE_SHOOTING
)
{
if
(
current_time
-
this
->
shooting_start_time
>
this
->
shot_duration_ms
)
{
my_zlog_
info
(
"shot end -> cooling"
);
my_zlog_
debug
(
"shot end -> cooling"
);
// 【优化】计算理论结束时间,消除 100ms 轮询带来的时间漂移
// 如果不在意精度,依然可以用 current_time
...
...
@@ -178,7 +178,7 @@ int device_fire_check(TankFireControl* this) {
return
-
1
;
// 射击刚刚结束
}
my_zlog_
info
(
"shot continue ..."
);
my_zlog_
debug
(
"shot continue ..."
);
return
0
;
// 正在射击中
}
...
...
@@ -209,14 +209,14 @@ void tank_angle_limit_function(){
if
(
s_limit_status
==
LIMIT_LIFT
)
{
device_gpio_control
(
g_device_type
,
5
,
0
);
if
(
limit_log_count
>
100
){
my_zlog_
info
(
"right limit"
);
my_zlog_
debug
(
"right limit"
);
limit_log_count
=
0
;
}
}
else
if
(
s_limit_status
==
LIMIT_RIGHT
)
{
device_gpio_control
(
g_device_type
,
7
,
0
);
if
(
limit_log_count
>
100
){
my_zlog_
info
(
"lift limit"
);
my_zlog_
debug
(
"lift limit"
);
limit_log_count
=
0
;
}
}
...
...
@@ -224,7 +224,7 @@ void tank_angle_limit_function(){
else
if
(
s_limit_status
==
0
)
{
limit_log_count
++
;
if
(
limit_log_count
>
100
){
my_zlog_
info
(
"limit stop"
);
my_zlog_
debug
(
"limit stop"
);
limit_log_count
=
0
;
}
delay_ms
(
5
);
...
...
@@ -408,12 +408,12 @@ void public_pin_value(int pin,int value) { //引脚控制
}
if
(
value
==
1
)
{
digitalWrite
(
pin
,
HIGH
);
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
HIGH
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
HIGH
);
}
else
if
(
value
==
0
)
{
digitalWrite
(
pin
,
LOW
);
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
LOW
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
LOW
);
}
}
void
tank0204_pin_value
(
int
pin
,
int
value
)
{
//tank0204引脚控制
...
...
@@ -422,17 +422,17 @@ void tank0204_pin_value(int pin,int value) { //tank0204引脚控制
}
if
(
value
==
1
)
{
digitalWrite
(
pin
,
HIGH
);
}
else
if
(
value
==
0
)
{
digitalWrite
(
pin
,
LOW
);
}
if
(
pin
!=
6
)
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
value
);
if
(
pin
!=
6
)
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
value
);
else
{
static
int
s_i
=
0
;
s_i
++
;
if
(
s_i
>
10
)
{
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
value
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
value
);
s_i
=
0
;
}
}
...
...
@@ -451,26 +451,26 @@ void car0102_pin_value(int pin,int value) { //引脚控制
static
int
i
=
0
;
i
++
;
if
(
i
>
10
)
{
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
HIGH
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
HIGH
);
i
=
0
;
}
return
;
}
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
HIGH
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
HIGH
);
}
else
if
(
value
==
0
)
{
digitalWrite
(
pin
,
LOW
);
if
(
pin
==
26
){
static
int
i
=
0
;
i
++
;
if
(
i
>
10
)
{
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
HIGH
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
HIGH
);
i
=
0
;
}
return
;
}
my_zlog_
info
(
"pin:%d,%d"
,
pin
,
LOW
);
my_zlog_
debug
(
"pin:%d,%d"
,
pin
,
LOW
);
}
}
/*
...
...
@@ -573,20 +573,20 @@ void public_pwm_value(int pin ,int value){
int
shot_speed
=
(
int
)(
g_shot_speed_value
*
100
);
if
(
value
==
1
)
{
if
(
pin
==
27
){
softPwmWrite
(
pin
,
shot_speed
);
my_zlog_
info
(
"pwm:%d,%d"
,
pin
,
shot_speed
);
my_zlog_
debug
(
"pwm:%d,%d"
,
pin
,
shot_speed
);
}
else
{
softPwmWrite
(
pin
,
shot_speed
);
my_zlog_
info
(
"pwm:%d,%d"
,
pin
,
shot_speed
);
my_zlog_
debug
(
"pwm:%d,%d"
,
pin
,
shot_speed
);
}
}
else
if
(
value
==
0
)
{
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"public pwm"
);
my_zlog_
debug
(
"public pwm"
);
}
...
...
@@ -618,26 +618,26 @@ void tank0202_pwm_value(int pin,int value) { //软件陪我们控制调速
softPwmWrite
(
pin
,
30
);
devicegpio_pwmreuse
(
pin
,
value
,
30
);
}
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
if
(
s_limit_status
==
LIMIT_LIFT
)
{
softPwmWrite
(
5
,
0
);
//device_gpio_control(g_device_type,5,0);
my_zlog_
info
(
"lift limit stop"
);
my_zlog_
debug
(
"lift limit stop"
);
}
else
if
(
s_limit_status
==
LIMIT_RIGHT
)
{
softPwmWrite
(
7
,
0
);
//device_gpio_control(g_device_type,7,0);
my_zlog_
info
(
"right limit stop"
);
my_zlog_
debug
(
"right limit stop"
);
}
}
else
if
(
value
==
0
)
{
softPwmWrite
(
pin
,
0
);
if
(
pin
!=
26
||
s_device_shot_t
.
state
!=
TANK_STATE_SHOOTING
)
{
devicegpio_pwmreuse
(
pin
,
value
,
0
);
}
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"tank0202 pwm"
);
my_zlog_
debug
(
"tank0202 pwm"
);
}
void
tank0203_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
...
...
@@ -654,27 +654,27 @@ void tank0203_pwm_value(int pin,int value) { //软件陪我们控制调速
softPwmWrite
(
pin
,
30
);
devicegpio_pwmreuse
(
pin
,
value
,
30
);
}
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
if
(
s_limit_status
==
LIMIT_LIFT
)
{
softPwmWrite
(
5
,
0
);
//device_gpio_control(g_device_type,5,0);
my_zlog_
info
(
"lift limit stop"
);
my_zlog_
debug
(
"lift limit stop"
);
}
else
if
(
s_limit_status
==
LIMIT_RIGHT
)
{
softPwmWrite
(
7
,
0
);
//device_gpio_control(g_device_type,7,0);
my_zlog_
info
(
"right limit stop"
);
my_zlog_
debug
(
"right limit stop"
);
}
}
else
if
(
value
==
0
)
{
softPwmWrite
(
pin
,
0
);
if
(
pin
!=
26
||
s_device_shot_t
.
state
!=
TANK_STATE_SHOOTING
)
{
devicegpio_pwmreuse
(
pin
,
value
,
0
);
}
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"tank0203 pwm"
);
my_zlog_
debug
(
"tank0203 pwm"
);
}
void
tank0204_pwm_value
(
int
pin
,
int
value
){
...
...
@@ -691,41 +691,41 @@ void tank0204_pwm_value(int pin,int value){
setshot_detection_index
(
false
);
tankshot_detection_backcount
(
NULL
,
3
);
set_backshotstatus
(
true
);
my_zlog_
info
(
"冷却完成,射击开始"
);
my_zlog_
debug
(
"冷却完成,射击开始"
);
}
//set_tank_shot_index_cool(0);
}
else
if
(
pin
==
5
)
{
softPwmWrite
(
7
,
35
);
my_zlog_
info
(
"pwm:7,1"
);
my_zlog_
debug
(
"pwm:7,1"
);
}
else
if
(
pin
==
7
)
{
softPwmWrite
(
5
,
35
);
my_zlog_
info
(
"pwm:5,1"
);
my_zlog_
debug
(
"pwm:5,1"
);
}
else
{
if
(
pin
==
26
&&
get_backshotstatus
()
!=
true
)
{
devicegpio_pwmreuse
(
pin
,
value
,
60
);
softPwmWrite
(
pin
,
60
);
}
if
(
pin
!=
26
)
softPwmWrite
(
pin
,
60
);
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
if
(
s_limit_status
==
LIMIT_LIFT
)
{
softPwmWrite
(
7
,
0
);
//device_gpio_control(g_device_type,5,0);
my_zlog_
info
(
"lift limit stop"
);
my_zlog_
debug
(
"lift limit stop"
);
}
else
if
(
s_limit_status
==
LIMIT_RIGHT
)
{
softPwmWrite
(
5
,
0
);
//device_gpio_control(g_device_type,7,0);
my_zlog_
info
(
"right limit stop"
);
my_zlog_
debug
(
"right limit stop"
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
5
)
{
softPwmWrite
(
7
,
0
);
my_zlog_
info
(
"pwm:7,0"
);
my_zlog_
debug
(
"pwm:7,0"
);
}
else
if
(
pin
==
7
)
{
softPwmWrite
(
5
,
0
);
my_zlog_
info
(
"pwm:5,0"
,
pin
);
my_zlog_
debug
(
"pwm:5,0"
,
pin
);
}
else
{
if
(
pin
!=
27
)
{
if
(
pin
==
26
){
...
...
@@ -735,95 +735,95 @@ void tank0204_pwm_value(int pin,int value){
}
}
if
(
pin
!=
26
)
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
}
}
my_zlog_
info
(
"tank0204 pwm"
);
my_zlog_
debug
(
"tank0204 pwm"
);
}
void
tank0206_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
if
(
!
device_gpio_pwm_allowed
(
pin
))
{
return
;
}
if
(
value
==
1
)
{
if
(
pin
==
27
){
device_shoting_check
(
26
,
35
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
)
softPwmWrite
(
26
,
0
);
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"tank0206 pwm"
);
my_zlog_
debug
(
"tank0206 pwm"
);
}
void
tank0207_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
if
(
!
device_gpio_pwm_allowed
(
pin
))
{
return
;
}
if
(
value
==
1
)
{
if
(
pin
==
27
){
device_shoting_check
(
26
,
100
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
)
softPwmWrite
(
26
,
0
);
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"tank0206
pwm"
);
my_zlog_
debug
(
"tank0207
pwm"
);
}
void
ship0301_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
if
(
!
device_gpio_pwm_allowed
(
pin
))
{
return
;
}
if
(
value
==
1
)
{
if
(
pin
==
27
){
softPwmWrite
(
26
,
35
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
)
softPwmWrite
(
26
,
0
);
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"tank
0301 pwm"
);
my_zlog_
debug
(
"ship
0301 pwm"
);
}
void
ship0302_pwm_value
(
int
pin
,
int
value
)
{
// 与 ship0301 引脚/软 PWM 行为一致
if
(
!
device_gpio_pwm_allowed
(
pin
))
{
return
;
}
if
(
value
==
1
)
{
if
(
pin
==
27
){
softPwmWrite
(
26
,
35
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
)
softPwmWrite
(
26
,
0
);
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"ship0302 pwm"
);
my_zlog_
debug
(
"ship0302 pwm"
);
}
...
...
@@ -831,24 +831,24 @@ void dog0501_pwm_value(int pin,int value) { //软件陪我们控制调速
if
(
!
device_gpio_pwm_allowed
(
pin
))
{
return
;
}
if
(
value
==
1
)
{
if
(
pin
==
27
){
softPwmWrite
(
27
,
40
);
softPwmWrite
(
7
,
100
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_
info
(
"pwm:%d"
,
pin
);
my_zlog_
debug
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
){
softPwmWrite
(
27
,
0
);
softPwmWrite
(
7
,
0
);
}
else
softPwmWrite
(
pin
,
0
);
my_zlog_
info
(
"pwm:%d,0"
,
pin
);
my_zlog_
debug
(
"pwm:%d,0"
,
pin
);
}
my_zlog_
info
(
"dog0501 pwm"
);
my_zlog_
debug
(
"dog0501 pwm"
);
}
drivers/selfcontrol/self_devicecontrol.c
View file @
279aa042
...
...
@@ -318,7 +318,7 @@ void receive_self_contorl_mqtt(cJSON *body){
send_self_contorl_mqtt
();
my_zlog_
info
(
"count:%d"
,
s_self_device_control_data
->
id_run_count
);
my_zlog_
debug
(
"count:%d"
,
s_self_device_control_data
->
id_run_count
);
return
;
}
...
...
@@ -369,8 +369,8 @@ void receive_self_contorl_date_mqtt(cJSON *body){
s_automatic_data
[
s_action_id
].
action_count
++
;
my_zlog_
info
(
"combination:%d"
,
s_automatic_data
[
s_action_id
].
mode
[
j
]);
my_zlog_
info
(
"speed:%d"
,
s_automatic_data
[
s_action_id
].
val
[
j
]);
my_zlog_
debug
(
"combination:%d"
,
s_automatic_data
[
s_action_id
].
mode
[
j
]);
my_zlog_
debug
(
"speed:%d"
,
s_automatic_data
[
s_action_id
].
val
[
j
]);
}
}
...
...
@@ -383,7 +383,7 @@ void receive_self_contorl_date_mqtt(cJSON *body){
memset
(
s_automatic_data
[
s_action_id
].
val
,
0
,
sizeof
(
s_automatic_data
[
s_action_id
].
val
));
}
my_zlog_
info
(
"action_count:%d"
,
s_automatic_data
[
s_action_id
].
action_count
);
my_zlog_
debug
(
"action_count:%d"
,
s_automatic_data
[
s_action_id
].
action_count
);
return
;
...
...
modules/browser/browser_open.c
View file @
279aa042
...
...
@@ -154,7 +154,7 @@ void refresh_cam(void)
if
(
now
<
s_refresh_next_allowed
)
{
long
left
=
(
long
)(
s_refresh_next_allowed
-
now
);
pthread_mutex_unlock
(
&
s_refresh_cool_mutex
);
my_zlog_
notice
(
"refresh_cam skipped: cooldown %lds remaining (max once per %ds)"
,
my_zlog_
debug
(
"refresh_cam skipped: cooldown %lds remaining (max once per %ds)"
,
left
,
REFRESH_CAM_COOLDOWN_SEC
);
return
;
}
...
...
modules/logger/mylog.c
View file @
279aa042
...
...
@@ -229,6 +229,7 @@ void my_zlog_debug(const char *format, ...) {
va_end
(
args
);
}
}
#endif
void
my_zlog_info
(
const
char
*
format
,
...)
{
if
(
s_zlog_c
)
{
...
...
@@ -238,7 +239,6 @@ void my_zlog_info(const char *format, ...) {
va_end
(
args
);
}
}
#endif
void
my_zlog_notice
(
const
char
*
format
,
...)
{
if
(
s_zlog_c
)
{
...
...
modules/logger/mylog.h
View file @
279aa042
...
...
@@ -6,12 +6,12 @@ int mylog_init();
#ifdef LOG_PRODUCTION
#define my_zlog_debug(...) ((void)0)
#define my_zlog_info(...) ((void)0)
#else
void
my_zlog_debug
(
const
char
*
format
,
...)
;
void
my_zlog_info
(
const
char
*
format
,
...)
;
#endif
void
my_zlog_info
(
const
char
*
format
,
...)
;
void
my_zlog_notice
(
const
char
*
format
,
...)
;
void
my_zlog_warn
(
const
char
*
format
,
...)
;
void
my_zlog_error
(
const
char
*
format
,
...)
;
...
...
modules/mqtt/mqtt_infor_handle.c
View file @
279aa042
...
...
@@ -253,7 +253,7 @@ void message_4_judyverify(cJSON *body)
if
(
VERIFIED_MODE
==
FALSE
)
{
message_4
(
body
);
my_zlog_
info
(
"不使用验证"
);
my_zlog_
warn
(
"不使用验证"
);
return
;
}
...
...
@@ -274,7 +274,7 @@ void message_6_steering_judyverify(cJSON *body)
if
(
VERIFIED_MODE
==
FALSE
)
{
steering_mqtt_recv
(
body
);
my_zlog_
info
(
"不使用验证"
);
my_zlog_
warn
(
"不使用验证"
);
return
;
}
...
...
@@ -301,7 +301,7 @@ void message_7_joystick_judyverify(cJSON *body)
if
(
VERIFIED_MODE
==
FALSE
)
{
ptz_driver_set_joystick_json
(
joystick_ctrl
);
my_zlog_
info
(
"不使用验证"
);
my_zlog_
warn
(
"不使用验证"
);
return
;
}
...
...
@@ -325,8 +325,8 @@ int device_mqttchange_name(cJSON *device_id)
char
*
device_change_date
=
date
->
valuestring
;
device_changename_back
(
device_change_date
,
device_change_id
);
// 输出提取的数据
my_zlog_
debug
(
"设备ID: %s"
,
device_change_id
);
my_zlog_
debug
(
"日期: %s"
,
device_change_date
);
my_zlog_
info
(
"设备ID: %s"
,
device_change_id
);
my_zlog_
info
(
"日期: %s"
,
device_change_date
);
return
0
;
}
...
...
@@ -371,7 +371,7 @@ int device_message_receive(cJSON *json)
case
5
:
audio_wheat_init
();
audio_speaker_init
();
my_zlog_
debug
(
"执行麦和喇叭命令"
);
my_zlog_
info
(
"执行麦和喇叭命令"
);
break
;
case
6
:
message_6_steering_judyverify
(
body
);
...
...
@@ -383,64 +383,64 @@ int device_message_receive(cJSON *json)
break
;
case
2001
:
audioplay_mqtt_receive
(
body
);
my_zlog_
debug
(
"进入音频播放"
);
my_zlog_
info
(
"进入音频播放"
);
break
;
case
2002
:
device_mqttchange_name
(
body
);
my_zlog_
debug
(
"进入修改设备号"
);
my_zlog_
info
(
"进入修改设备号"
);
break
;
case
2003
:
scan_wifi_json
();
my_zlog_
debug
(
"进入查询WiFi"
);
my_zlog_
info
(
"进入查询WiFi"
);
break
;
case
2004
:
// wifi_change_recmqtt(body);
my_zlog_
debug
(
"进入修改WiFi"
);
my_zlog_
info
(
"进入修改WiFi"
);
break
;
case
2006
:
message2006_verify
(
body
);
my_zlog_
debug
(
"进入消息为2006验证"
);
my_zlog_
info
(
"进入消息为2006验证"
);
break
;
case
2007
:
device_send_saved_wifi
();
my_zlog_
debug
(
"查询已保存wifi和现在已连接WiFi"
);
my_zlog_
info
(
"查询已保存wifi和现在已连接WiFi"
);
break
;
case
2008
:
device_wifi_rec_sava
(
body
);
my_zlog_
debug
(
"保存wifi"
);
my_zlog_
info
(
"保存wifi"
);
break
;
case
2009
:
device_wifi_rec_delete
(
body
);
my_zlog_
debug
(
"删除已保存wifi"
);
my_zlog_
info
(
"删除已保存wifi"
);
break
;
case
2011
:
int
res
=
system
(
"sudo reboot"
);
// 重启香橙派
if
(
res
==
0
)
my_zlog_
debug
(
"重启成功"
);
my_zlog_
info
(
"重启成功"
);
break
;
case
2012
:
refresh_cam
();
my_zlog_
debug
(
"刷新成功"
);
my_zlog_
info
(
"刷新成功"
);
break
;
case
2013
:
message2013_recverigy_open
(
body
);
my_zlog_
debug
(
"进入是否需要验证"
);
my_zlog_
info
(
"进入是否需要验证"
);
break
;
case
2014
:
control_pthread_function
(
"open"
);
my_zlog_
debug
(
"打开控制台推送"
);
my_zlog_
info
(
"打开控制台推送"
);
break
;
case
2015
:
control_pthread_function
(
"close"
);
my_zlog_
debug
(
"关闭控制台推送"
);
my_zlog_
info
(
"关闭控制台推送"
);
break
;
case
2016
:
mqtt_verify_data_clear
(
body
);
my_zlog_
debug
(
"清除验证数据"
);
my_zlog_
info
(
"清除验证数据"
);
break
;
case
2025
:
receive_self_contorl_mqtt
(
body
);
my_zlog_
debug
(
"device self comtrol"
);
my_zlog_
info
(
"device self comtrol"
);
break
;
case
2026
:
receive_self_contorl_date_mqtt
(
body
);
...
...
modules/mqtt/mqtt_init.c
View file @
279aa042
...
...
@@ -137,7 +137,7 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
// 解析 JSON
cJSON
*
json
=
cJSON_Parse
(
payload_str
);
if
(
json
!=
NULL
){
if
(
device_message_receive
(
json
)
==
0
)
my_zlog_
info
(
"进入设备接收mqtt"
);
if
(
device_message_receive
(
json
)
==
0
)
my_zlog_
debug
(
"进入设备接收mqtt"
);
}
// 释放 payload 字符串
...
...
@@ -239,7 +239,7 @@ void mqtt_clean(){
}
mosquitto_lib_cleanup
();
my_zlog_
notice
(
"清理成功"
);
my_zlog_
info
(
"清理成功"
);
}
int
mqtt_cycle
()
{
//非阻塞型
...
...
modules/mqtt/mqtt_verify.c
View file @
279aa042
...
...
@@ -33,6 +33,15 @@ static time_t s_verify_retry_after_time = 0; /* 允许发起重试的时间戳
#define VERIFY_RETRY_MAX 3
#define VERIFY_RETRY_INTERVAL_SEC 1
/* 启动时向后端查询是否开启验证(3013/2013) */
#define VERIFY_OPEN_QUERY_MAX 3
#define VERIFY_OPEN_QUERY_INTERVAL_SEC 3
static
bool
s_verify_open_got_reply
=
false
;
/* 已收到后端2013 */
static
bool
s_verify_open_query_gave_up
=
false
;
/* 3次未收到,已放弃 */
static
int
s_verify_open_send_count
=
0
;
/* 已发送3013次数 */
static
time_t
s_verify_open_last_send_time
=
0
;
int
g_verify_index
=
0
;
//判断是否验证成功
pthread_mutex_t
g_verify_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
//线程锁
...
...
@@ -120,7 +129,7 @@ int receive_jwt(cJSON *body) {
&&
s_verify_retry_after_time
>
0
&&
time
(
NULL
)
>=
s_verify_retry_after_time
)
{
s_verify_retry_after_time
=
0
;
send_jwtser
(
s_pending_verify_token
);
my_zlog_
notice
(
"距上次失败已过%d秒,发起第%d次重试验证, token=%s"
,
my_zlog_
info
(
"距上次失败已过%d秒,发起第%d次重试验证, token=%s"
,
VERIFY_RETRY_INTERVAL_SEC
,
s_verify_retry_count
+
1
,
s_pending_verify_token
);
}
...
...
@@ -141,7 +150,7 @@ int receive_jwt(cJSON *body) {
pthread_mutex_lock
(
&
g_verify_mutex
);
g_verify_count
=
0
;
pthread_mutex_unlock
(
&
g_verify_mutex
);
my_zlog_
notice
(
"首次token,发起验证, token=%s"
,
token
);
my_zlog_
info
(
"首次token,发起验证, token=%s"
,
token
);
}
else
if
(
strcmp
(
token
,
s_last_seen_token
)
!=
0
)
{
strncpy
(
s_last_seen_token
,
token
,
sizeof
(
s_last_seen_token
)
-
1
);
s_last_seen_token
[
sizeof
(
s_last_seen_token
)
-
1
]
=
'\0'
;
...
...
@@ -154,9 +163,9 @@ int receive_jwt(cJSON *body) {
pthread_mutex_lock
(
&
g_verify_mutex
);
g_verify_count
=
0
;
pthread_mutex_unlock
(
&
g_verify_mutex
);
my_zlog_
notice
(
"token变化,发起验证, token=%s"
,
token
);
my_zlog_
info
(
"token变化,发起验证, token=%s"
,
token
);
}
else
{
my_zlog_
info
(
"token未变化"
);
my_zlog_
debug
(
"token未变化"
);
}
...
...
@@ -175,7 +184,7 @@ int receive_jwt(cJSON *body) {
my_zlog_debug
(
"g_verify_index= %d "
,
g_verify_index
);
if
(
g_verify_count
>
12000
){
send_jwtser
(
token
);
my_zlog_
notice
(
"JWT超过1分钟触发重新验证, token=%s"
,
token
);
my_zlog_
debug
(
"JWT超过1分钟触发重新验证, token=%s"
,
token
);
pthread_mutex_lock
(
&
g_verify_mutex
);
g_verify_count
=
0
;
pthread_mutex_unlock
(
&
g_verify_mutex
);
...
...
@@ -187,8 +196,8 @@ int receive_jwt(cJSON *body) {
my_zlog_debug
(
"g_verify_index= %d "
,
g_verify_index
);
}
my_zlog_
info
(
"token: %s"
,
token
);
my_zlog_
info
(
"token_time: %s"
,
token_time
);
my_zlog_
debug
(
"token: %s"
,
token
);
my_zlog_
debug
(
"token_time: %s"
,
token_time
);
return
0
;
}
...
...
@@ -203,7 +212,7 @@ int message2006_verify(cJSON *body){
if
(
json_status
==
NULL
||
json_onlyid
==
NULL
)
{
my_zlog_
debug
(
"验证为空"
);
my_zlog_
warn
(
"验证为空"
);
s_service_verify
=
FALSE
;
g_verify_index
=
1
;
my_zlog_debug
(
"g_verify_index= %d "
,
g_verify_index
);
...
...
@@ -215,7 +224,7 @@ int message2006_verify(cJSON *body){
my_zlog_debug
(
"data: %s"
,
status
);
my_zlog_debug
(
"onlyid: %s"
,
onlyid
);
if
(
strcmp
(
onlyid
,
s_only_id_middle
)
==
0
&&
strcmp
(
status
,
"1"
)
==
0
){
my_zlog_
debug
(
"获得验证正确"
);
my_zlog_
info
(
"获得验证正确, onlyid=%s"
,
onlyid
);
s_service_verify
=
TRUE
;
g_verify_index
=
0
;
/* 后端通过后必须清除失败标志,否则正确 token 仍会提示验证不通过 */
strcpy
(
s_secret_key
,
s_pending_verify_token
);
...
...
@@ -237,7 +246,7 @@ int message2006_verify(cJSON *body){
return
2
;
}
}
else
{
my_zlog_
debug
(
"获得验证错误,禁止使用"
);
my_zlog_
warn
(
"获得验证错误,禁止使用, onlyid=%s status=%s"
,
onlyid
,
status
);
g_verify_index
=
1
;
s_service_verify
=
FALSE
;
return
2
;
...
...
@@ -251,17 +260,20 @@ int message2006_verify(cJSON *body){
int
message2013_recverigy_open
(
cJSON
*
body
){
cJSON
*
verifty_open_index
=
cJSON_GetObjectItem
(
body
,
"verify_status"
);
if
(
verifty_open_index
==
NULL
){
my_zlog_
debug
(
"接收验证是否打开为空"
);
my_zlog_
warn
(
"接收验证是否打开为空"
);
return
-
1
;
}
int
verifty_open
=
verifty_open_index
->
valueint
;
my_zlog_debug
(
"verifty:%d"
,
verifty_open
);
s_verify_open_got_reply
=
true
;
s_verify_open_query_gave_up
=
false
;
if
(
verifty_open
==
0
){
VERIFIED_MODE
=
FALSE
;
my_zlog_
debug
(
"verify close"
);
my_zlog_
info
(
"关闭验证, verify_status=%d"
,
verifty_open
);
}
else
{
VERIFIED_MODE
=
TRUE
;
my_zlog_
debug
(
"verify open"
);
my_zlog_
info
(
"开启验证, verify_status=%d"
,
verifty_open
);
}
return
0
;
}
...
...
@@ -287,7 +299,7 @@ int message_sendopen_verify(){
return
-
1
;
}
my_zlog_debug
(
"
%s"
,
payload
);
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
);
...
...
@@ -298,15 +310,48 @@ int message_sendopen_verify(){
return
0
;
}
}
static
int
verify_open_query_send_once
(
void
)
{
if
(
message_sendopen_verify
()
!=
0
)
{
return
-
1
;
}
s_verify_open_send_count
++
;
s_verify_open_last_send_time
=
time
(
NULL
);
my_zlog_info
(
"发送验证开关查询(3013), 第%d/%d次"
,
s_verify_open_send_count
,
VERIFY_OPEN_QUERY_MAX
);
return
0
;
}
/*发送是否打开验证的mqtt给后端验证初始化*/
int
verify_open_index_init
(){
if
(
message_sendopen_verify
()
!=
0
){
return
-
1
;
s_verify_open_got_reply
=
false
;
s_verify_open_query_gave_up
=
false
;
s_verify_open_send_count
=
0
;
s_verify_open_last_send_time
=
0
;
return
verify_open_query_send_once
();
}
void
verify_open_query_poll
(
void
)
{
if
(
s_verify_open_got_reply
||
s_verify_open_query_gave_up
)
{
return
;
}
if
(
s_verify_open_last_send_time
==
0
)
{
return
;
}
return
0
;
time_t
now
=
time
(
NULL
);
if
(
now
-
s_verify_open_last_send_time
<
VERIFY_OPEN_QUERY_INTERVAL_SEC
)
{
return
;
}
if
(
s_verify_open_send_count
>=
VERIFY_OPEN_QUERY_MAX
)
{
my_zlog_warn
(
"验证开关查询(3013)已发送%d次仍未收到后端2013回复,停止重试"
,
VERIFY_OPEN_QUERY_MAX
);
s_verify_open_query_gave_up
=
true
;
return
;
}
verify_open_query_send_once
();
}
int
mqtt_verify_clear_send
(
char
*
status
){
...
...
@@ -366,7 +411,7 @@ void mqtt_verify_data_clear(cJSON *body){
mqtt_verify_clear_send
(
"0"
);
}
}
else
{
my_zlog_
info
(
"verify_clear_item 字段不存在或不是字符串类型"
);
my_zlog_
warn
(
"verify_clear_item 字段不存在或不是字符串类型"
);
mqtt_verify_clear_send
(
"2"
);
}
}
...
...
modules/mqtt/mqtt_verify.h
View file @
279aa042
...
...
@@ -21,8 +21,11 @@ int message2006_verify(cJSON *body);
/*接收到是否打开验证的函数*/
int
message2013_recverigy_open
(
cJSON
*
body
);
/*发送是否打开验证的mqtt给后端验证初始化*/
/*发送是否打开验证的mqtt给后端验证初始化
(首次发送3013)
*/
int
verify_open_index_init
();
/* 心跳线程轮询:未收到2013则按间隔重试,最多3次 */
void
verify_open_query_poll
(
void
);
void
mqtt_verify_data_clear
(
cJSON
*
body
);
#endif
\ No newline at end of file
zlog.conf
View file @
279aa042
...
...
@@ -9,4 +9,4 @@ file perms = 600
millisecond
=
"%d(%Y-%m-%d %H:%M:%S).%ms [%V] %m%n"
[
rules
]
my_log
.*
"/home/orangepi/car/master/log/log_2026-05-
08
.log"
;
millisecond
my_log
.*
"/home/orangepi/car/master/log/log_2026-05-
22
.log"
;
millisecond
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