aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/AstraProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java40
-rwxr-xr-xsrc/org/traccar/protocol/KenjiProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TrvProtocolDecoder.java2
4 files changed, 27 insertions, 25 deletions
diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java
index 03053ca2d..8cfec95fe 100644
--- a/src/org/traccar/protocol/AstraProtocolDecoder.java
+++ b/src/org/traccar/protocol/AstraProtocolDecoder.java
@@ -78,7 +78,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(buf.readUnsignedByte() * 2);
int reason = buf.readUnsignedMedium();
- int status = buf.readUnsignedShort();
+ buf.readUnsignedShort(); // status
position.set(Event.PREFIX_IO + 1, buf.readUnsignedByte());
position.set(Event.PREFIX_ADC + 1, buf.readUnsignedByte());
@@ -107,11 +107,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder {
}
- if (BitUtil.check(status, 6)) {
-
- // extra data
-
- }
+ // extra data
positions.add(position);
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index 3179cbd78..9f332dd04 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -109,6 +109,28 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private void sendResponse(
+ Channel channel, SocketAddress remoteAddress, ChannelBuffer id, short type) {
+
+ if (channel != null) {
+ int length = 2 + 2 + id.readableBytes() + 2 + 4 + 8 + 2 + 2;
+
+ ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length);
+ response.writeByte('@'); response.writeByte('@');
+ response.writeShort(length);
+ response.writeBytes(id);
+ response.writeShort(ChannelBuffers.swapShort(type));
+ response.writeInt(0);
+ for (int i = 0; i < 8; i++) {
+ response.writeByte(0xff);
+ }
+ response.writeShort(
+ Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
+ response.writeByte(0x0D); response.writeByte(0x0A);
+ channel.write(response, remoteAddress);
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -134,23 +156,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
if (type == 0x2001) {
- if (channel != null) {
- int length = 2 + 2 + id.readableBytes() + 2 + 4 + 8 + 2 + 2;
-
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length);
- response.writeByte('@'); response.writeByte('@');
- response.writeShort(length);
- response.writeBytes(id);
- response.writeShort(ChannelBuffers.swapShort((short) 0x1001));
- response.writeInt(0);
- for (int i = 0; i < 8; i++) {
- response.writeByte(0xff);
- }
- response.writeShort(
- Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
- response.writeByte(0x0D); response.writeByte(0x0A);
- channel.write(response, remoteAddress);
- }
+ sendResponse(channel, remoteAddress, id, (short) 0x1001);
buf.readUnsignedInt(); // index
buf.readUnsignedInt(); // unix time
diff --git a/src/org/traccar/protocol/KenjiProtocolDecoder.java b/src/org/traccar/protocol/KenjiProtocolDecoder.java
index e1f8130fa..e190af948 100755
--- a/src/org/traccar/protocol/KenjiProtocolDecoder.java
+++ b/src/org/traccar/protocol/KenjiProtocolDecoder.java
@@ -47,7 +47,7 @@ public class KenjiProtocolDecoder extends BaseProtocolDecoder {
.number("G(d+)") // satellites
.any()
.compile();
-
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
diff --git a/src/org/traccar/protocol/TrvProtocolDecoder.java b/src/org/traccar/protocol/TrvProtocolDecoder.java
index 94796fa5e..8075515c2 100644
--- a/src/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrvProtocolDecoder.java
@@ -105,7 +105,7 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_GSM, parser.nextInt());
position.set(Event.KEY_SATELLITES, parser.nextInt());
- position.set(Event.KEY_BATTERY , parser.nextInt());
+ position.set(Event.KEY_BATTERY, parser.nextInt());
position.set(Event.KEY_IGNITION, parser.nextInt() != 0);
position.set("arm", parser.nextInt());