【类 型】:factor palneState改为questState 只记录任务状态

【原  因】:
【过  程】:
【影  响】:
This commit is contained in:
tk 2024-09-13 16:35:13 +08:00
parent 772e81baa0
commit cd92f11838

View File

@ -34,8 +34,19 @@ uint32_t udpServerPort = 37260; // 云台相机端口
FoodCube fc(ssid, password, mqttServer, mqttPort, mqttName, mqttPassword, mavlinkSerial, voiceSerial, udpServerIP, udpServerPort); // 创建项目对象
/* 发布 主题 ps:以下是登记发布json内容的组成元素 */
// 登记 json成员名字
// 0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:海拔高度 5:对地速度 6:卫星数量 7:定位状态 8:磁罗盘校准进度 9磁罗盘校准结果 10:任务状态 11:加速度计状态 12:飞机模式 13:重量 14:钩子状态 15:{经,维,高} 16:电池总容量 17:返航点 18:文本信息 19返航速度
const String topicPub[] = {"heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "fixType", "completionPct", "reportCal", "questState", "acceState", "getPlaneMode", "loadweight", "hookstatus", "position", "battCapacity", "homePosition", "statusText", "wpnavSpeed"};
/*
*topicPubMsg[10]
*00 0000
*0 &1
*1 线 &2
*2 &4
*3 &8
*4 &16
*5 &32
*/
const int topicPubCount = sizeof(topicPub) / sizeof(topicPub[0]); // 登记 json成员总数
String topicPubMsg[topicPubCount] = {""}; // 登记 json成员的值 对应topicPub
/*触发发送 主题*/
@ -80,17 +91,8 @@ void mqtt_receiveCallback(char *topic, byte *payload, unsigned int length)
writeRoute(todo); // 写入航点
}
else if (key == "setQuestState")
{ // 设置飞机状态
/*
*topicPubMsg[10]
*00 0000
*0 &1
*1 线 &2
*2 &4
*3 &8
*4 &16
*5 &32
*/
{
// 设置飞机任务状态
String todoJson = value; // 转换值
/* json 反序列化 */
DynamicJsonDocument doc(50);
@ -100,6 +102,15 @@ void mqtt_receiveCallback(char *topic, byte *payload, unsigned int length)
uint8_t state = obj["state"]; // 标记飞机状态 0 or 1
// 标记飞机状态
topicPubMsg[10] = fc.setNBit(topicPubMsg[10], n, state);
if (n = 5 && state == 1) // 执行任务 ps:且自动
{
// 切模式
set_mode(AUTO); // 设置飞控为定高模式
// 油门
delay(500);
uint16_t chan[] = {1500, 1500, 1500, 1500}; // 加解锁 油门到底
fc.mav_channels_override(chan); // 控制油门
}
}
else if (key == "unlock") // 解锁
{