From 1cf9b81ccbe596da989573c5c82e6c34f79fdc9f Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Fri, 20 Jun 2025 08:35:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E9=A3=9E=E6=8E=A7=E5=8F=91=E9=80=81adsb=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=20=EF=BC=88=E6=B5=8B=E8=AF=95=EF=BC=89=20=E3=80=90?= =?UTF-8?q?=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=20=E3=80=90=E5=BD=B1?= =?UTF-8?q?=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- src/commser.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/commser.cpp b/src/commser.cpp index 8bbc5cb..7f30cb5 100644 --- a/src/commser.cpp +++ b/src/commser.cpp @@ -795,6 +795,27 @@ void mavlink_receiveCallback(uint8_t c) } break; + case MAVLINK_MSG_ID_ADSB_VEHICLE: // #246 ADSB + { + mavlink_adsb_vehicle_t adsb; + mavlink_msg_adsb_vehicle_decode(&msg, &adsb); + + // 提取并转换数据 + uint32_t icao = adsb.ICAO_address; + float lat = adsb.lat / 1e7; + float lon = adsb.lon / 1e7; + int alt = adsb.altitude; + float heading = adsb.heading / 10.0f; + + // 构建 JSON 字符串 + char jsonString[256]; + snprintf(jsonString, sizeof(jsonString), "{\"icao\":%u,\"lat\":%.7f,\"lon\":%.7f,\"alt\":%d,\"heading\":%.1f}", icao, lat, lon, alt, heading); + + // 发送 MQTT 消息 + fc.pubMQTTmsg("ceshi", jsonString); + } + break; + case MAVLINK_MSG_ID_STATUSTEXT: // #253 文本信息 { char buf[51]; // 定义一个局部缓冲区,大小为 51