| | |
| | | } |
| | | |
| | | /** |
| | | * 无人机控制订阅 |
| | | */ |
| | | public void uavControlSubscribe(String boxSn) { |
| | | SubscribeCommand subscribeCommand = new SubscribeCommand(boxSn); |
| | | this.sendMessage(tyConfiguration.getIpPort(), subscribeCommand); |
| | | } |
| | | |
| | | /** |
| | | * 发送消息 |
| | | */ |
| | | public void sendMessage(String key, BaseCommand msg) { |
| | | try { |
| | | ChannelFuture future = TyNettyTcpClient.channels.get(key).getFuture(); |
| | | ChannelFuture future = TyNettyTcpClient.channels.get(key).getChannelFuture(); |
| | | Channel channel = future.channel(); |
| | | if (channel.isActive()) { |
| | | InetSocketAddress ipSocket = (InetSocketAddress) channel.remoteAddress(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 云台控制基于角度 |
| | | */ |
| | | @Override |
| | | public void controlAngle(String boxSn) { |
| | | ControlAngleCommand controlAngleCommand = new ControlAngleCommand(boxSn.getBytes(), (byte) 0x00, (byte) 0x00, (byte) 0x05); |
| | |
| | | HeartbeatReplyCommand heartbeatReplyCommand = (HeartbeatReplyCommand) tyCommand; |
| | | log.info("收到心跳消息-->处理心跳消息{}", heartbeatReplyCommand.getTimestamp()); |
| | | break; |
| | | case 0x03: |
| | | // 处理订阅消息 |
| | | SubscribeCommand subscribeCommand = (SubscribeCommand) tyCommand; |
| | | log.info("收到订阅消息-->处理订阅消息{}", subscribeCommand.getBoxSn()); |
| | | break; |
| | | case 0x04: |
| | | // 处理取消订阅消息 |
| | | subscribeCommand = (SubscribeCommand) tyCommand; |
| | | log.info("收到取消订阅消息-->处理取消订阅消息{}", subscribeCommand.getBoxSn()); |
| | | break; |
| | | case (byte) 0xA8: |
| | | // 处理无人机状态消息 |
| | | log.info("收到无人机状态消息-->无人机状态消息"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedRate = 5000) |
| | | @Scheduled(fixedRate = 3000) |
| | | public void sendHeartBeat() { |
| | | long timestamp = System.currentTimeMillis(); |
| | | log.debug("定时向天宇发送⼼跳,时间戳{}", timestamp); |