aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/StbProtocolDecoder.java
diff options
context:
space:
mode:
authorcasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
committercasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
commit7338b8730949ed027b3f8b31d7dca20687ebbb8b (patch)
treec2d171e6121818ab511460a786f69aab97a2a628 /src/main/java/org/traccar/protocol/StbProtocolDecoder.java
parentcdecd3fa4427a382c0b09f8ad9d69ec14388960a (diff)
parent85501f9cf4918d5eee345f83aed7a31eecb26b8d (diff)
downloadtrackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.gz
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.bz2
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.zip
Merge branch 'master' into develop
Diffstat (limited to 'src/main/java/org/traccar/protocol/StbProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/StbProtocolDecoder.java33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/main/java/org/traccar/protocol/StbProtocolDecoder.java b/src/main/java/org/traccar/protocol/StbProtocolDecoder.java
index cc985d605..641359bfd 100644
--- a/src/main/java/org/traccar/protocol/StbProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StbProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2021 - 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.
@@ -15,15 +15,12 @@
*/
package org.traccar.protocol;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonProcessingException;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.Context;
-import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
import org.traccar.model.Position;
+import org.traccar.session.DeviceSession;
import javax.json.Json;
import javax.json.JsonObject;
@@ -42,29 +39,13 @@ public class StbProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_PROPERTY = 310;
public static final int MSG_ALARM = 410;
- public static class Response {
- @JsonProperty("msgType")
- private int type;
- @JsonProperty("devId")
- private String deviceId;
- @JsonProperty("result")
- private int result;
- @JsonProperty("txnNo")
- private String transaction;
- }
-
private void sendResponse(
- Channel channel, SocketAddress remoteAddress, int type, String deviceId, JsonObject root)
- throws JsonProcessingException {
-
- Response response = new Response();
- response.type = type + 1;
- response.deviceId = deviceId;
- response.result = 1;
- response.transaction = root.getString("txnNo");
+ Channel channel, SocketAddress remoteAddress, int type, String deviceId, JsonObject root) {
+ String response = String.format(
+ "{ \"msgType\": %d, \"devId\": \"%s\", \"result\": 1, \"txnNo\": \"%s\" }",
+ type + 1, deviceId, root.getString("txnNo"));
if (channel != null) {
- channel.writeAndFlush(new NetworkMessage(
- Context.getObjectMapper().writeValueAsString(response), remoteAddress));
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}