Compare commits

...

3 Commits

Author SHA1 Message Date
b51dec345f Merge branch 'dev' of http://111.229.174.37:3000/Food/PullupDev into dev 2024-07-21 05:26:17 +08:00
eb6b1bc779 【类 型】:
【原  因】:
【过  程】:
【影  响】:
2024-07-21 05:25:30 +08:00
706449d553 【类 型】:
【原  因】:
【过  程】:
【影  响】:
2024-07-21 05:24:58 +08:00
2 changed files with 12 additions and 11 deletions

View File

@ -553,10 +553,11 @@ void FoodCube::mav_request_data()
* @description: * @description:
* @param {char*} param_id * @param {char*} param_id
*/ */
void FoodCube::mav_parameter_data(const char* param_id) { void FoodCube::mav_parameter_data(const char *param_id)
{
mavlink_message_t msg; mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN]; uint8_t buf[MAVLINK_MAX_PACKET_LEN];
// 构造PARAM_REQUEST_READ消息 // 构造PARAM_REQUEST_READ消息
mavlink_msg_param_request_read_pack(1, 200, &msg, 1, 1, param_id, -1); mavlink_msg_param_request_read_pack(1, 200, &msg, 1, 1, param_id, -1);
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg); uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);

View File

@ -14,8 +14,8 @@ extern void Hook_recovery();
static const char *MOUDLENAME = "COMMSER"; static const char *MOUDLENAME = "COMMSER";
/*项目对象*/ /*项目对象*/
char* ssid = "szMate40pro"; //wifi帐号 char *ssid = "szMate40pro"; // wifi帐号
char* password = "63587839ab"; //wifi密码 char *password = "63587839ab"; // wifi密码
// char* ssid = "szdot"; //wifi帐号 // char* ssid = "szdot"; //wifi帐号
// char* password = "63587839ab"; //wifi密码 // char* password = "63587839ab"; //wifi密码
// char *ssid = "flicube"; // wifi帐号 // char *ssid = "flicube"; // wifi帐号
@ -35,10 +35,10 @@ FoodCube fc(ssid, password, mqttServer, mqttPort, mqttName, mqttPassword, mavlin
/* 发布 主题 ps:以下是登记发布json内容的组成元素 */ /* 发布 主题 ps:以下是登记发布json内容的组成元素 */
// 登记 json成员名字 // 登记 json成员名字
// 0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:相对高度信息 5:对地速度 6:卫星数量 7:纬度 8:经度 9:定位状态 10:飞机状态 11:网速测试 12:飞机模式 13:重量 14:钩子状态 15:{经度,维度,海拔高度} 16:飞控参数{键:值} // 0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:相对高度信息 5:对地速度 6:卫星数量 7:纬度 8:经度 9:定位状态 10:飞机状态 11:网速测试 12:飞机模式 13:重量 14:钩子状态 15:{经度,维度,海拔高度} 16:飞控参数{键:值}
const String topicPub[] = {"heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "latitude", "longitude", "fixType", "state", "pingNet", "getPlaneMode", "loadweight", "hookstatus", "position","parameter"}; const String topicPub[] = {"heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "latitude", "longitude", "fixType", "state", "pingNet", "getPlaneMode", "loadweight", "hookstatus", "position", "parameter"};
const int topicPubCount = sizeof(topicPub) / sizeof(topicPub[0]); // 登记 json成员总数 const int topicPubCount = sizeof(topicPub) / sizeof(topicPub[0]); // 登记 json成员总数
String topicPubMsg[topicPubCount] ={""}; // 登记 json成员的值 对应topicPub String topicPubMsg[topicPubCount] = {""}; // 登记 json成员的值 对应topicPub
String oldMsg[topicPubCount]={""}; // 记录旧的值 用来对比有没有更新 String oldMsg[topicPubCount] = {""}; // 记录旧的值 用来对比有没有更新
/*触发发送 主题*/ /*触发发送 主题*/
// 0:对频信息 // 0:对频信息
String topicHandle[] = {"crosFrequency"}; String topicHandle[] = {"crosFrequency"};
@ -162,9 +162,9 @@ void mqtt_receiveCallback(char *topic, byte *payload, unsigned int length)
String todo = value; // 转换值 String todo = value; // 转换值
topicPubMsg[10] = todo; // 恢复初始状态 topicPubMsg[10] = todo; // 恢复初始状态
} }
else if (key == "getBattCapacity")//请求 飞控返回 电池容量 else if (key == "getBattCapacity") // 请求 飞控返回 电池容量
{ {
fc.mav_parameter_data("BATT_CAPACITY");// 请求飞控 返回参数 电池容量 值 fc.mav_parameter_data("BATT_CAPACITY"); // 请求飞控 返回参数 电池容量 值
} }
else if (key == "chan1") else if (key == "chan1")
{ {
@ -728,13 +728,13 @@ void pubThread()
// 设置对象成员 ps:心跳 // 设置对象成员 ps:心跳
doc[topicPub[i]] = topicPubMsg[i]; doc[topicPub[i]] = topicPubMsg[i];
} }
else if (i == 3 || i==10) else if (i == 3 || i == 10)
{ {
// 设置对象成员 ps:3电池电量 10飞机状态state // 设置对象成员 ps:3电池电量 10飞机状态state
doc[topicPub[i]] = topicPubMsg[i]; doc[topicPub[i]] = topicPubMsg[i];
} }
else if (topicPubMsg[i] != oldMsg[i]) else if (topicPubMsg[i] != oldMsg[i])
{ {
// 非心跳 非飞机状态 有更新 录入成员 // 非心跳 非飞机状态 有更新 录入成员
doc[topicPub[i]] = topicPubMsg[i]; doc[topicPub[i]] = topicPubMsg[i];
oldMsg[i] = topicPubMsg[i]; oldMsg[i] = topicPubMsg[i];