Compare commits
3 Commits
1f4098c73c
...
b51dec345f
Author | SHA1 | Date | |
---|---|---|---|
b51dec345f | |||
eb6b1bc779 | |||
706449d553 |
@ -553,7 +553,8 @@ 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];
|
||||||
|
|
||||||
|
@ -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,7 +728,7 @@ 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];
|
||||||
|
Loading…
Reference in New Issue
Block a user