hylexus/jt-808-protocol

这个位置似乎是错的.

HengCC opened this issue · 5 comments

msgHeader.setSubPackageSeq(this.parseIntFromBytes(data, 12, 2));

是否应该改成

msgHeader.setSubPackageSeq(this.parseIntFromBytes(data, 14, 2));

我也觉得这里应该是 msgHeader.setSubPackageSeq(this.parseIntFromBytes(data, 14, 2));

已修改

请问为什么导入maven工程,运行服务器后,用网络调试助手向服务器发送十六进制内容,服务器控制台没能显示终端鉴权、终端注册、位置信息汇报等具体信息,只是显示了调用的new Decoder4LoggingOnly()。刚接触netty,很多小问题,望见谅

@631292865 麻烦把具体报文贴出来,我抽空看看。

@631292865 麻烦把具体报文贴出来,我抽空看看。
将你的工程导入后,用网络调试助手向服务器发送十六进制的鉴权包,服务器控制台没能显示出"<<<<<[终端鉴权],phone={},flowid={}"之类的,只能显示出"ip={},hex = {}",也就是只调用了下面的ch.pipeline().addLast(new Decoder4LoggingOnly()); ,没有调用TCPSeverHandler()里的channelread()方法,请问为什么呢??刚接触netty,问题很多,望见谅,谢谢
private void bind() throws Exception {
this.bossGroup = new NioEventLoopGroup();
this.workerGroup = new NioEventLoopGroup();
ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup)//
.channel(NioServerSocketChannel.class) //
.childHandler(new ChannelInitializer() { //
@OverRide
public void initChannel(SocketChannel ch) throws Exception {
// 客户端发呆分钟后,服务器主动断开连接
ch.pipeline().addLast("idleStateHandler",
new IdleStateHandler(TPMSConsts.tcp_client_idle_minutes, 0, 0, TimeUnit.MINUTES));

					ch.pipeline().addLast(new Decoder4LoggingOnly());
					
					// 1024表示单条消息的最大长度,解码器在查找分隔符的时候,达到该长度还没找到的话会抛异常
					ch.pipeline().addLast(
							new DelimiterBasedFrameDecoder(1024, Unpooled.copiedBuffer(new byte[] { 0x7e }),
									Unpooled.copiedBuffer(new byte[] { 0x7e, 0x7e })));
					 // 分隔符解码方式
					//ch.pipeline().addLast(new PackageDataDecoder());
					ch.pipeline().addLast(new TCPServerHandler());//无法调用TCPSeverHandler()里的channelread()???
				}
			}).option(ChannelOption.SO_BACKLOG, 128) 
			.childOption(ChannelOption.SO_KEEPALIVE, true);

	this.log.info("TCP服务启动完毕,port={}", this.port);
	ChannelFuture channelFuture = serverBootstrap.bind(port).sync();
	channelFuture.channel().closeFuture().sync();
}