【类 型】:factor

【主	题】:发送飞机状态 不够频繁
【描	述】:
	[原因]:前端接收飞机状态 太旧
	[过程]:和心跳一起频繁发送 一秒一次
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-07-12 14:09:16 +08:00
parent 1303b1aaff
commit 3f0352daf0

View File

@ -16,10 +16,10 @@ static const char *MOUDLENAME = "COMMSER";
/*项目对象*/
// char* ssid = "szdot"; //wifi帐号
// char* password = "Ttaj@#*.com"; //wifi密码
// char *ssid = "flicube"; // wifi帐号
// char *password = "fxmf0622"; // wifi密码
char *ssid = "fxmf_sc01"; // 4g wifi帐号
char *password = "12345678"; // 4g wifi密码
char *ssid = "flicube"; // wifi帐号
char *password = "fxmf0622"; // wifi密码
// char *ssid = "fxmf_sc01"; // 4g wifi帐号
// char *password = "12345678"; // 4g wifi密码
char *mqttServer = "szdot.top"; // mqtt地址
int mqttPort = 1883; // mqtt端口
char *mqttName = "admin"; // mqtt帐号
@ -627,8 +627,6 @@ void pubThread()
DynamicJsonDocument doc(2000); // 缓冲区
// 遍历 有更新的数据 组成一个json对象
for (int i = 0; i < topicPubCount; i++)
{
if (topicPubMsg[i] != oldMsg[i])
{
if (i == 0)
{ // 心跳包 每每向心跳主题发布信息
@ -641,13 +639,18 @@ void pubThread()
// 设置对象成员 ps:心跳
doc[topicPub[0]] = topicPubMsg[0];
}
else
{ // 非心跳 有更新 录入成员
else if (i == 10)
{
// 设置对象成员 ps:飞机状态 state
doc[topicPub[10]] = topicPubMsg[10];
}
else if (topicPubMsg[i] != oldMsg[i])
{
// 非心跳 非飞机状态 有更新 录入成员
doc[topicPub[i]] = topicPubMsg[i];
oldMsg[i] = topicPubMsg[i];
}
}
}
// 将JSON对象序列化为JSON字符串
String jsonString;
serializeJson(doc, jsonString);