Commit 4cb33b70 authored by 957dd's avatar 957dd

feat:加入了霍尔传感器和修复了角度上传的问题

parent 170e1f10
No preview for this file type
......@@ -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"
......
......@@ -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 >= 100) heartbeat_send();
if( heartbeat_count >= 30) heartbeat_send();
}
......
......@@ -67,11 +67,11 @@ void *Mqttbeat(void *arg) {
Delay_Ms(15,0);
while(1) {
ipaddr();//获取ip
if( AppExit_pin_pwm == 202) Delay_Ms(0,90);
if( AppExit_pin_pwm == 202) Delay_Ms(0,80);
if( AppExit_pin_pwm != 202) Delay_Ms(0,100);
heartbeat_count++;
mqtt_wirte();//心跳,3s一个
if(heartbeat_count>=100) heartbeat_count=0;
if(heartbeat_count>=30) heartbeat_count=0;
}
return NULL;
......
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