Commit 438d9a5e authored by 957dd's avatar 957dd

3

parent b0ceaf43
......@@ -296,6 +296,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o
/usr/include/aarch64-linux-gnu/bits/local_lim.h
/usr/include/linux/limits.h
/usr/include/aarch64-linux-gnu/bits/posix2_lim.h
/usr/include/aarch64-linux-gnu/bits/xopen_lim.h
/usr/include/aarch64-linux-gnu/bits/uio_lim.h
/usr/include/aarch64-linux-gnu/sys/time.h
/usr/include/aarch64-linux-gnu/curl/easy.h
/usr/include/aarch64-linux-gnu/curl/multi.h
......@@ -311,7 +313,6 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o
/home/orangepi/car/master/include/log.h
/home/orangepi/car/master/include/delay.h
/home/orangepi/car/master/device_judg/device/device_change.h
/home/orangepi/car/master/include/download.h
CMakeFiles/main.dir/device_judg/device/pao.c.o
/home/orangepi/car/master/device_judg/device/pao.c
......@@ -2040,6 +2041,7 @@ CMakeFiles/main.dir/src/mqtt.c.o
/usr/include/cjson/cJSON.h
/home/orangepi/car/master/system/sensor/warm.h
/home/orangepi/car/master/include/fileopen.h
/home/orangepi/car/master/device_judg/device/device_change.h
/home/orangepi/car/master/device_judg/judg/judg.h
CMakeFiles/main.dir/src/opensh.c.o
......
......@@ -294,6 +294,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: ../device_judg/device/
/usr/include/aarch64-linux-gnu/bits/local_lim.h \
/usr/include/linux/limits.h \
/usr/include/aarch64-linux-gnu/bits/posix2_lim.h \
/usr/include/aarch64-linux-gnu/bits/xopen_lim.h \
/usr/include/aarch64-linux-gnu/bits/uio_lim.h \
/usr/include/aarch64-linux-gnu/sys/time.h \
/usr/include/aarch64-linux-gnu/curl/easy.h \
/usr/include/aarch64-linux-gnu/curl/multi.h \
......@@ -308,8 +310,7 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: ../device_judg/device/
../system/gpio/gpio_common.h \
../include/log.h \
../include/delay.h \
../device_judg/device/device_change.h \
../include/download.h
../device_judg/device/device_change.h
CMakeFiles/main.dir/device_judg/device/pao.c.o: ../device_judg/device/pao.c \
/usr/include/stdc-predef.h \
......@@ -2027,6 +2028,7 @@ CMakeFiles/main.dir/src/mqtt.c.o: ../src/mqtt.c \
/usr/include/cjson/cJSON.h \
../system/sensor/warm.h \
../include/fileopen.h \
../device_judg/device/device_change.h \
../device_judg/judg/judg.h
CMakeFiles/main.dir/src/opensh.c.o: ../src/opensh.c \
......@@ -6632,10 +6634,6 @@ CMakeFiles/main.dir/zlog/src/zlog.c.o: ../zlog/src/zlog.c \
../device_judg/device/device_change.h:
../include/download.h:
../system/sensor/heat.h:
../device_judg/device/pao.c:
../include/ip.h:
......@@ -6652,6 +6650,10 @@ CMakeFiles/main.dir/zlog/src/zlog.c.o: ../zlog/src/zlog.c \
../src/download.c:
../include/download.h:
../system/sensor/heat.h:
/usr/include/aarch64-linux-gnu/bits/getopt_posix.h:
../src/fileopen.c:
......
......@@ -116,6 +116,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: \
/usr/include/aarch64-linux-gnu/bits/local_lim.h \
/usr/include/linux/limits.h \
/usr/include/aarch64-linux-gnu/bits/posix2_lim.h \
/usr/include/aarch64-linux-gnu/bits/xopen_lim.h \
/usr/include/aarch64-linux-gnu/bits/uio_lim.h \
/usr/include/aarch64-linux-gnu/sys/time.h \
/usr/include/aarch64-linux-gnu/curl/easy.h \
/usr/include/aarch64-linux-gnu/curl/multi.h \
......@@ -129,5 +131,4 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: \
/home/orangepi/car/master/system/gpio/gpio_common.h \
/home/orangepi/car/master/include/log.h \
/home/orangepi/car/master/include/delay.h \
/home/orangepi/car/master/device_judg/device/device_change.h \
/home/orangepi/car/master/include/download.h
/home/orangepi/car/master/device_judg/device/device_change.h
......@@ -141,4 +141,5 @@ CMakeFiles/main.dir/src/mqtt.c.o: /home/orangepi/car/master/src/mqtt.c \
/usr/include/cjson/cJSON.h \
/home/orangepi/car/master/system/sensor/warm.h \
/home/orangepi/car/master/include/fileopen.h \
/home/orangepi/car/master/device_judg/device/device_change.h \
/home/orangepi/car/master/device_judg/judg/judg.h
......@@ -2,5 +2,5 @@
#define PROJECT_VERSION_MINOR 1
#define PROJECT_VERSION_PATCH 0
#define GIT_HASH ""
#define BUILD_TIMESTAMP "2025-05-08T12:02:23"
#define BUILD_TIMESTAMP "2025-05-10T08:31:49"
#define BUILD_USER "orangepi"
No preview for this file type
This diff is collapsed.
......@@ -3,8 +3,6 @@
#define DEVICE_NAME_DIR "/home/orangepi/car/master/deviceback"
int device_changename_back();
const char *find_latest_file(const char *dir_path);
#define DEVICE_NAME_FILE "/home/orangepi/car/master/Deviceld.txt"
int device_changename_back(const char *device_date, const char *device_id);
#endif
\ No newline at end of file
00010200000000
\ No newline at end of file
......@@ -3,6 +3,4 @@
int download_file(const char *url,const char *target_dir ,const char *filename) ;//下载文件
int file_exists(const char *path);//检查文件是否存在
int remove_file(const char *path); // 删除文件
#endif
\ No newline at end of file
......@@ -27,44 +27,39 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, voi
}
// 检查文件是否存在
int file_exists(const char *path) {
return access(path, F_OK) == 0;
}
// 检查并创建日志目录
int create_directory_if_not_exists(const char *path) {
char temp[1024];
size_t len = strlen(path);
// 删除文件
int remove_file(const char *path) {
if (remove(path) == 0) {
return 1;
} else {
my_zlog_warn("删除文件失败");
return 0;
if (len >= sizeof(temp)) {
my_zlog_error("路径过长: %s", path);
return -1;
}
}
// 检查并创建日志目录
static int create_directory_if_not_exists(const char *path) {
char dir_path[256] = {0};
const char *p = path;
char *q = dir_path;
// 提取目录部分
while (*p != '\0') {
*q = *p;
if (*p == '/' && *(p+1) != '\0') {
// 检查并创建每一级目录
if (access(dir_path, F_OK) != 0) {
if (mkdir(dir_path, 0755) != 0) {
fprintf(stderr, "Failed to create directory: %s\n", dir_path);
my_zlog_error("创建目录失败");
// 拷贝路径并保证以 '/' 结尾
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] = '/';
}
p++;
q++;
}
return 0;
}
......
......@@ -10,6 +10,7 @@
#include "mqtt.h"
#include "warm.h"
#include "fileopen.h"
#include "device_change.h"
#include "judg.h"
struct mosquitto *mosq;
......@@ -43,9 +44,6 @@ char *glon=NULL;//加入gps后删除,心跳预留,不更改
time_t gStart;//时间戳
char *gdevice_change_id=NULL;
char *gdevice_change_date=NULL;
int mqtt_init() {
// 初始化 mosquitto 库
mosquitto_lib_init();
......@@ -176,7 +174,7 @@ void message_4(cJSON *body, cJSON *pin_setctrl){//message 为4时候
pwm_value(gvalt[1],gvalt[2]);
}
int device_message(cJSON *json){
int device_message(cJSON *json){//接收到的控制设备的mqtt消息
cJSON *head = cJSON_GetObjectItem(json, "head");
cJSON *message_type = cJSON_GetObjectItem(head, "message_type");
......@@ -221,7 +219,7 @@ int device_message(cJSON *json){
return 0;
}
int download_message(cJSON *root){
int download_message(cJSON *root){//接收的下载的mqtt消息
cJSON *down = cJSON_GetObjectItem(root, "down");
if (cJSON_IsObject(down)) {
// 获取 site 对象
......@@ -254,14 +252,16 @@ int download_message(cJSON *root){
return 0;
}
int device_mqttchange_name(cJSON *device_id){
cJSON *id = cJSON_GetObjectItem(device_id, "id");// 提取ID
cJSON *date = cJSON_GetObjectItem(device_id, "date");// 提取日期
*gdevice_change_id=id->valuestring;
*gdevice_change_date=date->valuestring;
char *device_change_id=id->valuestring;
char *device_change_date=date->valuestring;
device_changename_back(device_change_date,device_change_id);
// 输出提取的数据
printf("设备ID: %s\n", id->valuestring);
printf("日期: %s\n", date->valuestring);
my_zlog_debug("设备ID: %s", device_change_id);
my_zlog_debug("日期: %s", device_change_date);
return 0;
}
......@@ -293,7 +293,7 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
} else if(cJSON_GetObjectItem(json, "device_id") != NULL) {
cJSON *device_id=cJSON_GetObjectItem(json, "device_id");
device_mqttchange_name(device_id);
my_zlog_debug("接收到设备更改");
my_zlog_debug("接收到设备更改");
} else {// 提取 head 对象
if(download_message(json) != 1) my_zlog_debug("接收到dowwnload下载");
if(device_message(json) != 0) my_zlog_debug("没有接收到控制信息,代码编号:%d",device_message(json));
......
......@@ -14,7 +14,7 @@ void car0102_calculate_L_R(int angle) {//将角度转化为对应的舵机pwm值
pwmWrite(PWM_PIN_CHANGE,val);
}
void car0102_speed_stop() {
pin_value(26,0);
//pin_value(26,0);
pwmWrite(PWM_PIN_SPEED,0);
car0102_calculate_L_R(90);
}
......
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