八达岭需求 注释后面代码 飞完过后删除
This commit is contained in:
parent
8ac6050148
commit
a7d9f79b8c
@ -21,8 +21,8 @@ String topicSub[] = { "questAss", "setPlaneState", "getPlaneState", "resetState"
|
||||
int topicSubCount = sizeof(topicSub) / sizeof(topicSub[0]); //订阅主题总数
|
||||
/* 发布 主题 ps:以下是登记发布json内容的组成元素 */
|
||||
//登记 json成员名字
|
||||
//0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:高度信息 5:对地速度 6:卫星数量 7:纬度 8:经度 9:定位状态 10:飞机状态 11:网速测试 12:飞机模式 13:重量 14:钩子状态 15:飞机海拔高度
|
||||
String topicPub[] = { "heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "latitude", "longitude", "fixType", "planeState", "pingNet", "getPlaneMode", "loadweight", "hookstatus", "altitude" };
|
||||
//0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:相对高度信息 5:对地速度 6:卫星数量 7:纬度 8:经度 9:定位状态 10:飞机状态 11:网速测试 12:飞机模式 13:重量 14:钩子状态 15:{经度,维度,海拔高度}
|
||||
String topicPub[] = { "heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "latitude", "longitude", "fixType", "state", "pingNet", "getPlaneMode", "loadweight", "hookstatus", "position" };
|
||||
int topicPubCount = sizeof(topicPub) / sizeof(topicPub[0]); //登记 json成员总数
|
||||
String topicPubMsg[16]; //登记 json成员的值 对应topicPub
|
||||
String oldMsg[16]; //记录旧的值 用来对比有没有更新
|
||||
@ -386,8 +386,11 @@ void mavlink_receiveCallback(uint8_t c) {
|
||||
if (topicPubMsg[4] != buf) {
|
||||
topicPubMsg[4] = buf;
|
||||
}
|
||||
//海拔高度
|
||||
sprintf(buf, "%.2f", (double)global_position_int.alt / 1000);
|
||||
//{经度,维度,海拔高度}
|
||||
sprintf(buf, "{lng:%d,lat:%d,alt:%.2f}",
|
||||
global_position_int.lon,
|
||||
global_position_int.lat,
|
||||
(double)global_position_int.alt / 1000);
|
||||
if (topicPubMsg[15] != buf) {
|
||||
topicPubMsg[15] = buf;
|
||||
}
|
||||
@ -510,9 +513,9 @@ void mavlink_receiveCallback(uint8_t c) {
|
||||
void pubThread() {
|
||||
/*解析mavlink 数据流等 此函数内会把解析的数据按信息类型 发布到mqtt服务器 planeState/macadd主题 */
|
||||
// 创建一个JSON对象
|
||||
DynamicJsonDocument doc(200); // 200字节 缓冲区
|
||||
DynamicJsonDocument doc(2000); // 缓冲区
|
||||
//遍历 有更新的数据 组成一个json对象
|
||||
for (int i = 0; i < topicPubCount; i++) {
|
||||
for (int i = 0; i < topicPubCount; i++) {
|
||||
if (topicPubMsg[i] != oldMsg[i]) {
|
||||
if (i == 0) { //心跳包 每每向心跳主题发布信息
|
||||
//启动飞控 第一次心跳 ps:防止飞控 滞后启动 拿不到数据
|
||||
@ -534,6 +537,9 @@ void pubThread() {
|
||||
fc.pubMQTTmsg("planeState", jsonString);
|
||||
/*更新4G网络测速ping值*/
|
||||
//pingNetTest();
|
||||
//八达岭需求 过后删除
|
||||
fc.pubMQTTmsg("heartBeat",topicPubMsg[0]);
|
||||
fc.pubMQTTmsg("position",topicPubMsg[15]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user