Skip to content

Commit

Permalink
Extend eelink protocol decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jan 5, 2017
1 parent e87edda commit 681057b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/org/traccar/protocol/EelinkProtocolDecoder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 - 2016 Anton Tananaev ([email protected])
* Copyright 2014 - 2017 Anton Tananaev ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -116,11 +116,27 @@ private Position decodeOld(DeviceSession deviceSession, ChannelBuffer buf, int t
position.setValid((buf.readUnsignedByte() & 0x01) != 0);

if (type == MSG_ALARM) {
position.set(Position.KEY_ALARM, buf.readUnsignedByte());
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
}

if (type == MSG_STATE) {
position.set(Position.KEY_STATUS, decodeAlarm(buf.readUnsignedByte()));
if (buf.readableBytes() >= 2 * 5) {

int status = buf.readUnsignedShort();
if (BitUtil.check(status, 1)) {
position.set(Position.KEY_IGNITION, BitUtil.check(status, 2));
}
if (BitUtil.check(status, 7)) {
position.set(Position.KEY_CHARGE, BitUtil.check(status, 8));
}
position.set(Position.KEY_STATUS, status);

position.set(Position.KEY_BATTERY, buf.readUnsignedShort() + "mV");

buf.readUnsignedShort(); // signal strength

position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());

}

return position;
Expand Down
3 changes: 3 additions & 0 deletions test/org/traccar/protocol/EelinkProtocolDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public void testDecode() throws Exception {
verifyNothing(decoder, binary(
"676701000c007b03525440717505180104"));

verifyPosition(decoder, binary(
"676702002509f65868507603a1e92e03cf90fe000000019f000117ee00111e0120631145003101510000"));

verifyPosition(decoder, binary(
"676712001e0092579714d60201f90001785003a301cd1a006a118504f2000000000000"));

Expand Down

0 comments on commit 681057b

Please sign in to comment.