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
b332cc9b
Commit
b332cc9b
authored
May 10, 2025
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入了mqtt的设备更改,但是没有回退
parent
438d9a5e
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
12 additions
and
46 deletions
+12
-46
.gitignore
.gitignore
+2
-0
compiler_depend.internal
build/CMakeFiles/main.dir/compiler_depend.internal
+1
-0
compiler_depend.make
build/CMakeFiles/main.dir/compiler_depend.make
+1
-0
device_change.c.o
.../CMakeFiles/main.dir/device_judg/device/device_change.c.o
+0
-0
download.c.o
build/CMakeFiles/main.dir/src/download.c.o
+0
-0
download.c.o.d
build/CMakeFiles/main.dir/src/download.c.o.d
+1
-0
main
build/main
+0
-0
device_change.c
device_judg/device/device_change.c
+3
-9
device_change.h
device_judg/device/device_change.h
+3
-0
download.c
src/download.c
+1
-37
No files found.
.gitignore
View file @
b332cc9b
log
deviceback
loghttp
Deviceld.txt
\ No newline at end of file
build/CMakeFiles/main.dir/compiler_depend.internal
View file @
b332cc9b
...
...
@@ -1265,6 +1265,7 @@ CMakeFiles/main.dir/src/download.c.o
/home/orangepi/car/master/src/download.c
/usr/include/stdc-predef.h
/home/orangepi/car/master/include/download.h
/home/orangepi/car/master/device_judg/device/device_change.h
/home/orangepi/car/master/include/common.h
/usr/include/stdio.h
/usr/include/aarch64-linux-gnu/bits/libc-header-start.h
...
...
build/CMakeFiles/main.dir/compiler_depend.make
View file @
b332cc9b
...
...
@@ -1256,6 +1256,7 @@ CMakeFiles/main.dir/src/delay.c.o: ../src/delay.c \
CMakeFiles/main.dir/src/download.c.o
:
../src/download.c
\
/usr/include/stdc-predef.h
\
../include/download.h
\
../device_judg/device/device_change.h
\
../include/common.h
\
/usr/include/stdio.h
\
/usr/include/aarch64-linux-gnu/bits/libc-header-start.h
\
...
...
build/CMakeFiles/main.dir/device_judg/device/device_change.c.o
View file @
b332cc9b
No preview for this file type
build/CMakeFiles/main.dir/src/download.c.o
View file @
b332cc9b
No preview for this file type
build/CMakeFiles/main.dir/src/download.c.o.d
View file @
b332cc9b
CMakeFiles
/
main
.
dir
/
src
/
download
.
c
.
o
:
\
/
home
/
orangepi
/
car
/
master
/
src
/
download
.
c
/
usr
/
include
/
stdc
-
predef
.
h
\
/
home
/
orangepi
/
car
/
master
/
include
/
download
.
h
\
/
home
/
orangepi
/
car
/
master
/
device_judg
/
device
/
device_change
.
h
\
/
home
/
orangepi
/
car
/
master
/
include
/
common
.
h
/
usr
/
include
/
stdio
.
h
\
/
usr
/
include
/
aarch64
-
linux
-
gnu
/
bits
/
libc
-
header
-
start
.
h
\
/
usr
/
include
/
features
.
h
/
usr
/
include
/
features
-
time64
.
h
\
...
...
build/main
View file @
b332cc9b
No preview for this file type
device_judg/device/device_change.c
View file @
b332cc9b
...
...
@@ -4,15 +4,6 @@
#include "common.h"
#include "device_change.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <dirent.h>
#include <time.h>
#define BUFFER_SIZE 1024
// 判断文件是否存在
...
...
@@ -184,6 +175,9 @@ int write_device_id(const char *path, const char *device_id) {
fprintf
(
f
,
"%s"
,
device_id
);
fclose
(
f
);
my_zlog_debug
(
"成功写入设备ID到 %s"
,
path
);
system
(
"sudo reboot"
);
return
0
;
}
...
...
device_judg/device/device_change.h
View file @
b332cc9b
...
...
@@ -5,4 +5,6 @@
#define DEVICE_NAME_DIR "/home/orangepi/car/master/deviceback"
#define DEVICE_NAME_FILE "/home/orangepi/car/master/Deviceld.txt"
int
device_changename_back
(
const
char
*
device_date
,
const
char
*
device_id
);
int
file_exists
(
const
char
*
path
);
int
create_directory_if_not_exists
(
const
char
*
path
);
#endif
\ No newline at end of file
src/download.c
View file @
b332cc9b
#include "download.h"
#include "device_change.h"
#include "common.h"
// 用于存储下载数据的结构体
...
...
@@ -26,43 +27,6 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, voi
return
realsize
;
}
// 检查并创建日志目录
int
create_directory_if_not_exists
(
const
char
*
path
)
{
char
temp
[
1024
];
size_t
len
=
strlen
(
path
);
if
(
len
>=
sizeof
(
temp
))
{
my_zlog_error
(
"路径过长: %s"
,
path
);
return
-
1
;
}
// 拷贝路径并保证以 '/' 结尾
strncpy
(
temp
,
path
,
sizeof
(
temp
));
if
(
temp
[
len
-
1
]
!=
'/'
)
{
temp
[
len
]
=
'/'
;
temp
[
len
+
1
]
=
'\0'
;
len
++
;
}
for
(
size_t
i
=
1
;
i
<
len
;
i
++
)
{
if
(
temp
[
i
]
==
'/'
)
{
temp
[
i
]
=
'\0'
;
if
(
access
(
temp
,
F_OK
)
!=
0
)
{
if
(
mkdir
(
temp
,
0755
)
!=
0
)
{
my_zlog_error
(
"创建目录失败: %s (%s)"
,
temp
,
strerror
(
errno
));
return
-
1
;
}
else
{
my_zlog_debug
(
"已创建目录: %s"
,
temp
);
}
}
temp
[
i
]
=
'/'
;
}
}
return
0
;
}
int
download_file
(
const
char
*
url
,
const
char
*
target_dir
,
const
char
*
filename
)
{
// 创建目标目录(如果不存在)
if
(
create_directory_if_not_exists
(
target_dir
)
==
-
1
)
{
...
...
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