| | |
| | | package com.ard.tianyu.netty.handler;// MessageProtocolDecoder.java |
| | | |
| | | import com.ard.tianyu.netty.command.BaseCommand; |
| | | import com.ard.tianyu.netty.command.HeartbeatReplyCommand; |
| | | import com.ard.tianyu.netty.command.UavDataCommand; |
| | | import com.ard.tianyu.netty.command.UavStateCommand; |
| | | import com.ard.tianyu.netty.command.*; |
| | | import com.ard.tianyu.netty.protobuf.TelemetryDataPB; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | |
| | | case 0x01: |
| | | byte success = in.readByte(); // 读取是否成功 |
| | | log.warn("注册回复: {}", success == 0x01 ? "成功" : "失败"); |
| | | baseCommand = new RegisterReplyCommand(success); |
| | | break; |
| | | case 0x02: |
| | | long timestamp = in.readLong(); // 读取时间戳 |
| | | baseCommand = new HeartbeatReplyCommand(timestamp); |
| | | log.warn("心跳回复: 时间戳 {}", timestamp); |
| | | log.debug("心跳回复: 时间戳 {}", timestamp); |
| | | 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]; |