diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-31 09:37:26 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-31 09:37:26 -0700 |
commit | 50e7e2b17ba580afddaf11a0ea079b4535cf2478 (patch) | |
tree | 3556c5c371f0a641d91a29fc6b3870dc6dc458a1 /src | |
parent | 02c11aa5bb9506357b5007084e80ef1bbc8ecd78 (diff) | |
download | trackermap-server-50e7e2b17ba580afddaf11a0ea079b4535cf2478.tar.gz trackermap-server-50e7e2b17ba580afddaf11a0ea079b4535cf2478.tar.bz2 trackermap-server-50e7e2b17ba580afddaf11a0ea079b4535cf2478.zip |
Implement SOS alarm
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java | 3 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java b/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java index 7e0e3e110..ea9c9767b 100644 --- a/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java @@ -83,6 +83,9 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder { } else { position.set(Position.KEY_EVENT, event); + if (event == 0x22 || event == 0x62) { + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + } while (buf.isReadable()) { int type = buf.readUnsignedByte(); diff --git a/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java index 7e7fc24bc..fdd780073 100644 --- a/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java @@ -3,6 +3,7 @@ package org.traccar.protocol; import io.netty.handler.codec.http.HttpMethod; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class SigfoxProtocolDecoderTest extends ProtocolTest { @@ -11,6 +12,10 @@ public class SigfoxProtocolDecoderTest extends ProtocolTest { SigfoxProtocolDecoder decoder = new SigfoxProtocolDecoder(null); + verifyAttribute(decoder, request(HttpMethod.POST, "/", + buffer("{ \"device\": \"40D310\", \"payload\": \"62\", \"time\": 1563043532, \"seqNumber\": 1076 }")), + Position.KEY_ALARM, Position.ALARM_SOS); + verifyAttributes(decoder, request(HttpMethod.POST, "/", buffer("{ \"device\": \"40D310\", \"payload\": \"20061494480389f956042a\", \"time\": 1563043532, \"seqNumber\": 1076 }"))); |