Compare commits

..

No commits in common. "b51dec345f2cc9279c72d5fc9d4658f7456ec5d6" and "1f4098c73c8c09ee6edeea56aea0d4f63fa99c73" have entirely different histories.

2 changed files with 11 additions and 12 deletions

View File

@ -553,11 +553,10 @@ void FoodCube::mav_request_data()
* @description:
* @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;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
// 构造PARAM_REQUEST_READ消息
mavlink_msg_param_request_read_pack(1, 200, &msg, 1, 1, param_id, -1);
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";
/*项目对象*/
char *ssid = "szMate40pro"; // wifi帐号
char *password = "63587839ab"; // wifi密码
char* ssid = "szMate40pro"; //wifi帐号
char* password = "63587839ab"; //wifi密码
// char* ssid = "szdot"; //wifi帐号
// char* password = "63587839ab"; //wifi密码
// char *ssid = "flicube"; // wifi帐号
@ -35,10 +35,10 @@ FoodCube fc(ssid, password, mqttServer, mqttPort, mqttName, mqttPassword, mavlin
/* 发布 主题 ps:以下是登记发布json内容的组成元素 */
// 登记 json成员名字
// 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成员总数
String topicPubMsg[topicPubCount] = {""}; // 登记 json成员的值 对应topicPub
String oldMsg[topicPubCount] = {""}; // 记录旧的值 用来对比有没有更新
String topicPubMsg[topicPubCount] ={""}; // 登记 json成员的值 对应topicPub
String oldMsg[topicPubCount]={""}; // 记录旧的值 用来对比有没有更新
/*触发发送 主题*/
// 0:对频信息
String topicHandle[] = {"crosFrequency"};
@ -162,9 +162,9 @@ void mqtt_receiveCallback(char *topic, byte *payload, unsigned int length)
String todo = value; // 转换值
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")
{
@ -728,13 +728,13 @@ void pubThread()
// 设置对象成员 ps:心跳
doc[topicPub[i]] = topicPubMsg[i];
}
else if (i == 3 || i == 10)
else if (i == 3 || i==10)
{
// 设置对象成员 ps:3电池电量 10飞机状态state
doc[topicPub[i]] = topicPubMsg[i];
}
else if (topicPubMsg[i] != oldMsg[i])
{
{
// 非心跳 非飞机状态 有更新 录入成员
doc[topicPub[i]] = topicPubMsg[i];
oldMsg[i] = topicPubMsg[i];