| | |
| | | downConnectReq.setVerifyCode(verifyCode); |
| | | log.info("从链路连接请求({}):{}", DataType.DOWN_CONNECT_REQ.getCode(), JSON.toJSONString(downConnectReq)); |
| | | byte[] body = downConnectReq.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_CONNECT_REQ.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_CONNECT_REQ.getCode(), inferiorPlatformId, body); |
| | | channel.writeAndFlush(out); |
| | | channel.flush(); |
| | | |
| | |
| | | //主链路登录应答 |
| | | log.info("主链路登录应答({}):{}", DataType.UP_CONNECT_RSP.getCode(), JSON.toJSONString(upConnectRsp)); |
| | | byte[] body = upConnectRsp.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.UP_CONNECT_RSP.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.UP_CONNECT_RSP.getCode(),outerPacket.getGnsscenterId() , body); |
| | | ctx.writeAndFlush(out); |
| | | ctx.flush(); |
| | | if (upConnectRsp.getResult() == 0x00) { |
| | |
| | | try { |
| | | boolean b = downConnect(inferiorPlatformId, host, port, verifyCode); |
| | | } catch (Exception e) { |
| | | downDisconnectInform(ctx, 0x00); |
| | | downDisconnectInform(ctx, inferiorPlatformId, 0x00); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | |
| | | * @param ctx |
| | | * @param errorCode |
| | | */ |
| | | public void downDisconnectInform(ChannelHandlerContext ctx, int errorCode) { |
| | | public void downDisconnectInform(ChannelHandlerContext ctx, int inferiorPlatformId, int errorCode) { |
| | | DOWNDisconnectInform downDisconnectInform = new DOWNDisconnectInform(); |
| | | downDisconnectInform.setErrorCode(errorCode); |
| | | log.info("从链路断开通知({}):{}", DataType.DOWN_DISCONNECT_INFORM.getCode(), JSON.toJSONString(downDisconnectInform)); |
| | | byte[] body = downDisconnectInform.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_CONNECT_REQ.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_CONNECT_REQ.getCode(), inferiorPlatformId, body); |
| | | ctx.writeAndFlush(out); |
| | | ctx.flush(); |
| | | } |
| | |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_LINKTEST_REQ.getCode(), null); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_LINKTEST_REQ.getCode(), inferiorPlatformId, null); |
| | | channel.writeAndFlush(out); |
| | | log.info("从链路连接保持请求({}):{}", DataType.DOWN_LINKTEST_REQ.getCode(), ""); |
| | | redisTemplate.opsForValue().set("login:" + inferiorPlatformId, System.currentTimeMillis(), 1, TimeUnit.MINUTES); |
| | |
| | | downPlaybackMsgControl.setFastTime(fastTime); |
| | | downPlaybackMsgControl.setDateTime(null); |
| | | byte[] body = downPlaybackMsgControl.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_PLAYBACK_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_PLAYBACK_MSG.getCode(), inferiorPlatformId, body); |
| | | channel.writeAndFlush(out); |
| | | log.info("远程录像回放控制请求({}):{}", DataType.DOWN_PLAYBACK_MSG_CONTROL.getCode(), JSON.toJSONString(downPlaybackMsgControl)); |
| | | return R.ok(); |
| | |
| | | downPlaybackMsgStartup.setAuthorizeCode(authorizeMsgStartup.getAuthorizeCode1()); |
| | | downPlaybackMsgStartup.setGnssData(""); |
| | | byte[] body = downPlaybackMsgStartup.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_PLAYBACK_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_PLAYBACK_MSG.getCode(), inferiorPlatformId, body); |
| | | channel.writeAndFlush(out); |
| | | log.info("远程录像回放请求({}):{}", DataType.DOWN_PLAYBACK_MSG_STARTUP.getCode(), JSON.toJSONString(downPlaybackMsgStartup)); |
| | | return R.ok(authorizeMsgStartup.getAuthorizeCode1()); |
| | |
| | | downRealvideoMsgEnd.setChannelId(1); |
| | | downRealvideoMsgEnd.setAvttemType(0X00); |
| | | byte[] body = downRealvideoMsgEnd.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_REALVIDEO_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_REALVIDEO_MSG.getCode(), inferiorPlatformId, body); |
| | | channel.writeAndFlush(out); |
| | | log.info("主动请求停止实时音视频({}):{}", DataType.DOWN_REALVIDEO_MSG_END.getCode(), JSON.toJSONString(downRealvideoMsgEnd)); |
| | | return R.ok(); |
| | |
| | | downRealvideoMsgStartup.setAuthorizeCode(authorizeMsgStartup.getAuthorizeCode1()); |
| | | downRealvideoMsgStartup.setGnssData(""); |
| | | byte[] body = downRealvideoMsgStartup.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_REALVIDEO_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_REALVIDEO_MSG.getCode(), inferiorPlatformId, body); |
| | | channel.writeAndFlush(out); |
| | | log.info("发起实时音视频请求({}):{}", DataType.DOWN_REALVIDEO_MSG_STARTUP.getCode(), JSON.toJSONString(downRealvideoMsgStartup)); |
| | | return R.ok(authorizeMsgStartup.getAuthorizeCode1()); |
| | |
| | | downExgMsgReportDriverInfo.setDataType(DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode()); |
| | | downExgMsgReportDriverInfo.setDataLength(0); |
| | | byte[] body = downExgMsgReportDriverInfo.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG.getCode(), inferiorPlatformId, body); |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | |
| | | downExgMsgTakeEwaybillReq.setDataLength(0); |
| | | |
| | | byte[] body = downExgMsgTakeEwaybillReq.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG.getCode(), inferiorPlatformId, body); |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | |
| | | downBaseMsgVehicleAdded.setDataLength(0); |
| | | |
| | | byte[] body = downBaseMsgVehicleAdded.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_BASE_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_BASE_MSG.getCode(), inferiorPlatformId, body); |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | |
| | | ctx.close(); |
| | | return; |
| | | } |
| | | OuterPacket rep = new OuterPacket(DataType.UP_DISCONNECT_RSP.getCode(), null); |
| | | OuterPacket rep = new OuterPacket(DataType.UP_DISCONNECT_RSP.getCode(), out.getGnsscenterId(), null); |
| | | log.info("主链路注销应答({}):{}", DataType.UP_DISCONNECT_RSP.getCode(), JSON.toJSONString(rep)); |
| | | ctx.writeAndFlush(rep); |
| | | redisTemplate.delete("login:" + out.getGnsscenterId()); |
| | |
| | | } |
| | | int gnsscenterId = out.getGnsscenterId(); |
| | | ChannelMap.addServerChannel(gnsscenterId, ctx.channel()); |
| | | OuterPacket rep = new OuterPacket(DataType.UP_LINKTEST_RSP.getCode(), null); |
| | | OuterPacket rep = new OuterPacket(DataType.UP_LINKTEST_RSP.getCode(), gnsscenterId, null); |
| | | rep.setGnsscenterId(gnsscenterId); |
| | | log.info("主链路连接保持应答({}):{}", DataType.UP_LINKTEST_RSP.getCode(), JSON.toJSONString(rep)); |
| | | ctx.writeAndFlush(rep); |
| | | } |
| | |
| | | downWarnMsgUrgeTodoReq.setDataType(DataType.DOWN_WARN_MSG_URGE_TODO_REQ.getCode()); |
| | | downWarnMsgUrgeTodoReq.setDataLength(92); |
| | | byte[] body = downWarnMsgUrgeTodoReq.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_WARN_MSG.getCode(), body); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_WARN_MSG.getCode(), inferiorPlatformId, body); |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | |
| | | int id = byteBuf.readUnsignedShort(); |
| | | // 下级平台接入码 |
| | | int gnsscenterId = byteBuf.readInt(); |
| | | ctx.channel().attr(Jtt809Constant.NettyAttribute.GNSS_CENTER_ID).setIfAbsent(String.valueOf(gnsscenterId)); |
| | | // 协议版本号标识 |
| | | String version = "v" + byteBuf.readByte() + "." + byteBuf.readByte() + "." + byteBuf.readByte(); |
| | | // 报文加密标识位 |
| | |
| | | if (packet == null) { |
| | | return; |
| | | } |
| | | int gnsscenterId; |
| | | if (ctx.channel().hasAttr(Jtt809Constant.NettyAttribute.GNSS_CENTER_ID)) { |
| | | gnsscenterId = Integer.parseInt(ctx.channel().attr(Jtt809Constant.NettyAttribute.GNSS_CENTER_ID).get()); |
| | | } else { |
| | | gnsscenterId = packet.getGnsscenterId(); |
| | | } |
| | | int gnsscenterId = packet.getGnsscenterId(); |
| | | byte[] body = packet.getBody(); |
| | | if (body == null) { |
| | | body = new byte[0]; |