| | |
| | | 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; |
| | |
| | | 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); |
| | | String boxSn = new String(uavData2); |
| | | boxSn = new String(uavData2); |
| | | TelemetryDataPB.UavInitInfo uavInitInfo = TelemetryDataPB.UavInitInfo.parseFrom(uavData1); |
| | | baseCommand = new UavReadyNotificationCommand(boxSn, uavInitInfo, actionCode); |
| | | log.debug("无人机初始化数据: {}", boxSn); |