From 562535fd538e7b05b6fe96c0f56eb2ec0ae1fd0e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 6 Jun 2018 16:51:47 +1200 Subject: Migrate more protocols --- .../traccar/protocol/CellocatorProtocolEncoder.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/org/traccar/protocol/CellocatorProtocolEncoder.java') diff --git a/src/org/traccar/protocol/CellocatorProtocolEncoder.java b/src/org/traccar/protocol/CellocatorProtocolEncoder.java index bb143d349..4eef42128 100644 --- a/src/org/traccar/protocol/CellocatorProtocolEncoder.java +++ b/src/org/traccar/protocol/CellocatorProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 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,34 +15,32 @@ */ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Log; import org.traccar.model.Command; -import java.nio.ByteOrder; - public class CellocatorProtocolEncoder extends BaseProtocolEncoder { - private ChannelBuffer encodeContent(long deviceId, int command, int data1, int data2) { + private ByteBuf encodeContent(long deviceId, int command, int data1, int data2) { - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0); + ByteBuf buf = Unpooled.buffer(0); buf.writeByte('M'); buf.writeByte('C'); buf.writeByte('G'); buf.writeByte('P'); buf.writeByte(0); - buf.writeInt(Integer.parseInt(getUniqueId(deviceId))); + buf.writeIntLE(Integer.parseInt(getUniqueId(deviceId))); buf.writeByte(0); // command numerator - buf.writeInt(0); // authentication code + buf.writeIntLE(0); // authentication code buf.writeByte(command); buf.writeByte(command); buf.writeByte(data1); buf.writeByte(data1); buf.writeByte(data2); buf.writeByte(data2); - buf.writeInt(0); // command specific data + buf.writeIntLE(0); // command specific data byte checksum = 0; for (int i = 4; i < buf.writerIndex(); i++) { -- cgit v1.2.3