From 7e324a9dfb2bcde08d1524a9f3dc5114c0d49bdc Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 7 Jun 2018 16:48:41 +1200 Subject: Migrate H, I, J, K protocols --- .../traccar/protocol/IntellitracFrameDecoder.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/org/traccar/protocol/IntellitracFrameDecoder.java') diff --git a/src/org/traccar/protocol/IntellitracFrameDecoder.java b/src/org/traccar/protocol/IntellitracFrameDecoder.java index 49f8b4a5d..3b175252d 100644 --- a/src/org/traccar/protocol/IntellitracFrameDecoder.java +++ b/src/org/traccar/protocol/IntellitracFrameDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ */ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; -import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.LineBasedFrameDecoder; +import org.traccar.NetworkMessage; public class IntellitracFrameDecoder extends LineBasedFrameDecoder { @@ -31,7 +31,7 @@ public class IntellitracFrameDecoder extends LineBasedFrameDecoder { // example of sync header: 0xFA 0xF8 0x1B 0x01 0x81 0x60 0x33 0x3C @Override - protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception { + protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception { // Check minimum length if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) { @@ -40,13 +40,13 @@ public class IntellitracFrameDecoder extends LineBasedFrameDecoder { // Check for sync packet if (buf.getUnsignedShort(buf.readerIndex()) == 0xFAF8) { - ChannelBuffer syncMessage = buf.readBytes(8); - if (channel != null) { - channel.write(syncMessage); + ByteBuf syncMessage = buf.readBytes(8); + if (ctx != null && ctx.channel() != null) { + ctx.channel().write(new NetworkMessage(syncMessage, ctx.channel().remoteAddress())); } } - return super.decode(ctx, channel, buf); + return super.decode(ctx, buf); } } -- cgit v1.2.3