From 1157c58dc74805cbb7db57ab121bbb521f4c216b Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Fri, 25 Oct 2024 16:33:49 +0800
Subject: [PATCH] 增加 拍照 录像 相机模式设置

---
 ard-work/src/main/java/com/ard/tianyu/netty/handler/MessageProtocolDecoder.java |   93 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 89 insertions(+), 4 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/tianyu/netty/handler/MessageProtocolDecoder.java b/ard-work/src/main/java/com/ard/tianyu/netty/handler/MessageProtocolDecoder.java
index 4dcb9e0..689ccc8 100644
--- a/ard-work/src/main/java/com/ard/tianyu/netty/handler/MessageProtocolDecoder.java
+++ b/ard-work/src/main/java/com/ard/tianyu/netty/handler/MessageProtocolDecoder.java
@@ -1,6 +1,16 @@
 package com.ard.tianyu.netty.handler;// MessageProtocolDecoder.java
 
 import com.ard.tianyu.netty.command.*;
+import com.ard.tianyu.netty.command.camera.CameraModeReplyCommand;
+import com.ard.tianyu.netty.command.camera.CapturePicReplyCommand;
+import com.ard.tianyu.netty.command.camera.RecordStartReplyCommand;
+import com.ard.tianyu.netty.command.camera.RecordStopReplyCommand;
+import com.ard.tianyu.netty.command.real.SignalInfoCommand;
+import com.ard.tianyu.netty.command.real.UavStateCommand;
+import com.ard.tianyu.netty.command.real.UavTelemetryDataCommand;
+import com.ard.tianyu.netty.command.register.HeartbeatReplyCommand;
+import com.ard.tianyu.netty.command.register.RegisterReplyCommand;
+import com.ard.tianyu.netty.command.register.UavReadyNotificationCommand;
 import com.ard.tianyu.netty.protobuf.TelemetryDataPB;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
@@ -42,22 +52,97 @@
                 baseCommand = new HeartbeatReplyCommand(timestamp);
                 log.debug("心跳回复: 时间戳 {}", timestamp);
                 break;
+            case 0x03:
+            case 0x04:
+                break;
             case (byte) 0xA8:
                 byte[] uavStatus = new byte[dataLength - 1];
                 in.readBytes(uavStatus);  // 读取 ProtoBuf 数据
                 TelemetryDataPB.UavState uavState = TelemetryDataPB.UavState.parseFrom(uavStatus);
                 baseCommand = new UavStateCommand(uavState);
-                log.warn("无人机状态数据: {}", uavState.getBoxSn());
+                log.debug("无人机状态数据: {}", uavState.getBoxSn());
                 break;
             case (byte) 0xA9:
                 byte[] uavData = new byte[dataLength - 1];
                 in.readBytes(uavData);
                 TelemetryDataPB.TelemetryData telemetryData = TelemetryDataPB.TelemetryData.parseFrom(uavData);
-                baseCommand = new UavDataCommand(telemetryData);
-                log.warn("无人机遥测数据: {}", telemetryData.getBoxSn());
+                baseCommand = new UavTelemetryDataCommand(telemetryData);
+                log.debug("遥测数据: {}", telemetryData.getBoxSn());
+                break;
+            case (byte) 0x0C:
+                int delayTime = in.readInt();
+                uavData = new byte[15];
+                in.readBytes(uavData);
+                //  String boxSn12 = new String(uavData);
+                uavData = new byte[dataLength - 20];
+                in.readBytes(uavData);
+                TelemetryDataPB.SignalInfo signalInfo = TelemetryDataPB.SignalInfo.parseFrom(uavData);
+                baseCommand = new SignalInfoCommand(signalInfo);
+                log.debug("信道质量数据: {}", delayTime);
+                break;
+            case (byte) 0xD1:
+                byte encryptionFlag = in.readByte();
+                byte actionCode = in.readByte();
+                switch (actionCode) {
+                    case 0x22:
+                        byte result = in.readByte();
+                        int errorCode = in.readInt();
+                        uavData = new byte[15];
+                        in.readBytes(uavData);
+                        String boxSn = new String(uavData);
+                        baseCommand = new CameraModeReplyCommand(boxSn, result, errorCode);
+                        log.debug("设置相机模式回复: {}", boxSn);
+                        break;
+                    case 0x23:
+                        result = in.readByte();
+                        errorCode = in.readInt();
+                        uavData = new byte[15];
+                        in.readBytes(uavData);
+                        boxSn = new String(uavData);
+                        baseCommand = new CapturePicReplyCommand(boxSn, result, errorCode);
+                        log.debug("拍照回复: {}", boxSn);
+                        break;
+                    case 0x24:
+                        result = in.readByte();
+                        errorCode = in.readInt();
+                        uavData = new byte[15];
+                        in.readBytes(uavData);
+                        boxSn = new String(uavData);
+                        baseCommand = new RecordStartReplyCommand(boxSn, result, errorCode);
+                        log.debug("开始录像回复: {}", boxSn);
+                        break;
+                    case 0x25:
+                        result = in.readByte();
+                        errorCode = in.readInt();
+                        uavData = new byte[15];
+                        in.readBytes(uavData);
+                        boxSn = new String(uavData);
+                        baseCommand = new RecordStopReplyCommand(boxSn, result, errorCode);
+                        log.debug("停止录像回复: {}", boxSn);
+                        break;
+                    case 0x42:
+                        byte[] uavData1 = new byte[dataLength - 18];
+                        in.readBytes(uavData1);
+                        byte[] uavData2 = new byte[15];
+                        in.readBytes(uavData2);
+                        boxSn = new String(uavData2);
+                        TelemetryDataPB.UavInitInfo uavInitInfo = TelemetryDataPB.UavInitInfo.parseFrom(uavData1);
+                        baseCommand = new UavReadyNotificationCommand(boxSn, uavInitInfo, actionCode);
+                        log.debug("无人机初始化数据: {}", boxSn);
+                        break;
+                    default:
+                        log.warn("无法识别的命令码动作编号:{}", String.format("0x%02X", actionCode & 0xFF));
+                        break;
+                }
                 break;
             default:
-                log.warn("无法识别的命令码: {}", String.format("0x%02X", cmdCode & 0xFF));//String.format("0x%02X", cmdCode & 0xFF)
+                encryptionFlag = in.readByte();
+                actionCode = in.readByte();
+                log.warn("无法识别的命令码: {},加密标志:{},动作编号:{}",
+                        String.format("0x%02X", cmdCode & 0xFF),
+                        String.format("0x%02X", encryptionFlag & 0xFF),
+                        String.format("0x%02X", actionCode & 0xFF));//String.format("0x%02X", cmdCode & 0xFF)
+
         }
         if (baseCommand != null) {
             out.add(baseCommand);

--
Gitblit v1.9.3