feat: update USART1 baud rate and implement IM1281B communication

This commit is contained in:
2025-03-29 22:37:31 +08:00
parent 98463aa9f1
commit 05668ca262
11 changed files with 1663 additions and 208 deletions

View File

@ -5,7 +5,6 @@
#include "onenet.h"
#include "mqttkit.h"
#include "stm32f1xx_hal_gpio.h"
// #include "main.h"
#define PRODUCT_ID "zzS53oqy5l"
#define DEVICE_ID "ESP_67EAF3"
@ -61,7 +60,6 @@ _Bool OneNet_DevLink(void)
// break;
// case 5: printf("WARN: 连接失败:非法链接(比如token非法)\r\n");
// break;
//
default:
break;
}
@ -84,7 +82,19 @@ unsigned char OneNet_FillBuf(char* buf)
strcpy(buf, "{\"id\":\"1743082944\",\"params\":{");
memset(text, 0, sizeof(text));
sprintf(text, "\"volt\":{\"value\":%f},", 218.3);
sprintf(text, "\"volt\":{\"value\":%.2f},", IM_Volt * 0.0001);
strcat(buf, text);
memset(text, 0, sizeof(text));
sprintf(text, "\"current\":{\"value\":%.2f},", IM_Curr * 0.0001);
strcat(buf, text);
memset(text, 0, sizeof(text));
sprintf(text, "\"watt_P\":{\"value\":%.2f},", IM_Power * 0.0001);
strcat(buf, text);
memset(text, 0, sizeof(text));
sprintf(text, "\"energy\":{\"value\":%.3f},", IM_Energy * 0.0001);
strcat(buf, text);
memset(text, 0, sizeof(text));
@ -111,7 +121,7 @@ void OneNet_SendData(void)
{
MQTT_PACKET_STRUCTURE mqttPacket = {NULL, 0, 0, 0}; //协议包
char buf[128];
char buf[256];
short body_len = 0, i = 0;
memset(buf, 0, sizeof(buf)); //清空数组内容