From 91f6e60919b92b7f99a41f2ddeb42df17cd0c487 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Fri, 25 Oct 2024 10:48:26 +0800
Subject: [PATCH] 优化

---
 ard-work/src/main/java/com/ard/tianyu/netty/command/UavInitInfoCommand.java |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/tianyu/netty/command/UavInitInfoCommand.java b/ard-work/src/main/java/com/ard/tianyu/netty/command/UavInitInfoCommand.java
index 44ebc13..9944dd5 100644
--- a/ard-work/src/main/java/com/ard/tianyu/netty/command/UavInitInfoCommand.java
+++ b/ard-work/src/main/java/com/ard/tianyu/netty/command/UavInitInfoCommand.java
@@ -11,25 +11,29 @@
  */
 
 @Data
-public class UavInitInfoCommand extends BaseCommand{
+public class UavInitInfoCommand extends BaseCommand {
 
     private final byte encryptFlag; // 加密标志
     private final byte actionCode; // 动作编号
     private final byte result; // 执行结果
 
-    public UavInitInfoCommand(String boxSn, byte actionCode) {
-        setDataHeader((short)0x7479);
-        setDataLength((short) 18);
-        setBoxSn(boxSn.getBytes());
-        setCmdCode((byte)0xD1);
+    public UavInitInfoCommand(byte[] boxSn) {
+        setDataHeader((short) 0x7479);
+        setDataLength((short) 19);
+        setCmdCode((byte) 0xD1);
         this.encryptFlag = 0x00;
-        this.actionCode = actionCode;
+        this.actionCode = 0x42;
         this.result = 0x01;
+        setBoxSn(boxSn);
     }
 
     public void encode(ByteBuf out) {
+        out.writeShort(getDataHeader());    // 写入数据头
+        out.writeShort(getDataLength());    // 写入数据长度
+        out.writeByte(getCmdCode());        // 写入命令码
         out.writeByte(encryptFlag);         // 写入加密标志
         out.writeByte(actionCode);          // 写入动作编号
         out.writeByte(result);              // 写入执行结果
+        out.writeBytes(getBoxSn());         // 写入云盒编号
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3