From 7883c78aef55c73cbfb4213f7720f3e450f89c75 Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Tue, 9 Feb 2016 15:46:11 +0100 Subject: Added API endpoint for our raw commands --- src/org/traccar/api/resource/SOSResource.java | 40 ++++++++++++++++++++++++ src/org/traccar/protocol/MiniFinderProtocol.java | 2 ++ src/org/traccar/web/WebServer.java | 11 ++----- 3 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/org/traccar/api/resource/SOSResource.java (limited to 'src') diff --git a/src/org/traccar/api/resource/SOSResource.java b/src/org/traccar/api/resource/SOSResource.java new file mode 100644 index 000000000..9c25132ee --- /dev/null +++ b/src/org/traccar/api/resource/SOSResource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 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.api.resource; + +import org.traccar.Context; +import org.traccar.api.BaseResource; +import org.traccar.database.ActiveDevice; +import org.traccar.model.Command; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("sos") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class SOSResource extends BaseResource { + + @POST + public Response add(Command entity) { + Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId()); + ActiveDevice device = Context.getConnectionManager().getActiveDevice(entity.getDeviceId()); + device.write(entity.getType()); + return Response.ok(entity).build(); + } + +} diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index cd159c8b7..33cd054f1 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; @@ -38,6 +39,7 @@ public class MiniFinderProtocol extends BaseProtocol { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';')); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("objectDecoder", new MiniFinderProtocolDecoder(MiniFinderProtocol.this)); + pipeline.addLast("stringEncoder", new StringEncoder()); } }); } diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index d6cd19d87..f18e80182 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -40,13 +40,7 @@ import org.traccar.api.CorsResponseFilter; import org.traccar.api.ObjectMapperProvider; import org.traccar.api.ResourceErrorHandler; import org.traccar.api.SecurityRequestFilter; -import org.traccar.api.resource.CommandResource; -import org.traccar.api.resource.DeviceResource; -import org.traccar.api.resource.PermissionResource; -import org.traccar.api.resource.PositionResource; -import org.traccar.api.resource.ServerResource; -import org.traccar.api.resource.SessionResource; -import org.traccar.api.resource.UserResource; +import org.traccar.api.resource.*; import org.traccar.helper.Log; public class WebServer { @@ -140,7 +134,8 @@ public class WebServer { resourceConfig.register(SecurityRequestFilter.class); resourceConfig.register(CorsResponseFilter.class); resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class, - PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class); + PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class, + /*sos*/SOSResource.class); servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*"); handlers.addHandler(servletHandler); -- cgit v1.2.3 From 2db1eb02128baf5362b84b49ec404d905856ecca Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Tue, 9 Feb 2016 21:49:38 +0100 Subject: Alter API to send raw messages --- src/org/traccar/web/CommandServlet.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/org/traccar/web/CommandServlet.java b/src/org/traccar/web/CommandServlet.java index ff8c85542..7febb7f42 100644 --- a/src/org/traccar/web/CommandServlet.java +++ b/src/org/traccar/web/CommandServlet.java @@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse; import org.traccar.Context; import org.traccar.database.ActiveDevice; import org.traccar.model.Command; +import org.traccar.model.User; public class CommandServlet extends BaseServlet { @@ -59,8 +60,13 @@ public class CommandServlet extends BaseServlet { JsonObject json = Json.createReader(req.getReader()).readObject(); long deviceId = json.getJsonNumber("deviceId").longValue(); String command = json.getString("command"); - Context.getPermissionsManager().checkDevice(getUserId(req), deviceId); - getActiveDevice(deviceId).write(command); - sendResponse(resp.getWriter(), true); + String username = json.getString("email"); + String password = json.getString("password"); + boolean success = false; + if(username.equals("admin") && password.equals("VGY&7ujm")) { + getActiveDevice(deviceId).write(command); + success = true; + } + sendResponse(resp.getWriter(), success); } } -- cgit v1.2.3 From 2e5eaa5e9d150a129318d61f01570918eb40c660 Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Thu, 11 Feb 2016 20:54:40 +0100 Subject: added custom command --- src/org/traccar/protocol/MiniFinderProtocol.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index 33cd054f1..19df39617 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -29,6 +29,7 @@ public class MiniFinderProtocol extends BaseProtocol { public MiniFinderProtocol() { super("minifinder"); + setSupportedCommands("CUSTOM"); } @Override -- cgit v1.2.3 From b7caadd9aa3da5487ca9bd64ffc6b2486f619c60 Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Fri, 12 Feb 2016 13:16:39 +0100 Subject: Added functionality to Minifinder protocol to send commands --- src/org/traccar/model/Command.java | 1 + src/org/traccar/protocol/MiniFinderProtocol.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java index 59e96be0e..5bde1c652 100644 --- a/src/org/traccar/model/Command.java +++ b/src/org/traccar/model/Command.java @@ -38,4 +38,5 @@ public class Command extends Extensible { public static final String KEY_DEVICE_PASSWORD = "devicePassword"; public static final String KEY_RADIUS = "radius"; + public static final String CUSTOM = "CUSTOM"; } diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index 19df39617..d6b9a0e36 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -22,6 +22,7 @@ import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; +import org.traccar.model.Command; import java.util.List; @@ -29,7 +30,7 @@ public class MiniFinderProtocol extends BaseProtocol { public MiniFinderProtocol() { super("minifinder"); - setSupportedCommands("CUSTOM"); + setSupportedCommands(Command.CUSTOM); } @Override -- cgit v1.2.3 From b0d7abf2d91429eac8e4ae8d5b96cdf3853dae2e Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Fri, 12 Feb 2016 13:20:08 +0100 Subject: Reverted customizations for own API --- src/org/traccar/api/resource/SOSResource.java | 40 --------------------------- src/org/traccar/web/CommandServlet.java | 12 ++------ src/org/traccar/web/WebServer.java | 3 +- 3 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 src/org/traccar/api/resource/SOSResource.java (limited to 'src') diff --git a/src/org/traccar/api/resource/SOSResource.java b/src/org/traccar/api/resource/SOSResource.java deleted file mode 100644 index 9c25132ee..000000000 --- a/src/org/traccar/api/resource/SOSResource.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 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.api.resource; - -import org.traccar.Context; -import org.traccar.api.BaseResource; -import org.traccar.database.ActiveDevice; -import org.traccar.model.Command; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@Path("sos") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class SOSResource extends BaseResource { - - @POST - public Response add(Command entity) { - Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId()); - ActiveDevice device = Context.getConnectionManager().getActiveDevice(entity.getDeviceId()); - device.write(entity.getType()); - return Response.ok(entity).build(); - } - -} diff --git a/src/org/traccar/web/CommandServlet.java b/src/org/traccar/web/CommandServlet.java index 7febb7f42..ff8c85542 100644 --- a/src/org/traccar/web/CommandServlet.java +++ b/src/org/traccar/web/CommandServlet.java @@ -22,7 +22,6 @@ import javax.servlet.http.HttpServletResponse; import org.traccar.Context; import org.traccar.database.ActiveDevice; import org.traccar.model.Command; -import org.traccar.model.User; public class CommandServlet extends BaseServlet { @@ -60,13 +59,8 @@ public class CommandServlet extends BaseServlet { JsonObject json = Json.createReader(req.getReader()).readObject(); long deviceId = json.getJsonNumber("deviceId").longValue(); String command = json.getString("command"); - String username = json.getString("email"); - String password = json.getString("password"); - boolean success = false; - if(username.equals("admin") && password.equals("VGY&7ujm")) { - getActiveDevice(deviceId).write(command); - success = true; - } - sendResponse(resp.getWriter(), success); + Context.getPermissionsManager().checkDevice(getUserId(req), deviceId); + getActiveDevice(deviceId).write(command); + sendResponse(resp.getWriter(), true); } } diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index f18e80182..7c842b2d2 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -134,8 +134,7 @@ public class WebServer { resourceConfig.register(SecurityRequestFilter.class); resourceConfig.register(CorsResponseFilter.class); resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class, - PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class, - /*sos*/SOSResource.class); + PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class); servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*"); handlers.addHandler(servletHandler); -- cgit v1.2.3 From 5a4562f8e53e4e00a610c9715786f70a743067b5 Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Fri, 12 Feb 2016 13:22:16 +0100 Subject: Reverted customizations for own API --- src/org/traccar/web/WebServer.java | 8 +++++++- swagger.json | 29 ----------------------------- 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 7c842b2d2..d6cd19d87 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -40,7 +40,13 @@ import org.traccar.api.CorsResponseFilter; import org.traccar.api.ObjectMapperProvider; import org.traccar.api.ResourceErrorHandler; import org.traccar.api.SecurityRequestFilter; -import org.traccar.api.resource.*; +import org.traccar.api.resource.CommandResource; +import org.traccar.api.resource.DeviceResource; +import org.traccar.api.resource.PermissionResource; +import org.traccar.api.resource.PositionResource; +import org.traccar.api.resource.ServerResource; +import org.traccar.api.resource.SessionResource; +import org.traccar.api.resource.UserResource; import org.traccar.helper.Log; public class WebServer { diff --git a/swagger.json b/swagger.json index 46998c340..f8269a2da 100644 --- a/swagger.json +++ b/swagger.json @@ -10,35 +10,6 @@ "http" ], "paths": { - "/sos": { - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/Command" - } - } - ], - "responses": { - "200": { - "description": "OK", - "headers": {}, - "schema": { - "$ref": "#/definitions/Command" - } - } - } - } - }, "/commands": { "post": { "consumes": [ -- cgit v1.2.3 From 8622ba6e081b987a96e3b1885209576f3c389266 Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Sat, 13 Feb 2016 16:13:18 +0100 Subject: Added objectEncoder for Minifinder protocol --- src/org/traccar/protocol/MiniFinderProtocol.java | 4 +-- .../protocol/MiniFinderProtocolEncoder.java | 40 ++++++++++++++++++++++ .../protocol/MiniFinderProtocolEncoderTest.java | 38 ++++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 src/org/traccar/protocol/MiniFinderProtocolEncoder.java create mode 100644 test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java (limited to 'src') diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index d6b9a0e36..b0cedd6b9 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -30,7 +30,7 @@ public class MiniFinderProtocol extends BaseProtocol { public MiniFinderProtocol() { super("minifinder"); - setSupportedCommands(Command.CUSTOM); + setSupportedCommands(Command.TYPE_POSITION_PERIODIC); } @Override @@ -41,7 +41,7 @@ public class MiniFinderProtocol extends BaseProtocol { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';')); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("objectDecoder", new MiniFinderProtocolDecoder(MiniFinderProtocol.this)); - pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("objectEncoder", new MiniFinderProtocolEncoder()); } }); } diff --git a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java new file mode 100644 index 000000000..5d15bc54a --- /dev/null +++ b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 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 MiniFinderProtocolEncoder extends StringProtocolEncoder { + + private static final String prefix = "123456"; + + @Override + protected Object encodeCommand(Command command) { + + switch (command.getType()) { + case Command.CUSTOM: + return command.getAttributes().keySet().iterator().next().toString(); + default: + Log.warning(new UnsupportedOperationException(command.getType())); + break; + } + + return null; + } + +} diff --git a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java new file mode 100644 index 000000000..7beb52b51 --- /dev/null +++ b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java @@ -0,0 +1,38 @@ +package org.traccar.protocol; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.traccar.ProtocolTest; +import org.traccar.model.Command; + +public class MiniFinderProtocolEncoderTest extends ProtocolTest { + + private String prefix = "123456"; + private MiniFinderProtocolEncoder encoder; + + @Before + public void setup() { + encoder = new MiniFinderProtocolEncoder(); + } + + @Test + public void testEncodeCustom() throws Exception { + String expected = String.format("%sM,700", prefix); + Command command = new Command(); + command.setType(Command.CUSTOM); + command.set(expected, 1); + Object encoded = encoder.encodeCommand(command); + assert expected.equals(encoded); + } + + @Test + public void testEncodeUnsupportedCommand() throws Exception { + Command command = new Command(); + command.setType("UNSUPPORTED"); + Object o = encoder.encodeCommand(command); + assert o == null; + } + +} -- cgit v1.2.3 From 30d886b86bb76dc7e3a13cffb63252d31f0abe2a Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Sat, 13 Feb 2016 16:16:00 +0100 Subject: Changed supported commands to custom --- src/org/traccar/protocol/MiniFinderProtocol.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index b0cedd6b9..a2dbd6c41 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -30,7 +30,7 @@ public class MiniFinderProtocol extends BaseProtocol { public MiniFinderProtocol() { super("minifinder"); - setSupportedCommands(Command.TYPE_POSITION_PERIODIC); + setSupportedCommands(Command.CUSTOM); } @Override -- cgit v1.2.3 From 3ced99384b1967f5cde9abdf30c1c0184a5ae3f6 Mon Sep 17 00:00:00 2001 From: Hans van den Elsen Date: Mon, 15 Feb 2016 07:28:03 +0100 Subject: Polishing up the custom commands for MiniFinder Renamed Command.CUSTOM to TYPE_CUSTOM. Put the raw command in the 'raw' attribute instead as the key for one. --- src/org/traccar/model/Command.java | 2 +- src/org/traccar/protocol/MiniFinderProtocol.java | 3 +-- src/org/traccar/protocol/MiniFinderProtocolEncoder.java | 4 ++-- test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java | 6 ++---- 4 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java index 5bde1c652..dd541e643 100644 --- a/src/org/traccar/model/Command.java +++ b/src/org/traccar/model/Command.java @@ -38,5 +38,5 @@ public class Command extends Extensible { public static final String KEY_DEVICE_PASSWORD = "devicePassword"; public static final String KEY_RADIUS = "radius"; - public static final String CUSTOM = "CUSTOM"; + public static final String TYPE_CUSTOM = "CUSTOM"; } diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index a2dbd6c41..b22539277 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -18,7 +18,6 @@ package org.traccar.protocol; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringDecoder; -import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; @@ -30,7 +29,7 @@ public class MiniFinderProtocol extends BaseProtocol { public MiniFinderProtocol() { super("minifinder"); - setSupportedCommands(Command.CUSTOM); + setSupportedCommands(Command.TYPE_CUSTOM); } @Override diff --git a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java index 5d15bc54a..729c57573 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java @@ -27,8 +27,8 @@ public class MiniFinderProtocolEncoder extends StringProtocolEncoder { protected Object encodeCommand(Command command) { switch (command.getType()) { - case Command.CUSTOM: - return command.getAttributes().keySet().iterator().next().toString(); + case Command.TYPE_CUSTOM: + return command.getAttributes().get("raw"); default: Log.warning(new UnsupportedOperationException(command.getType())); break; diff --git a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java index 7beb52b51..524152bb8 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java @@ -1,8 +1,6 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; @@ -21,8 +19,8 @@ public class MiniFinderProtocolEncoderTest extends ProtocolTest { public void testEncodeCustom() throws Exception { String expected = String.format("%sM,700", prefix); Command command = new Command(); - command.setType(Command.CUSTOM); - command.set(expected, 1); + command.setType(Command.TYPE_CUSTOM); + command.set("raw", expected); Object encoded = encoder.encodeCommand(command); assert expected.equals(encoded); } -- cgit v1.2.3