diff options
Diffstat (limited to 'src/org/traccar/BaseProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/BaseProtocolDecoder.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java index d8130c79e..103a999b0 100644 --- a/src/org/traccar/BaseProtocolDecoder.java +++ b/src/org/traccar/BaseProtocolDecoder.java @@ -19,6 +19,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.socket.DatagramChannel; import org.traccar.helper.Log; import org.traccar.model.Device; +import org.traccar.model.Group; import org.traccar.model.Position; import java.net.InetSocketAddress; @@ -34,8 +35,17 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { public long addUnknownDevice(String uniqueId) { Device device = new Device(); + String defaultGroupName = Context.getConfig().getString("database.registerUnknown.defaultGroup", "NOTDEFINED"); device.setName(uniqueId); device.setUniqueId(uniqueId); + device.setCategory(Context.getConfig().getString("database.registerUnknown.defaultCategory", "default")); + + if (!defaultGroupName.equals("NOTDEFINED")) { + Group defaultGroup = Context.getDeviceManager().getGroupByName(defaultGroupName); + if (defaultGroup != null) { + device.setGroupId(defaultGroup.getId()); + } + } try { Context.getDeviceManager().addDevice(device); |