From 3d9b8bdd2a4df0ef055e3dd064209fc5c3e8401d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 25 Apr 2016 12:30:44 +1200 Subject: Start implementing watch commands --- src/org/traccar/protocol/WatchProtocolEncoder.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/org/traccar/protocol/WatchProtocolEncoder.java (limited to 'src/org/traccar/protocol/WatchProtocolEncoder.java') diff --git a/src/org/traccar/protocol/WatchProtocolEncoder.java b/src/org/traccar/protocol/WatchProtocolEncoder.java new file mode 100644 index 000000000..f93cb7568 --- /dev/null +++ b/src/org/traccar/protocol/WatchProtocolEncoder.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.protocol; + +import org.traccar.StringProtocolEncoder; +import org.traccar.helper.Log; +import org.traccar.model.Command; + +public class WatchProtocolEncoder extends StringProtocolEncoder { + + @Override + protected Object encodeCommand(Command command) { + + switch (command.getType()) { + case Command.TYPE_REBOOT_DEVICE: + return formatCommand(command, "[CS*{%s}*0005*RESET]", Command.KEY_UNIQUE_ID); + default: + Log.warning(new UnsupportedOperationException(command.getType())); + break; + } + + return null; + } + +} -- cgit v1.2.3