aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-28 06:31:55 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-28 06:31:55 -0700
commit56af285413c2337079332f303f7d091d65f09c4e (patch)
tree800c4b6c3f7a54b98a63451aea3183832c64947c /src/main/java/org/traccar/protocol
parentbb50a4178d171d40734b94fccf52b72733f1f04c (diff)
downloadtrackermap-server-56af285413c2337079332f303f7d091d65f09c4e.tar.gz
trackermap-server-56af285413c2337079332f303f7d091d65f09c4e.tar.bz2
trackermap-server-56af285413c2337079332f303f7d091d65f09c4e.zip
Decode G6W audio format
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index b25a15f93..420866578 100644
--- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 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.
@@ -18,14 +18,13 @@ package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
import org.traccar.helper.BitUtil;
+import org.traccar.helper.BufferUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -41,7 +40,7 @@ import java.util.regex.Pattern;
public class WatchProtocolDecoder extends BaseProtocolDecoder {
- private static final Logger LOGGER = LoggerFactory.getLogger(WatchProtocolDecoder.class);
+ private ByteBuf audio;
public WatchProtocolDecoder(Protocol protocol) {
super(protocol);
@@ -318,13 +317,37 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type.equals("JXTK")) {
+
+ int dataIndex = BufferUtil.indexOf(buf, buf.readerIndex(), buf.writerIndex(), (byte) ',', 4) + 1;
+ String[] values = buf.readCharSequence(
+ dataIndex - buf.readerIndex(), StandardCharsets.US_ASCII).toString().split(",");
+
+ int current = Integer.parseInt(values[2]);
+ int total = Integer.parseInt(values[3]);
+
+ if (audio == null) {
+ audio = Unpooled.buffer();
+ }
+ audio.writeBytes(buf);
+
+ sendResponse(channel, id, index, "JXTKR,1");
+
+ if (current < total) {
+ return null;
+ } else {
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+ getLastLocation(position, null);
+ position.set(Position.KEY_AUDIO, Context.getMediaManager().writeFile(id, audio, "amr"));
+ audio.release();
+ audio = null;
+ return position;
+ }
+
} else if (type.equals("TK")) {
if (buf.readableBytes() == 1) {
- byte result = buf.readByte();
- if (result != '1') {
- LOGGER.warn(type + "," + result);
- }
return null;
}