| | |
| | | package com.ard.tianyu.netty.handler;// MessageProtocolDecoder.java |
| | | |
| | | import com.ard.tianyu.netty.command.*; |
| | | 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; |
| | |
| | | break; |
| | | case 0x03: |
| | | case 0x04: |
| | | byte[] boxSn = new byte[dataLength - 1]; |
| | | in.readBytes(boxSn); |
| | | SubscribeReplyCommand subscribeReply = new SubscribeReplyCommand(new String(boxSn)); |
| | | log.debug("订阅回复: {}", subscribeReply.getBoxSn()); |
| | | break; |
| | | case (byte) 0xA8: |
| | | byte[] uavStatus = new byte[dataLength - 1]; |
| | |
| | | byte encryptionFlag = in.readByte(); |
| | | byte actionCode = in.readByte(); |
| | | switch (actionCode) { |
| | | case 0x23: |
| | | byte result = in.readByte(); |
| | | int errorCode = in.readInt(); |
| | | uavData = new byte[15]; |
| | | in.readBytes(uavData); |
| | | String 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 DroneReadyNotificationCommand(uavInitInfo, actionCode); |
| | | log.info("无人机初始化数据: {}", uavInitInfo.getUavModel()); |
| | | baseCommand = new UavReadyNotificationCommand(boxSn, uavInitInfo, actionCode); |
| | | log.debug("无人机初始化数据: {}", boxSn); |
| | | break; |
| | | default: |
| | | log.warn("无法识别的命令码动作编号:{}", String.format("0x%02X", actionCode & 0xFF)); |