diff options
Diffstat (limited to 'src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index 2d00ea81e..21d23c24d 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -45,6 +45,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { private boolean includeAdc; private boolean includeRpm; private boolean includeTemp; + private boolean m2m; public SuntechProtocolDecoder(Protocol protocol) { super(protocol); @@ -98,6 +99,15 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { return Context.getIdentityManager().lookupAttributeBoolean( deviceId, getProtocolName() + ".includeTemp", includeTemp, false, true); } + + public void setM2M(boolean m2m) { + this.m2m = m2m; + } + + public boolean isM2M(long deviceId) { + return Context.getIdentityManager().lookupAttributeBoolean( + deviceId, getProtocolName() + ".m2m", m2m, true, false); + } private Position decode9( Channel channel, SocketAddress remoteAddress, String[] values) throws ParseException { @@ -396,11 +406,15 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { if (isHbm(deviceSession.getDeviceId())) { if (index < values.length) { - position.set(Position.KEY_HOURS, UnitsConverter.msFromMinutes(Integer.parseInt(values[index++]))); + try { + position.set(Position.KEY_HOURS, UnitsConverter.msFromMinutes(Integer.parseInt(values[index++]))); + } catch (NumberFormatException e) {} } if (index < values.length) { - position.set(Position.KEY_BATTERY, Double.parseDouble(values[index++])); + try { + position.set(Position.KEY_BATTERY, Double.parseDouble(values[index++])); + } catch (NumberFormatException e) {} } if (index < values.length && values[index++].equals("0")) { |