From 9cd863136dbcf9e8062f633869de212426bed960 Mon Sep 17 00:00:00 2001 From: Edward Valley Date: Wed, 3 Jul 2019 17:04:36 -0400 Subject: Changes after first review --- .../org/traccar/protocol/LaipacProtocolEncoder.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java') diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java index 090203806..fac82d2fd 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org) + * Copyright 2019 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,7 +15,6 @@ */ package org.traccar.protocol; -import org.traccar.Context; import org.traccar.Protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; @@ -28,8 +27,7 @@ public class LaipacProtocolEncoder extends StringProtocolEncoder { public LaipacProtocolEncoder(Protocol protocol) { this.protocol = protocol; - defaultDevicePassword = Context.getConfig().getString( - getProtocolName() + ".defaultPassword", "00000000"); + defaultDevicePassword = "00000000"; } protected String getProtocolName() { @@ -41,28 +39,28 @@ public class LaipacProtocolEncoder extends StringProtocolEncoder { initDevicePassword(command, defaultDevicePassword); - String cmd = ""; + String commandSentence = null; switch (command.getType()) { case Command.TYPE_CUSTOM: - cmd = formatCommand(command, "${%s}", + commandSentence = formatCommand(command, "${%s}", Command.KEY_DATA); break; case Command.TYPE_POSITION_SINGLE: - cmd = formatCommand(command, "$AVREQ,{%s},1", + commandSentence = formatCommand(command, "$AVREQ,{%s},1", Command.KEY_DEVICE_PASSWORD); break; case Command.TYPE_REBOOT_DEVICE: - cmd = formatCommand(command, "$AVRESET,{%s},{%s}", + commandSentence = formatCommand(command, "$AVRESET,{%s},{%s}", Command.KEY_UNIQUE_ID, Command.KEY_DEVICE_PASSWORD); break; default: break; } - if (cmd.length() > 0) { - cmd += Checksum.nmea(cmd) + "\r\n"; - return cmd; + if (commandSentence != null) { + commandSentence += Checksum.nmea(commandSentence) + "\r\n"; + return commandSentence; } return null; -- cgit v1.2.3