| | |
| | | import com.ard.tianyu.model.dto.BoxPhotosDTO; |
| | | import com.ard.tianyu.model.dto.BoxSettingsDTO; |
| | | import com.ard.tianyu.model.receiver.*; |
| | | import com.ard.tianyu.netty.command.BaseCommand; |
| | | import com.ard.tianyu.netty.command.ControlAngleCommand; |
| | | import com.ard.tianyu.netty.command.HeartbeatCommand; |
| | | import com.ard.tianyu.netty.command.RegisterCommand; |
| | | import com.ard.tianyu.netty.command.*; |
| | | import com.ard.tianyu.netty.TyNettyTcpClient; |
| | | import com.ard.tianyu.service.ITyService; |
| | | import io.netty.buffer.ByteBuf; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.net.InetSocketAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<BoxInfoReceiver> getBoxList() { |
| | | //请求云盒列表 |
| | | try { |
| | | TyHttpCommonReceiver<List<BoxInfoReceiver>> boxListReveiver = tyClient.getBoxList(tyConfiguration.getAccessToken().convertFromDTO()); |
| | | return boxListReveiver.getContent(); |
| | | } catch (Exception e) { |
| | | log.error("获取云盒列表失败:{}", e.getMessage()); |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | this.sendMessage(tyConfiguration.getIpPort(), controlAngleCommand); |
| | | } |
| | | |
| | | @Override |
| | | public void processMessage(String key, BaseCommand tyCommand) { |
| | | byte cmdCode = tyCommand.getCmdCode(); |
| | | switch (cmdCode) { |
| | | case 0x01: |
| | | // 处理心跳消息 |
| | | log.info("收到心跳消息-->处理心跳消息"); |
| | | break; |
| | | case 0x02: |
| | | // 处理注册消息 |
| | | HeartbeatReplyCommand heartbeatReplyCommand = (HeartbeatReplyCommand) tyCommand; |
| | | log.info("收到心跳消息-->处理心跳消息{}", heartbeatReplyCommand.getTimestamp()); |
| | | break; |
| | | case (byte) 0xA8: |
| | | // 处理无人机状态消息 |
| | | log.info("收到无人机状态消息-->无人机状态消息"); |
| | | break; |
| | | case (byte) 0xA9: |
| | | // 处理无人机遥测消息 |
| | | log.info("收到无人机遥测消息-->无人机遥测消息"); |
| | | break; |
| | | default: |
| | | // 处理其他消息 |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedRate = 5000) |
| | | public void sendHeartBeat() { |
| | | long timestamp = System.currentTimeMillis(); |