Commit c9aa0c81 authored by 学习的菜鸟's avatar 学习的菜鸟

逐步重构

parent f46f5a10
...@@ -49,7 +49,7 @@ include_directories( ...@@ -49,7 +49,7 @@ include_directories(
modules/thread_pool modules/thread_pool
modules/mqtt modules/mqtt
modules/http modules/http
modules/brower modules/browser
third_party/zlog/src third_party/zlog/src
third_party/mosquitto/include third_party/mosquitto/include
third_party/mosquitto/lib third_party/mosquitto/lib
...@@ -66,7 +66,7 @@ file(GLOB_RECURSE SOURCES ...@@ -66,7 +66,7 @@ file(GLOB_RECURSE SOURCES
modules/thread_pool/*.c modules/thread_pool/*.c
modules/mqtt/*.c modules/mqtt/*.c
modules/http/*.c modules/http/*.c
modules/brower/*.c modules/browser/*.c
app/device_identity/*.c app/device_identity/*.c
app/device_change/*.c app/device_change/*.c
app/main/*.c app/main/*.c
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "common.h" #include "common.h"
#include "device_id_change.h" #include "device_id_change.h"
#include "delay.h"
#define BUFFER_SIZE 1024 #define BUFFER_SIZE 1024
......
#include <cjson/cJSON.h> #include "device_wifi_change.h"
#include "wifichange.h" #include "device_identity.h"
#include "mqtt.h" #include "mqtt_init.h"
#include "common.h" #include "common.h"
#include "judg.h" #include "delay.h"
char current_ssid[SSID_MAX_LEN] = {0};//用于存现在已连接WiFi char current_ssid[SSID_MAX_LEN] = {0};//用于存现在已连接WiFi
char wifi_Last_ssid[SSID_MAX_LEN]= {0} ; char wifi_Last_ssid[SSID_MAX_LEN]= {0} ;
...@@ -107,8 +107,7 @@ void scan_wifi_json() { ...@@ -107,8 +107,7 @@ void scan_wifi_json() {
char *json_str = cJSON_Print(root); char *json_str = cJSON_Print(root);
if (json_str) { if (json_str) {
my_zlog_debug("%s", json_str); my_zlog_debug("%s", json_str);
topic_middle_value(); mosquitto_publish(mosq, NULL, mqtt_topic_pure_number(), strlen(json_str), json_str, 0, false);
mosquitto_publish(mosq, NULL, TOPIC3, strlen(json_str), json_str, 0, false);
free(json_str); free(json_str);
} }
cJSON_Delete(root); cJSON_Delete(root);
...@@ -368,7 +367,6 @@ int compare_ssid_with_file() { ...@@ -368,7 +367,6 @@ int compare_ssid_with_file() {
,5为密码错误,6为未知错误,7为回退失败,8为没网切回默认wifi*/ ,5为密码错误,6为未知错误,7为回退失败,8为没网切回默认wifi*/
void wifichange_sendmqtt(int wifi_status) { //改WiFi发送 void wifichange_sendmqtt(int wifi_status) { //改WiFi发送
topic_middle_value();//指针中间函数
get_current_wifi(); get_current_wifi();
cJSON *root = cJSON_CreateObject(); cJSON *root = cJSON_CreateObject();
cJSON *body = cJSON_CreateObject(); cJSON *body = cJSON_CreateObject();
...@@ -384,7 +382,7 @@ void wifichange_sendmqtt(int wifi_status) { //改WiFi发送 ...@@ -384,7 +382,7 @@ void wifichange_sendmqtt(int wifi_status) { //改WiFi发送
char *payload = cJSON_PrintUnformatted(root); char *payload = cJSON_PrintUnformatted(root);
my_zlog_debug("%s",payload); my_zlog_debug("%s",payload);
mosquitto_publish(mosq, NULL, TOPIC3, strlen(payload), payload, 0, false); mosquitto_publish(mosq, NULL, mqtt_topic_pure_number(), strlen(payload), payload, 0, false);
cJSON_Delete(root); // 释放 cJSON 对象 cJSON_Delete(root); // 释放 cJSON 对象
} }
...@@ -394,7 +392,7 @@ void connect_wifi_jking() { ...@@ -394,7 +392,7 @@ void connect_wifi_jking() {
if(check_or_create_wifi_conf() == 0) my_zlog_debug("文件已创建"); if(check_or_create_wifi_conf() == 0) my_zlog_debug("文件已创建");
if(write_wifi_conf() == 0) my_zlog_debug("写入成功"); if(write_wifi_conf() == 0) my_zlog_debug("写入成功");
int ret=change_wifi_connect(default_SSID,default_password); int ret=change_wifi_connect(default_SSID,default_password);
Delay_Ms(15,0); delay_s(15);
if(can_access_internet()==0) { if(can_access_internet()==0) {
system("sudo reboot");//重启香橙派 system("sudo reboot");//重启香橙派
my_zlog_debug("重启成功"); my_zlog_debug("重启成功");
...@@ -423,7 +421,7 @@ int wifi_change_sendmqtt_init(){ ...@@ -423,7 +421,7 @@ int wifi_change_sendmqtt_init(){
if(strcmp(default_SSID,current_ssid)==0){ if(strcmp(default_SSID,current_ssid)==0){
extract_wifi_file(); extract_wifi_file();
if(change_wifi_connect(wifi_Last_ssid,wifi_Last_password)==0){ if(change_wifi_connect(wifi_Last_ssid,wifi_Last_password)==0){
Delay_Ms(15,0); delay_s(15);
if(can_access_internet()==0){ if(can_access_internet()==0){
delete_wifi_by_ssid(current_ssid); delete_wifi_by_ssid(current_ssid);
delete_wifi_conf(); delete_wifi_conf();
...@@ -445,7 +443,7 @@ int wifi_change_sendmqtt_init(){ ...@@ -445,7 +443,7 @@ int wifi_change_sendmqtt_init(){
}else { }else {
if(change_wifi_connect(default_SSID,default_password)==0)delete_wifi_conf(); if(change_wifi_connect(default_SSID,default_password)==0)delete_wifi_conf();
my_zlog_debug("WiFi无网切回"); my_zlog_debug("WiFi无网切回");
Delay_Ms(10,0); delay_s(10); ;
} }
} }
...@@ -476,7 +474,7 @@ void wifi_change_recmqtt(cJSON *body){ ...@@ -476,7 +474,7 @@ void wifi_change_recmqtt(cJSON *body){
if(check_or_create_wifi_conf() == 0) my_zlog_debug("文件已创建"); if(check_or_create_wifi_conf() == 0) my_zlog_debug("文件已创建");
if(write_wifi_conf() == 0) my_zlog_debug("写入成功"); if(write_wifi_conf() == 0) my_zlog_debug("写入成功");
int ret = change_wifi_connect(ssid,password); int ret = change_wifi_connect(ssid,password);
Delay_Ms(15,0); delay_s(15);
if(strcmp(default_SSID,ssid)==0){ if(strcmp(default_SSID,ssid)==0){
delete_wifi_by_ssid(current_ssid); delete_wifi_by_ssid(current_ssid);
my_zlog_debug("ssid:%S",current_ssid); my_zlog_debug("ssid:%S",current_ssid);
...@@ -494,7 +492,7 @@ void wifi_change_recmqtt(cJSON *body){ ...@@ -494,7 +492,7 @@ void wifi_change_recmqtt(cJSON *body){
delete_wifi_conf(); delete_wifi_conf();
if(change_wifi_connect(default_SSID,default_password)==0) delete_wifi_by_ssid(current_ssid); if(change_wifi_connect(default_SSID,default_password)==0) delete_wifi_by_ssid(current_ssid);
my_zlog_debug("无网切回默认WiFi"); my_zlog_debug("无网切回默认WiFi");
Delay_Ms(15,0); delay_s(15);
wifichange_sendmqtt(8); wifichange_sendmqtt(8);
} }
} }
......
#ifndef WIFICHANGE_H__ #ifndef DEVICE_WIFI_CHANGE_H__
#define WIFICHANGE_H__ #define DEVICE_WIFI_CHANGE_H__
#include <cjson/cJSON.h> #include "cjson/cJSON.h"
#define SSID_MAX_LEN 128 #define SSID_MAX_LEN 128
#define PASS_MAX_LEN 128 #define PASS_MAX_LEN 128
......
#include "device_fileopen.h" #include "device_fileopen.h"
#include "common.h" #include "common.h"
#include "mylog.h"
#include "delay.h" #include "delay.h"
#define FILENAME "/home/orangepi/car/master/Deviceld.txt" #define FILENAME "/home/orangepi/car/master/Deviceld.txt"
......
#include "common.h" #include "common.h"
#include "devcontrol_common.h"
#include "device_identity.h" #include "device_identity.h"
#include "device_fileopen.h" #include "device_fileopen.h"
#include "device_init.h"
#include "delay.h" #include "delay.h"
#include "mylog.h"
char g_app2dev_topic[23]; char g_app2dev_topic[23];
char g_dev2app_topic[23]; char g_dev2app_topic[23];
...@@ -100,7 +101,8 @@ int hash_insert_init(HashTable_t *HashTable_t) { ...@@ -100,7 +101,8 @@ int hash_insert_init(HashTable_t *HashTable_t) {
int device_judg(CodeEnum_t code,char *sub_str) { int device_judg(CodeEnum_t code,char *sub_str) {
if (code == CAR_0101) { if (code == CAR_0101) {
//car_Init_0101(); device_init(DEVICE_CAR0101);
my_zlog_info("使用型号%s",sub_str); my_zlog_info("使用型号%s",sub_str);
}else if(code == CAR_0102) { }else if(code == CAR_0102) {
//car_Init_0102(); //car_Init_0102();
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "common.h" #include "common.h"
#include "device_fileopen.h" #include "device_fileopen.h"
#include "mylog.h"
#include "device_identity.h" #include "device_identity.h"
#include "pthread_open.h" #include "pthread_open.h"
......
#include "common.h" #include "common.h"
#include "delay.h" #include "delay.h"
#include "pthread_open.h" #include "pthread_open.h"
#include "mylog.h"
#include "mqtt_init.h" #include "mqtt_init.h"
#include "mqtt_infor_handle.h" #include "mqtt_infor_handle.h"
#include "browser_open.h" #include "browser_open.h"
#include "mqtt_verify.h" #include "mqtt_verify.h"
#include "device_wifi_change.h"
#include "browser_open.h"
pthread_t g_thread[6]; // 全局线程句柄数组(或传参) pthread_t g_thread[6]; // 全局线程句柄数组(或传参)
...@@ -44,7 +46,7 @@ void *thread_exit_time(void *arg) { ...@@ -44,7 +46,7 @@ void *thread_exit_time(void *arg) {
delay_ms(100); delay_ms(100);
g_devcontrol_exit_count++; g_devcontrol_exit_count++;
if(g_devcontrol_exit_count>=5) { if(g_devcontrol_exit_count>=5) {
device_warn_exit(); //device_warn_exit();
g_devcontrol_exit_count=6; g_devcontrol_exit_count=6;
} }
} }
...@@ -53,13 +55,13 @@ void *thread_exit_time(void *arg) { ...@@ -53,13 +55,13 @@ void *thread_exit_time(void *arg) {
void *thread_mqtt_beat(void *arg) { void *thread_mqtt_beat(void *arg) {
my_zlog_info("thread_mqtt_beat start"); my_zlog_info("thread_mqtt_beat start");
//wifi_change_sendmqtt_init(); wifi_change_sendmqtt_init();
delay_s(5); delay_s(5);
g_webrtc_index=1; g_webrtc_index=1;
int device_type=0;
while(1) { while(1) {
//if( AppExit_pin_pwm == 202) delay_ms(45); if( device_type == 202) delay_ms(45);
//if( AppExit_pin_pwm != 202) if( device_type != 202)delay_ms(100);
delay_ms(100);
g_heartbeat_count++; g_heartbeat_count++;
if(g_mqtt_grc == 0){ if(g_mqtt_grc == 0){
......
This diff is collapsed.
No preview for this file type
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 = 80
CMAKE_PROGRESS_3 = 79 CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = 80 CMAKE_PROGRESS_5 = 81
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 =
CMAKE_PROGRESS_8 = 81 CMAKE_PROGRESS_8 = 82
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = 82 CMAKE_PROGRESS_10 =
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 = 83
CMAKE_PROGRESS_12 = CMAKE_PROGRESS_12 =
CMAKE_PROGRESS_13 = 83 CMAKE_PROGRESS_13 = 84
CMAKE_PROGRESS_1 = 89 CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 = 90
CMAKE_PROGRESS_3 = CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = 90 CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = CMAKE_PROGRESS_5 = 91
CMAKE_PROGRESS_6 = 91 CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 =
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 = 93
CMAKE_PROGRESS_3 = 93 CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 = 94
CMAKE_PROGRESS_5 = 94 CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 = 95
CMAKE_PROGRESS_3 = 95 CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = 96 CMAKE_PROGRESS_5 = 96
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
......
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 = 97
CMAKE_PROGRESS_2 = 97 CMAKE_PROGRESS_2 =
CMAKE_PROGRESS_3 = CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = 98 CMAKE_PROGRESS_4 = 98
CMAKE_PROGRESS_5 = CMAKE_PROGRESS_5 =
......
...@@ -3,43 +3,43 @@ CMAKE_PROGRESS_2 = ...@@ -3,43 +3,43 @@ CMAKE_PROGRESS_2 =
CMAKE_PROGRESS_3 = CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = 2 CMAKE_PROGRESS_4 = 2
CMAKE_PROGRESS_5 = CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = 3 CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 = 3
CMAKE_PROGRESS_8 = CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = 4 CMAKE_PROGRESS_9 = 4
CMAKE_PROGRESS_10 = CMAKE_PROGRESS_10 =
CMAKE_PROGRESS_11 = 5 CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12 = CMAKE_PROGRESS_12 = 5
CMAKE_PROGRESS_13 = CMAKE_PROGRESS_13 =
CMAKE_PROGRESS_14 = 6 CMAKE_PROGRESS_14 =
CMAKE_PROGRESS_15 = CMAKE_PROGRESS_15 = 6
CMAKE_PROGRESS_16 = 7 CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17 = CMAKE_PROGRESS_17 = 7
CMAKE_PROGRESS_18 = CMAKE_PROGRESS_18 =
CMAKE_PROGRESS_19 = 8 CMAKE_PROGRESS_19 =
CMAKE_PROGRESS_20 = CMAKE_PROGRESS_20 = 8
CMAKE_PROGRESS_21 = CMAKE_PROGRESS_21 =
CMAKE_PROGRESS_22 = 9 CMAKE_PROGRESS_22 =
CMAKE_PROGRESS_23 = CMAKE_PROGRESS_23 = 9
CMAKE_PROGRESS_24 = 10 CMAKE_PROGRESS_24 =
CMAKE_PROGRESS_25 = CMAKE_PROGRESS_25 = 10
CMAKE_PROGRESS_26 = CMAKE_PROGRESS_26 =
CMAKE_PROGRESS_27 = 11 CMAKE_PROGRESS_27 =
CMAKE_PROGRESS_28 = CMAKE_PROGRESS_28 = 11
CMAKE_PROGRESS_29 = 12 CMAKE_PROGRESS_29 =
CMAKE_PROGRESS_30 = CMAKE_PROGRESS_30 =
CMAKE_PROGRESS_31 = CMAKE_PROGRESS_31 = 12
CMAKE_PROGRESS_32 = 13 CMAKE_PROGRESS_32 =
CMAKE_PROGRESS_33 = CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34 = 14 CMAKE_PROGRESS_34 = 13
CMAKE_PROGRESS_35 = CMAKE_PROGRESS_35 =
CMAKE_PROGRESS_36 = CMAKE_PROGRESS_36 = 14
CMAKE_PROGRESS_37 = 15 CMAKE_PROGRESS_37 =
CMAKE_PROGRESS_38 = CMAKE_PROGRESS_38 =
CMAKE_PROGRESS_39 = CMAKE_PROGRESS_39 = 15
CMAKE_PROGRESS_40 = 16 CMAKE_PROGRESS_40 =
CMAKE_PROGRESS_41 = CMAKE_PROGRESS_41 =
CMAKE_PROGRESS_42 = 17 CMAKE_PROGRESS_42 = 16
CMAKE_PROGRESS_43 = CMAKE_PROGRESS_43 =
CMAKE_PROGRESS_44 = CMAKE_PROGRESS_44 = 17
CMAKE_PROGRESS_1 = 18 CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 =
CMAKE_PROGRESS_3 = 19 CMAKE_PROGRESS_3 = 18
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = 20 CMAKE_PROGRESS_6 = 19
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 =
CMAKE_PROGRESS_8 = 21 CMAKE_PROGRESS_8 = 20
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = CMAKE_PROGRESS_10 =
CMAKE_PROGRESS_11 = 22 CMAKE_PROGRESS_11 = 21
CMAKE_PROGRESS_12 = CMAKE_PROGRESS_12 =
CMAKE_PROGRESS_13 = CMAKE_PROGRESS_13 =
CMAKE_PROGRESS_14 = 23 CMAKE_PROGRESS_14 = 22
CMAKE_PROGRESS_15 = CMAKE_PROGRESS_15 =
CMAKE_PROGRESS_16 = 24 CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17 = CMAKE_PROGRESS_17 = 23
CMAKE_PROGRESS_18 = CMAKE_PROGRESS_18 =
CMAKE_PROGRESS_19 = 25 CMAKE_PROGRESS_19 = 24
CMAKE_PROGRESS_20 = CMAKE_PROGRESS_20 =
CMAKE_PROGRESS_21 = 26 CMAKE_PROGRESS_21 =
CMAKE_PROGRESS_22 = CMAKE_PROGRESS_22 = 25
CMAKE_PROGRESS_23 = CMAKE_PROGRESS_23 =
CMAKE_PROGRESS_24 = 27 CMAKE_PROGRESS_24 =
CMAKE_PROGRESS_25 = CMAKE_PROGRESS_25 = 26
CMAKE_PROGRESS_26 = 28 CMAKE_PROGRESS_26 =
CMAKE_PROGRESS_27 = CMAKE_PROGRESS_27 = 27
CMAKE_PROGRESS_28 = CMAKE_PROGRESS_28 =
CMAKE_PROGRESS_29 = 29 CMAKE_PROGRESS_29 =
CMAKE_PROGRESS_30 = CMAKE_PROGRESS_30 = 28
CMAKE_PROGRESS_31 = CMAKE_PROGRESS_31 =
CMAKE_PROGRESS_32 = 30 CMAKE_PROGRESS_32 =
CMAKE_PROGRESS_33 = CMAKE_PROGRESS_33 = 29
CMAKE_PROGRESS_34 = 31 CMAKE_PROGRESS_34 =
CMAKE_PROGRESS_35 = CMAKE_PROGRESS_35 = 30
CMAKE_PROGRESS_36 = CMAKE_PROGRESS_36 =
CMAKE_PROGRESS_37 = 32 CMAKE_PROGRESS_37 =
CMAKE_PROGRESS_38 = CMAKE_PROGRESS_38 = 31
CMAKE_PROGRESS_39 = 33 CMAKE_PROGRESS_39 =
CMAKE_PROGRESS_40 = CMAKE_PROGRESS_40 =
CMAKE_PROGRESS_41 = CMAKE_PROGRESS_41 = 32
CMAKE_PROGRESS_42 = 34 CMAKE_PROGRESS_42 =
CMAKE_PROGRESS_43 = CMAKE_PROGRESS_43 =
CMAKE_PROGRESS_44 = 35 CMAKE_PROGRESS_44 = 33
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = 84 CMAKE_PROGRESS_2 =
CMAKE_PROGRESS_3 = CMAKE_PROGRESS_3 = 85
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = 85 CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 = 86
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 =
CMAKE_PROGRESS_8 = 86 CMAKE_PROGRESS_8 = 87
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = 87 CMAKE_PROGRESS_10 =
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 = 88
CMAKE_PROGRESS_12 = CMAKE_PROGRESS_12 =
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 = 52
CMAKE_PROGRESS_3 = 50 CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = CMAKE_PROGRESS_5 = 53
CMAKE_PROGRESS_6 = 51 CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 = 54
CMAKE_PROGRESS_8 = 52 CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = CMAKE_PROGRESS_10 = 55
CMAKE_PROGRESS_11 = 53 CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12 = CMAKE_PROGRESS_12 =
CMAKE_PROGRESS_13 = 54 CMAKE_PROGRESS_13 = 56
CMAKE_PROGRESS_14 = CMAKE_PROGRESS_14 =
CMAKE_PROGRESS_15 = CMAKE_PROGRESS_15 = 57
CMAKE_PROGRESS_16 = 55 CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17 = CMAKE_PROGRESS_17 =
CMAKE_PROGRESS_18 = 56 CMAKE_PROGRESS_18 = 58
CMAKE_PROGRESS_19 = CMAKE_PROGRESS_19 =
CMAKE_PROGRESS_20 = CMAKE_PROGRESS_20 =
CMAKE_PROGRESS_21 = 57 CMAKE_PROGRESS_21 = 59
CMAKE_PROGRESS_22 = CMAKE_PROGRESS_22 =
CMAKE_PROGRESS_23 = CMAKE_PROGRESS_23 = 60
CMAKE_PROGRESS_24 = 58 CMAKE_PROGRESS_24 =
CMAKE_PROGRESS_25 = CMAKE_PROGRESS_25 =
CMAKE_PROGRESS_26 = 59 CMAKE_PROGRESS_26 = 61
CMAKE_PROGRESS_27 = CMAKE_PROGRESS_27 =
CMAKE_PROGRESS_28 = CMAKE_PROGRESS_28 =
CMAKE_PROGRESS_29 = 60 CMAKE_PROGRESS_29 = 62
CMAKE_PROGRESS_30 = CMAKE_PROGRESS_30 =
CMAKE_PROGRESS_31 = 61 CMAKE_PROGRESS_31 =
CMAKE_PROGRESS_32 = CMAKE_PROGRESS_32 = 63
CMAKE_PROGRESS_33 = CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34 = 62 CMAKE_PROGRESS_34 = 64
CMAKE_PROGRESS_35 = CMAKE_PROGRESS_35 =
CMAKE_PROGRESS_36 = 63 CMAKE_PROGRESS_36 =
CMAKE_PROGRESS_37 = CMAKE_PROGRESS_37 = 65
CMAKE_PROGRESS_38 = CMAKE_PROGRESS_38 =
CMAKE_PROGRESS_39 = 64 CMAKE_PROGRESS_39 =
CMAKE_PROGRESS_40 = CMAKE_PROGRESS_40 = 66
CMAKE_PROGRESS_41 = CMAKE_PROGRESS_41 =
CMAKE_PROGRESS_42 = 65 CMAKE_PROGRESS_42 = 67
CMAKE_PROGRESS_43 = CMAKE_PROGRESS_43 =
CMAKE_PROGRESS_44 = 66 CMAKE_PROGRESS_44 =
CMAKE_PROGRESS_45 = CMAKE_PROGRESS_45 = 68
CMAKE_PROGRESS_46 = CMAKE_PROGRESS_46 =
CMAKE_PROGRESS_47 = 67 CMAKE_PROGRESS_47 =
CMAKE_PROGRESS_48 = CMAKE_PROGRESS_48 = 69
CMAKE_PROGRESS_49 = 68 CMAKE_PROGRESS_49 =
CMAKE_PROGRESS_50 = CMAKE_PROGRESS_50 = 70
CMAKE_PROGRESS_51 = CMAKE_PROGRESS_51 =
CMAKE_PROGRESS_52 = 69 CMAKE_PROGRESS_52 =
CMAKE_PROGRESS_53 = CMAKE_PROGRESS_53 = 71
CMAKE_PROGRESS_54 = 70 CMAKE_PROGRESS_54 =
CMAKE_PROGRESS_55 = CMAKE_PROGRESS_55 =
CMAKE_PROGRESS_56 = CMAKE_PROGRESS_56 = 72
CMAKE_PROGRESS_57 = 71 CMAKE_PROGRESS_57 =
CMAKE_PROGRESS_58 = CMAKE_PROGRESS_58 =
CMAKE_PROGRESS_59 = CMAKE_PROGRESS_59 = 73
CMAKE_PROGRESS_60 = 72 CMAKE_PROGRESS_60 =
CMAKE_PROGRESS_61 = CMAKE_PROGRESS_61 = 74
CMAKE_PROGRESS_62 = 73 CMAKE_PROGRESS_62 =
CMAKE_PROGRESS_63 = CMAKE_PROGRESS_63 =
CMAKE_PROGRESS_64 = CMAKE_PROGRESS_64 = 75
CMAKE_PROGRESS_65 = 74 CMAKE_PROGRESS_65 =
CMAKE_PROGRESS_66 = CMAKE_PROGRESS_66 =
CMAKE_PROGRESS_67 = 75 CMAKE_PROGRESS_67 = 76
CMAKE_PROGRESS_68 = CMAKE_PROGRESS_68 =
CMAKE_PROGRESS_69 = CMAKE_PROGRESS_69 = 77
CMAKE_PROGRESS_70 = 76 CMAKE_PROGRESS_70 =
CMAKE_PROGRESS_71 = CMAKE_PROGRESS_71 =
CMAKE_PROGRESS_72 = 77 CMAKE_PROGRESS_72 = 78
CMAKE_PROGRESS_73 = CMAKE_PROGRESS_73 =
CMAKE_PROGRESS_74 = CMAKE_PROGRESS_74 =
CMAKE_PROGRESS_75 = 78 CMAKE_PROGRESS_75 = 79
#include "car0101_control.h" #include "common.h"
#include "gpio_init.h" #include "gpio_init.h"
/*将角度转化为对应的舵机pwm值*/ /*将角度转化为对应的舵机pwm值*/
......
#include "device_init.h" #include "device_init.h"
#include "car0101_control.h" #include "devcontrol_common.h"
#include "common.h" #include "common.h"
#include "gpio_init.h" #include "gpio_init.h"
...@@ -11,6 +11,7 @@ const deviceconfig_t device_configs[] = { ...@@ -11,6 +11,7 @@ const deviceconfig_t device_configs[] = {
.device_id = 101, .device_id = 101,
.device_name = "car0101", .device_name = "car0101",
.gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27, -1}, .gpio_pins = {5, 6, 7, 10, 16, 20, 22, 23, 24, 25, 26, 27, -1},
.gpio_pwms = {-1},
.device_pwm_init = physics_pwm_init, .device_pwm_init = physics_pwm_init,
.device_control_stop = car0101_middle_pwm, .device_control_stop = car0101_middle_pwm,
.emergency_code = 101 .emergency_code = 101
...@@ -65,6 +66,13 @@ const deviceconfig_t device_configs[] = { ...@@ -65,6 +66,13 @@ const deviceconfig_t device_configs[] = {
{ .device_id = -1 } { .device_id = -1 }
}; };
bool get_array_length(int* arr) {
if(arr[0] != -1) { // 遇到-1停止计数
return TRUE;
}
return FALSE;
}
void device_init(int device_id) { void device_init(int device_id) {
const deviceconfig_t *config = NULL; const deviceconfig_t *config = NULL;
...@@ -82,7 +90,8 @@ void device_init(int device_id) { ...@@ -82,7 +90,8 @@ void device_init(int device_id) {
} }
// 执行初始化流程 // 执行初始化流程
init_gpioWPi(config->gpio_pins); // GPIO初始化 if(get_array_length(config->gpio_pins)==TRUE)init_gpiowpi(config->gpio_pins); // GPIO初始化
if(get_array_length(config->gpio_pins)==TRUE)init_gpiopwm(config->gpio_pwms); // GPIOsoft_pwm初始化
config->device_pwm_init(); // PWM初始化 config->device_pwm_init(); // PWM初始化
config->device_control_stop(); // 速度控制初始化 config->device_control_stop(); // 速度控制初始化
......
...@@ -13,4 +13,6 @@ typedef struct { ...@@ -13,4 +13,6 @@ typedef struct {
int emergency_code; // 异常停止代码 int emergency_code; // 异常停止代码
} deviceconfig_t; } deviceconfig_t;
void device_init(int device_id);
#endif #endif
\ No newline at end of file
#include "common.h" #include "common.h"
#include "gpio_init.h" #include "gpio_init.h"
#include "http_request.h" #include "http_request.h"
#include "request.h"
#define MIN_DUTY 0 // 最小占空比 #define MIN_DUTY 0 // 最小占空比
#define MAX_DUTY 100 // 最大占空比 #define MAX_DUTY 100 // 最大占空比
...@@ -14,7 +13,7 @@ int g_gpiowpi[40]; //能使用高低引脚和其他引脚 ...@@ -14,7 +13,7 @@ int g_gpiowpi[40]; //能使用高低引脚和其他引脚
int g_gpiocount=0; int g_gpiocount=0;
int g_gpio_softpwmcount=0; int g_gpio_softpwmcount=0;
void init_gpioWPi(int *values_pin) { void init_gpiowpi(int *values_pin) {
while (values_pin[g_gpiocount] != -1) { while (values_pin[g_gpiocount] != -1) {
g_gpiocount++; g_gpiocount++;
} }
...@@ -28,7 +27,7 @@ void init_gpioWPi(int *values_pin) { ...@@ -28,7 +27,7 @@ void init_gpioWPi(int *values_pin) {
} }
} }
void init_gpioPwm(int *values_pwm) { void init_gpiopwm(int *values_pwm) {
while (values_pwm[g_gpio_softpwmcount] != -1) { while (values_pwm[g_gpio_softpwmcount] != -1) {
g_gpio_softpwmcount++; g_gpio_softpwmcount++;
} }
...@@ -69,8 +68,8 @@ void pwm_value(int pin,int value) { //软件陪我们控制调速 ...@@ -69,8 +68,8 @@ void pwm_value(int pin,int value) { //软件陪我们控制调速
softPwmWrite(pin, shot_speed); softPwmWrite(pin, shot_speed);
my_zlog_debug("pin:%d,%d",pin,shot_speed); my_zlog_debug("pin:%d,%d",pin,shot_speed);
} else { } else {
if(AppExit_pin_pwm == 202)softPwmWrite(pin, 30); //if(AppExit_pin_pwm == 202)softPwmWrite(pin, 30);
if(AppExit_pin_pwm != 202 )softPwmWrite(pin, shot_speed); //if(AppExit_pin_pwm != 202 )softPwmWrite(pin, shot_speed);
} }
...@@ -112,5 +111,5 @@ void physics_pwm_init() { ...@@ -112,5 +111,5 @@ void physics_pwm_init() {
} }
void device_exit_end(){//main最后结束需要调用的函数 void device_exit_end(){//main最后结束需要调用的函数
if(AppExit_pin_pwm == 202) tank_shot_back_stop_task_end(); //if(AppExit_pin_pwm == 202) tank_shot_back_stop_task_end();
} }
\ No newline at end of file
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#define PWM_PIN_SPEED 21 #define PWM_PIN_SPEED 21
#define PWM_PIN_CHANGE 2 #define PWM_PIN_CHANGE 2
void init_gpioWPi(int *values_pin);//gpio引脚初始化 void init_gpiowpi(int *values_pin);//gpio引脚初始化
void init_gpioPwm(int *values_pwm); void init_gpiopwm(int *values_pwm);
void pin_value(int pin,int value);//控制引脚高低 void pin_value(int pin,int value);//控制引脚高低
......
#include <math.h>
#include "common.h"
#include "softiic.h"
int sda_pin = 0; // GPIO0
int scl_pin = 1; // GPIO1
// 软件 I2C 延时
void i2c_delay() {
delayMicroseconds(5); // ~5μs 延迟,适配 100kHz I2C
}
// 初始化 I2C 引脚
bool SOFTiic_init() {
pinMode(sda_pin, OUTPUT);
pinMode(scl_pin, OUTPUT);
digitalWrite(sda_pin, HIGH);
digitalWrite(scl_pin, HIGH);
return true;
}
// I2C 起始信号
void i2c_start() {
pinMode(sda_pin, OUTPUT);
digitalWrite(sda_pin, HIGH);
digitalWrite(scl_pin, HIGH);
i2c_delay();
digitalWrite(sda_pin, LOW);
i2c_delay();
digitalWrite(scl_pin, LOW);
i2c_delay();
}
// I2C 停止信号
void i2c_stop() {
pinMode(sda_pin, OUTPUT);
digitalWrite(sda_pin, LOW);
digitalWrite(scl_pin, LOW);
i2c_delay();
digitalWrite(scl_pin, HIGH);
i2c_delay();
digitalWrite(sda_pin, HIGH);
i2c_delay();
}
// I2C 发送一个字节,并检查 ACK(不返回,但内部可判断是否 ACK)
void i2c_write_byte(uint8_t data) {
pinMode(sda_pin, OUTPUT);
for (int i = 7; i >= 0; i--) {
digitalWrite(sda_pin, (data >> i) & 0x01);
i2c_delay();
digitalWrite(scl_pin, HIGH);
i2c_delay();
digitalWrite(scl_pin, LOW);
i2c_delay();
}
// 接收 ACK
pinMode(sda_pin, INPUT); // 释放 SDA
i2c_delay();
digitalWrite(scl_pin, HIGH);
i2c_delay();
int ack = digitalRead(sda_pin); // 0 = ACK,1 = NACK(你可以打印或设置状态变量)
digitalWrite(scl_pin, LOW);
pinMode(sda_pin, OUTPUT); // 拉回输出模式
i2c_delay();
}
// I2C 读取一个字节并发送 ACK/NACK
uint8_t i2c_read_byte(bool ack) {
uint8_t data = 0;
pinMode(sda_pin, INPUT);
for (int i = 7; i >= 0; i--) {
digitalWrite(scl_pin, HIGH);
i2c_delay();
data |= (digitalRead(sda_pin) << i);
digitalWrite(scl_pin, LOW);
i2c_delay();
}
pinMode(sda_pin, OUTPUT);
digitalWrite(sda_pin, ack ? LOW : HIGH); // 发送 ACK or NACK
i2c_delay();
digitalWrite(scl_pin, HIGH);
i2c_delay();
digitalWrite(scl_pin, LOW);
i2c_delay();
pinMode(sda_pin, INPUT);
return data;
}
#ifndef SOFTIIC_H__
#define SOFTIIC_H__
extern int sda_pin; // GPIO0
extern int scl_pin; // GPIO1
bool SOFTiic_init();
// I2C 起始信号
void i2c_start();
void i2c_delay();
// I2C 停止信号
void i2c_stop();
// I2C 发送一个字节
void i2c_write_byte(uint8_t data);
// I2C 读取一个字节
uint8_t i2c_read_byte(bool ack);
#endif
\ No newline at end of file
#include <math.h>
#include <stdbool.h>
#include "common.h" #include "common.h"
#include "INA226.h" #include "INA226.h"
#include "softiic.h" #include "softiic.h"
......
#include "ads1115.h" #include "ads1115.h"
#include "common.h" #include "common.h"
#include "softiic.h"
#define ADS1115_ADDR 0x48 #define ADS1115_ADDR 0x48
......
#include "common.h"
#include "heat.h"
#define MAX_LINE_LENGTH 20
char temperature[20];
float temp_str;
//温度获取
int heat_tem() {
FILE *file;
char line[MAX_LINE_LENGTH];
file = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
if (file == NULL) {
perror("无法打开温度文件");
return 1;
}
if (fgets(line, sizeof(line), file) != NULL) {
temp_str = (float)atof(line) / 1000.0;
sprintf(temperature, "%.2f°C", temp_str);
my_zlog_debug("CPU 温度: %.2f°C", temp_str);
}
fclose(file);
return 0;
}
\ No newline at end of file
#ifndef HEAT_H__
#define HEAT_H__
int heat_tem();//获取CPU温度
extern char temperature[];//温度存储
#endif
\ No newline at end of file
...@@ -31,28 +31,28 @@ void pad_and_convert(const char* hex_str, uint32_t* data_out, int* count) { ...@@ -31,28 +31,28 @@ void pad_and_convert(const char* hex_str, uint32_t* data_out, int* count) {
void sendNEC(uint32_t data) { void sendNEC(uint32_t data) {
// 起始码 // 起始码
digitalWrite(IR_PIN, HIGH); digitalWrite(IR_PIN, HIGH);
Delay_us(START_PULSE_HIGH); delay_us(START_PULSE_HIGH);
digitalWrite(IR_PIN, LOW); digitalWrite(IR_PIN, LOW);
Delay_us(START_PULSE_LOW); delay_us(START_PULSE_LOW);
// 发送32位数据 // 发送32位数据
for (int i = 31; i >= 0; i--) { for (int i = 31; i >= 0; i--) {
if ((data >> i) & 1) { if ((data >> i) & 1) {
digitalWrite(IR_PIN, HIGH); digitalWrite(IR_PIN, HIGH);
Delay_us(ONE_PULSE_HIGH); delay_us(ONE_PULSE_HIGH);
digitalWrite(IR_PIN, LOW); digitalWrite(IR_PIN, LOW);
Delay_us(ONE_PULSE_LOW); delay_us(ONE_PULSE_LOW);
} else { } else {
digitalWrite(IR_PIN, HIGH); digitalWrite(IR_PIN, HIGH);
Delay_us(ZERO_PULSE_HIGH); delay_us(ZERO_PULSE_HIGH);
digitalWrite(IR_PIN, LOW); digitalWrite(IR_PIN, LOW);
Delay_us(ZERO_PULSE_LOW); delay_us(ZERO_PULSE_LOW);
} }
} }
// 停止码 // 停止码
digitalWrite(IR_PIN_rec, LOW); digitalWrite(IR_PIN_rec, LOW);
Delay_us(STOP_PULSE); delay_us(STOP_PULSE);
} }
// 发送完整字符串数据(如“00020200000000”) // 发送完整字符串数据(如“00020200000000”)
...@@ -75,17 +75,17 @@ void receiveNEC_Multi(int num_blocks) { ...@@ -75,17 +75,17 @@ void receiveNEC_Multi(int num_blocks) {
// 等待高电平(起始码) // 等待高电平(起始码)
while (digitalRead(IR_PIN_rec) == LOW); while (digitalRead(IR_PIN_rec) == LOW);
Delay_us(START_PULSE_MIN); delay_us(START_PULSE_MIN);
for (int i = 31; i >= 0; i--) { for (int i = 31; i >= 0; i--) {
while (digitalRead(IR_PIN_rec) == LOW); while (digitalRead(IR_PIN_rec) == LOW);
Delay_us(ZERO_PULSE_MIN); delay_us(ZERO_PULSE_MIN);
if (digitalRead(IR_PIN_rec) == HIGH) { if (digitalRead(IR_PIN_rec) == HIGH) {
Delay_us(ONE_PULSE_MIN); delay_us(ONE_PULSE_MIN);
data |= (1 << i); data |= (1 << i);
} else { } else {
Delay_us(ZERO_PULSE_MIN); delay_us(ZERO_PULSE_MIN);
} }
} }
data_arr[j] = data; data_arr[j] = data;
......
#ifndef INFRARED_GUN_H #ifndef INFRARED_GUN_H
#define INFRARED_GUN_H #define INFRARED_GUN_H
/*没有使用暂时*/
#define IR_PIN_rec 6 // 使用WiringPi,红外接收 #define IR_PIN_rec 6 // 使用WiringPi,红外接收
#define IR_PIN 25 // 使用WiringPi,红外发射 #define IR_PIN 25 // 使用WiringPi,红外发射
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "warm.h" #include "warm.h"
#include "http_request.h" #include "http_request.h"
#include "mylog.h" #include "mylog.h"
#include "gpio_init.h"
//最高警报,最低电压报警 //最高警报,最低电压报警
int alarm_highest(int index) { int alarm_highest(int index) {
......
...@@ -29,8 +29,12 @@ ...@@ -29,8 +29,12 @@
#include <math.h> // 数学函数 #include <math.h> // 数学函数
#include <time.h> // 时间处理 #include <time.h> // 时间处理
#include <mosquitto.h> #include "mosquitto.h"
#include <cjson/cJSON.h> #include "cjson/cJSON.h"
#include "delay.h"
#include "mylog.h"
// ========== 香橙派优化宏 ========== // ========== 香橙派优化宏 ==========
// #define ORANGE_GPIO_SET(pin, val) { \ // #define ORANGE_GPIO_SET(pin, val) { \
......
#ifndef COMMON_H #ifndef DEVCONTROL_COMMON_H
#define COMMON_H #define DEVCONTROL_COMMON_H
#include "car0101_control.h"
#define DEVICE_CAR0101 101
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
#define DEVICE_CAR0104 104
#define DEVICE_TANK0201 201
#define DEVICE_TANK0202 101
#define DEVICE_PAO_PTZ0401 401
#endif #endif
\ No newline at end of file
#include "common.h" #include "common.h"
#include "browser_open.h" #include "browser_open.h"
#include "device_fileopen.h" #include "device_fileopen.h"
#include "device_identity.h"
char gwebcam[254];//存放启动火狐网站命令 char gwebcam[254];//存放启动火狐网站命令
...@@ -8,8 +9,6 @@ int opencamsh_china(){ ...@@ -8,8 +9,6 @@ int opencamsh_china(){
const char* url = "https://jywy.yd-ss.com?dev="; const char* url = "https://jywy.yd-ss.com?dev=";
char urls[50]; char urls[50];
topic_middle_value();
sprintf(urls,"%s%s",url,mqtt_topic_pure_number()); sprintf(urls,"%s%s",url,mqtt_topic_pure_number());
//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
...@@ -25,8 +24,6 @@ int opencamsh_abroad(){ ...@@ -25,8 +24,6 @@ int opencamsh_abroad(){
const char* url = "https://video.luckycar.top/?dev="; const char* url = "https://video.luckycar.top/?dev=";
char urls[50]; char urls[50];
topic_middle_value();
sprintf(urls,"%s%s",url,mqtt_topic_pure_number()); sprintf(urls,"%s%s",url,mqtt_topic_pure_number());
//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
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "cjson/cJSON.h" #include "cjson/cJSON.h"
#include "http_request.h" #include "http_request.h"
#include "device_identity.h" #include "device_identity.h"
#include "common.h"
const char *c_post = "http://47.119.190.60/api/v1/device/config"; const char *c_post = "http://47.119.190.60/api/v1/device/config";
...@@ -103,8 +105,6 @@ int analysis_request_json(char *payload_str) { ...@@ -103,8 +105,6 @@ int analysis_request_json(char *payload_str) {
char *wirte_json() { char *wirte_json() {
cJSON *body = cJSON_CreateObject(); cJSON *body = cJSON_CreateObject();
topic_middle_value();
cJSON_AddStringToObject(body, "device_id", mqtt_topic_pure_number()); // 发送设备id cJSON_AddStringToObject(body, "device_id", mqtt_topic_pure_number()); // 发送设备id
char *payload = cJSON_PrintUnformatted(body); char *payload = cJSON_PrintUnformatted(body);
......
...@@ -4,10 +4,15 @@ ...@@ -4,10 +4,15 @@
#include "mqtt_verify.h" #include "mqtt_verify.h"
#include "device_fileopen.h" #include "device_fileopen.h"
#include "device_identity.h" #include "device_identity.h"
#include "browser_open.h"
#include "temperature.h" #include "temperature.h"
#include "common.h" #include "common.h"
#include "mylog.h" #include "INA226.h"
#include "ads1115.h"
#include "warm.h"
#include "device_fileopen.h" #include "device_fileopen.h"
#include "devcontrol_common.h"
#include "gpio_init.h"
bool g_verified_mode = TRUE;//控制是否需要验证 bool g_verified_mode = TRUE;//控制是否需要验证
...@@ -23,13 +28,13 @@ unsigned char g_valt[4];//存放mqtt接收的tpye,mode等 ...@@ -23,13 +28,13 @@ unsigned char g_valt[4];//存放mqtt接收的tpye,mode等
void heartbeat_send() { void heartbeat_send() {
float voltage = 0;//INA226_readBusVoltage(); float voltage = 0;//INA226_readBusVoltage();
float current = 0;//INA226_readCurrent(); float current = 0;//INA226_readCurrent();
//my_zlog_debug("%.2f\n", voltage); my_zlog_debug("%.2f\n", voltage);
// if(voltage<=0.5){ if(voltage<=0.5){
// voltage=ads1115_read_channel(0)*5/2; voltage=ads1115_read_channel(0)*5/2;
// current=ads1115_read_channel(1)*5/2; current=ads1115_read_channel(1)*5/2;
// //my_zlog_debug("%.2f\n", voltage); my_zlog_debug("%.2f\n", voltage);
// current=(current-voltage)*100; current=(current-voltage)*100;
// } }
char voltage_str[20]; // 足够存储转换后的字符串的缓冲区 char voltage_str[20]; // 足够存储转换后的字符串的缓冲区
sprintf(voltage_str, "%.2f", voltage); sprintf(voltage_str, "%.2f", voltage);
char current_str[20]; // 足够存储转换后的字符串的缓冲区 char current_str[20]; // 足够存储转换后的字符串的缓冲区
...@@ -73,7 +78,8 @@ void heartbeat_send() { ...@@ -73,7 +78,8 @@ void heartbeat_send() {
//mqtt设备行走驱动函数 //mqtt设备行走驱动函数
void device_driver(){ void device_driver(){
// if(AppExit_pin_pwm == 101) speed_change(valt) ; int device_type=0;
if( device_type == 101) car0101_control_change(g_valt) ;
// if(AppExit_pin_pwm == 102) car0102_speed_change(valt) ; // if(AppExit_pin_pwm == 102) car0102_speed_change(valt) ;
// if(AppExit_pin_pwm == 103 ) car0103_change(valt) ; // if(AppExit_pin_pwm == 103 ) car0103_change(valt) ;
// if(AppExit_pin_pwm == 104 ) car0104_change(valt) ; // if(AppExit_pin_pwm == 104 ) car0104_change(valt) ;
...@@ -132,7 +138,7 @@ void message_3(cJSON *body){ ...@@ -132,7 +138,7 @@ void message_3(cJSON *body){
g_valt[0]=typeTemp; g_valt[0]=typeTemp;
g_valt[1]=modeTemp; g_valt[1]=modeTemp;
g_valt[2]=valTemp; g_valt[2]=valTemp;
gPwmCount = 0; g_devcontrol_exit_count = 0;
my_zlog_debug("typeTemp:%d",g_valt[0]); my_zlog_debug("typeTemp:%d",g_valt[0]);
my_zlog_debug("modeTemp:%d",g_valt[1]); my_zlog_debug("modeTemp:%d",g_valt[1]);
...@@ -159,7 +165,7 @@ void message_4(cJSON *body){//message 为4时候 ...@@ -159,7 +165,7 @@ void message_4(cJSON *body){//message 为4时候
valTemp=1; valTemp=1;
} }
gPwmCount=0; g_devcontrol_exit_count=0;
g_valt[0]=0; g_valt[0]=0;
g_valt[1]=pinTemp; g_valt[1]=pinTemp;
g_valt[2]=valTemp; g_valt[2]=valTemp;
...@@ -167,22 +173,22 @@ void message_4(cJSON *body){//message 为4时候 ...@@ -167,22 +173,22 @@ void message_4(cJSON *body){//message 为4时候
my_zlog_debug("pinTemp:%d",g_valt[1]); my_zlog_debug("pinTemp:%d",g_valt[1]);
my_zlog_debug("valTemp:%d",g_valt[2]); my_zlog_debug("valTemp:%d",g_valt[2]);
//pin_value(g_valt[1],g_valt[2]); pin_value(g_valt[1],g_valt[2]);
//pwm_value(g_valt[1],g_valt[2]); pwm_value(g_valt[1],g_valt[2]);
//if(AppExit_pin_pwm == 202 ) tank_shot_back_stop(g_valt[1],g_valt[2]); //if(AppExit_pin_pwm == 202 ) tank_shot_back_stop(g_valt[1],g_valt[2]);
} }
//当接收到2时候验证 //当接收到2时候验证
void message_2_judyverify(cJSON *body){ void message_2_judyverify(cJSON *body){
if(g_verified_mode == FALSE) { if(g_verified_mode == FALSE) {
//refresh_cam(); refresh_cam();
my_zlog_warn("不使用验证"); my_zlog_warn("不使用验证");
return ; return ;
} }
receive_jwt(body); receive_jwt(body);
if(g_verify_index == 0) { if(g_verify_index == 0) {
//refresh_cam(); refresh_cam();
} else { } else {
my_zlog_warn("验证不通过"); my_zlog_warn("验证不通过");
} }
...@@ -251,7 +257,7 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息 ...@@ -251,7 +257,7 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
my_zlog_debug("message_type: %d",message_type->valueint); my_zlog_debug("message_type: %d",message_type->valueint);
switch(g_message_type){ switch(g_message_type){
case 2: case 2:
//message_2_judyverify(body); message_2_judyverify(body);
my_zlog_debug("进入刷新"); my_zlog_debug("进入刷新");
break; break;
case 3: case 3:
......
#include <time.h> #include <time.h>
#include "cjson/cJSON.h"
#include "mqtt_verify.h" #include "mqtt_verify.h"
#include "common.h" #include "common.h"
#include <openssl/evp.h> #include <openssl/evp.h>
......
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