aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-28 11:18:05 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-08-28 11:18:05 +1200
commitae5fe50416df190f5374d084526518a22096871e (patch)
tree80ad67bfdc5eb3dde63cf466f090fd9379f96752 /src/org
parent726b69a642e7f4d7c54863fc7367b066f7217ad2 (diff)
downloadtrackermap-server-ae5fe50416df190f5374d084526518a22096871e.tar.gz
trackermap-server-ae5fe50416df190f5374d084526518a22096871e.tar.bz2
trackermap-server-ae5fe50416df190f5374d084526518a22096871e.zip
Add more MiniFinder commands
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/model/Command.java1
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolEncoder.java2
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocol.java3
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolEncoder.java47
-rw-r--r--src/org/traccar/protocol/WialonProtocolEncoder.java2
5 files changed, 39 insertions, 16 deletions
diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java
index 730f47842..67c624fcd 100644
--- a/src/org/traccar/model/Command.java
+++ b/src/org/traccar/model/Command.java
@@ -58,7 +58,6 @@ public class Command extends Message {
public static final String KEY_TIMEZONE = "timezone";
public static final String KEY_DEVICE_PASSWORD = "devicePassword";
public static final String KEY_RADIUS = "radius";
- public static final String KEY_PHONE_NUMBER = "phoneNumber";
public static final String KEY_MESSAGE = "message";
public static final String KEY_ENABLE = "enable";
public static final String KEY_DATA = "data";
diff --git a/src/org/traccar/protocol/MeitrackProtocolEncoder.java b/src/org/traccar/protocol/MeitrackProtocolEncoder.java
index 04cb39637..784b3b917 100644
--- a/src/org/traccar/protocol/MeitrackProtocolEncoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolEncoder.java
@@ -52,7 +52,7 @@ public class MeitrackProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, 'D', "D03,1,camera_picture.jpg");
case Command.TYPE_SEND_SMS:
return formatCommand(command, 'f', "C02,0,"
- + attributes.get(Command.KEY_PHONE_NUMBER) + "," + attributes.get(Command.KEY_MESSAGE));
+ + attributes.get(Command.KEY_PHONE) + "," + attributes.get(Command.KEY_MESSAGE));
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;
diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java
index bdd3337ed..8da621ee4 100644
--- a/src/org/traccar/protocol/MiniFinderProtocol.java
+++ b/src/org/traccar/protocol/MiniFinderProtocol.java
@@ -38,7 +38,8 @@ public class MiniFinderProtocol extends BaseProtocol {
Command.TYPE_SET_AGPS,
Command.TYPE_ALARM_FALL,
Command.TYPE_MODE_POWER_SAVING,
- Command.TYPE_MODE_DEEP_SLEEP);
+ Command.TYPE_MODE_DEEP_SLEEP,
+ Command.TYPE_SOS_NUMBER);
}
@Override
diff --git a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java
index 4d1d5b576..c5210aa0b 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java
@@ -19,33 +19,56 @@ import org.traccar.StringProtocolEncoder;
import org.traccar.helper.Log;
import org.traccar.model.Command;
-public class MiniFinderProtocolEncoder extends StringProtocolEncoder {
+public class MiniFinderProtocolEncoder extends StringProtocolEncoder implements StringProtocolEncoder.ValueFormatter {
- private int getEnabledFlag(Command command) {
- return (Boolean) command.getAttributes().get(Command.KEY_ENABLE) ? 1 : 0;
+ @Override
+ public String formatValue(String key, Object value) {
+
+ if (key.equals(Command.KEY_ENABLE)) {
+ return (Boolean) value ? "1" : "0";
+ } else if (key.equals(Command.KEY_TIMEZONE)) {
+ return String.format("%+03d", ((Number) value).longValue() / 3600);
+ } else if (key.equals(Command.KEY_INDEX)) {
+ switch (((Number) value).intValue()) {
+ case 0:
+ return "A";
+ case 1:
+ return "B";
+ case 2:
+ return "C";
+ default:
+ return null;
+ }
+ }
+
+ return null;
}
@Override
protected Object encodeCommand(Command command) {
+ initDevicePassword(command, "123456");
+
switch (command.getType()) {
case Command.TYPE_SET_TIMEZONE:
- return String.format("123456L%+03d",
- ((Number) command.getAttributes().get(Command.KEY_TIMEZONE)).longValue() / 3600);
+ return formatCommand(command, "{%s}L{%s}", this, Command.KEY_DEVICE_PASSWORD, Command.KEY_TIMEZONE);
case Command.TYPE_VOICE_MONITORING:
- return String.format("123456L%d", getEnabledFlag(command));
+ return formatCommand(command, "{%s}P{%s}", this, Command.KEY_DEVICE_PASSWORD, Command.KEY_ENABLE);
case Command.TYPE_ALARM_SPEED:
- return formatCommand(command, "123456J1{%s}", Command.KEY_DATA);
+ return formatCommand(command, "{%s}J1{%s}", Command.KEY_DEVICE_PASSWORD, Command.KEY_DATA);
case Command.TYPE_ALARM_GEOFENCE:
- return formatCommand(command, "123456R1{%s}", Command.KEY_RADIUS);
+ return formatCommand(command, "{%s}R1{%s}", Command.KEY_DEVICE_PASSWORD, Command.KEY_RADIUS);
case Command.TYPE_SET_AGPS:
- return String.format("123456AGPS%d", getEnabledFlag(command));
+ return formatCommand(command, "{%s}AGPS{%s}", this, Command.KEY_DEVICE_PASSWORD, Command.KEY_ENABLE);
case Command.TYPE_ALARM_FALL:
- return String.format("123456F%d", getEnabledFlag(command));
+ return formatCommand(command, "{%s}F{%s}", this, Command.KEY_DEVICE_PASSWORD, Command.KEY_ENABLE);
case Command.TYPE_MODE_POWER_SAVING:
- return String.format("123456SP%d", getEnabledFlag(command));
+ return formatCommand(command, "{%s}SP{%s}", this, Command.KEY_DEVICE_PASSWORD, Command.KEY_ENABLE);
case Command.TYPE_MODE_DEEP_SLEEP:
- return String.format("123456DS%d", getEnabledFlag(command));
+ return formatCommand(command, "{%s}DS{%s}", this, Command.KEY_DEVICE_PASSWORD, Command.KEY_ENABLE);
+ case Command.TYPE_SOS_NUMBER:
+ return formatCommand(command, "{%s}{%s}1,{%s}", this,
+ Command.KEY_DEVICE_PASSWORD, Command.KEY_INDEX, Command.KEY_PHONE);
default:
Log.warning(new UnsupportedOperationException(command.getType()));
return null;
diff --git a/src/org/traccar/protocol/WialonProtocolEncoder.java b/src/org/traccar/protocol/WialonProtocolEncoder.java
index 7cdc0c63c..b68dacd79 100644
--- a/src/org/traccar/protocol/WialonProtocolEncoder.java
+++ b/src/org/traccar/protocol/WialonProtocolEncoder.java
@@ -28,7 +28,7 @@ public class WialonProtocolEncoder extends StringProtocolEncoder {
case Command.TYPE_REBOOT_DEVICE:
return formatCommand(command, "reboot\r\n");
case Command.TYPE_SEND_USSD:
- return formatCommand(command, "USSD:{%s}\r\n", Command.KEY_PHONE_NUMBER);
+ return formatCommand(command, "USSD:{%s}\r\n", Command.KEY_PHONE);
case Command.TYPE_IDENTIFICATION:
return formatCommand(command, "VER?\r\n");
case Command.TYPE_OUTPUT_CONTROL: