aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/Context.java13
-rw-r--r--src/org/traccar/FilterHandler.java16
-rw-r--r--src/org/traccar/LocationProviderHandler.java8
-rw-r--r--src/org/traccar/database/QueryBuilder.java5
-rw-r--r--src/org/traccar/events/MaintenanceEventHandler.java4
-rw-r--r--src/org/traccar/events/OverspeedEventHandler.java6
-rw-r--r--src/org/traccar/location/BaseLocationProvider.java52
-rw-r--r--src/org/traccar/location/CellInfo.java136
-rw-r--r--src/org/traccar/location/GoogleLocationProvider.java26
-rw-r--r--src/org/traccar/location/LocationProvider.java8
-rw-r--r--src/org/traccar/location/MozillaLocationProvider.java53
-rw-r--r--src/org/traccar/location/OpenCellIdLocationProvider.java56
-rw-r--r--src/org/traccar/location/UniversalLocationProvider.java66
-rw-r--r--src/org/traccar/model/CellTower.java42
-rw-r--r--src/org/traccar/model/Network.java7
-rw-r--r--src/org/traccar/model/Position.java6
-rw-r--r--src/org/traccar/protocol/ApelProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/AquilaProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/AstraProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/AutoFonProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Avl301ProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/BceProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CarcellProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/CguardProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/CradlepointProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/DishaProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/FifotrackProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/FlextrackProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Gt02ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java66
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/HaicomProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/IdplProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/JpKorjarProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java21
-rw-r--r--src/org/traccar/protocol/L100ProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/MaestroProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/OigoProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/RaveonProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/T800xProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/ThinkRaceProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java17
-rw-r--r--src/org/traccar/protocol/Tr900ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TrvProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/Tt8850ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TzoneProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/UproProtocolDecoder.java15
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/XirgoProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Xt013ProtocolDecoder.java2
73 files changed, 452 insertions, 504 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index 5d6e14efc..14ef85929 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -44,6 +44,7 @@ import org.traccar.geocode.NominatimReverseGeocoder;
import org.traccar.geocode.OpenCageReverseGeocoder;
import org.traccar.geocode.ReverseGeocoder;
import org.traccar.helper.Log;
+import org.traccar.location.GoogleLocationProvider;
import org.traccar.location.LocationProvider;
import org.traccar.location.MozillaLocationProvider;
import org.traccar.location.OpenCellIdLocationProvider;
@@ -249,20 +250,21 @@ public final class Context {
}
if (config.getBoolean("location.enable")) {
- String type = config.getString("location.type", "opencellid");
+ String type = config.getString("location.type", "mozilla");
String key = config.getString("location.key");
switch (type) {
- case "mozilla":
+ case "google":
+ locationProvider = new GoogleLocationProvider(key);
+ case "opencellid":
+ locationProvider = new OpenCellIdLocationProvider(key);
+ default:
if (key != null) {
locationProvider = new MozillaLocationProvider(key);
} else {
locationProvider = new MozillaLocationProvider();
}
break;
- default:
- locationProvider = new OpenCellIdLocationProvider(key);
- break;
}
}
@@ -311,6 +313,7 @@ public final class Context {
public static void init(IdentityManager testIdentityManager) {
config = new Config();
+ objectMapper = new ObjectMapper();
identityManager = testIdentityManager;
}
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index 898651837..0a54cfeca 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -21,16 +21,14 @@ import org.traccar.model.Position;
public class FilterHandler extends BaseDataHandler {
- private static final long FILTER_FUTURE_LIMIT = 5 * 60 * 1000;
-
private boolean filterInvalid;
private boolean filterZero;
private boolean filterDuplicate;
- private boolean filterFuture;
private boolean filterApproximate;
private boolean filterStatic;
private int filterDistance;
private long filterLimit;
+ private long filterFuture;
public void setFilterInvalid(boolean filterInvalid) {
this.filterInvalid = filterInvalid;
@@ -44,10 +42,6 @@ public class FilterHandler extends BaseDataHandler {
this.filterDuplicate = filterDuplicate;
}
- public void setFilterFuture(boolean filterFuture) {
- this.filterFuture = filterFuture;
- }
-
public void setFilterApproximate(boolean filterApproximate) {
this.filterApproximate = filterApproximate;
}
@@ -64,17 +58,21 @@ public class FilterHandler extends BaseDataHandler {
this.filterLimit = filterLimit;
}
+ public void setFilterFuture(long filterFuture) {
+ this.filterFuture = filterFuture;
+ }
+
public FilterHandler() {
Config config = Context.getConfig();
if (config != null) {
filterInvalid = config.getBoolean("filter.invalid");
filterZero = config.getBoolean("filter.zero");
filterDuplicate = config.getBoolean("filter.duplicate");
- filterFuture = config.getBoolean("filter.future");
filterApproximate = config.getBoolean("filter.approximate");
filterStatic = config.getBoolean("filter.static");
filterDistance = config.getInteger("filter.distance");
filterLimit = config.getLong("filter.limit") * 1000;
+ filterFuture = config.getLong("filter.future") * 1000;
}
}
@@ -107,7 +105,7 @@ public class FilterHandler extends BaseDataHandler {
}
private boolean filterFuture(Position position) {
- return filterFuture && position.getFixTime().getTime() > System.currentTimeMillis() + FILTER_FUTURE_LIMIT;
+ return filterFuture != 0 && position.getFixTime().getTime() > System.currentTimeMillis() + filterFuture;
}
private boolean filterApproximate(Position position) {
diff --git a/src/org/traccar/LocationProviderHandler.java b/src/org/traccar/LocationProviderHandler.java
index d47f05bd1..5f07358ec 100644
--- a/src/org/traccar/LocationProviderHandler.java
+++ b/src/org/traccar/LocationProviderHandler.java
@@ -44,15 +44,17 @@ public class LocationProviderHandler implements ChannelUpstreamHandler {
Object message = e.getMessage();
if (message instanceof Position) {
final Position position = (Position) message;
- if (position.getOutdated() || processInvalidPositions && !position.getValid()) {
- locationProvider.getLocation(position.getAttributes(), new LocationProvider.LocationProviderCallback() {
+ if ((position.getOutdated() || processInvalidPositions && !position.getValid())
+ && position.getNetwork() != null) {
+ locationProvider.getLocation(position.getNetwork(), new LocationProvider.LocationProviderCallback() {
@Override
- public void onSuccess(double latitude, double longitude) {
+ public void onSuccess(double latitude, double longitude, double accuracy) {
position.set(Position.KEY_APPROXIMATE, true);
position.setValid(true);
position.setFixTime(position.getDeviceTime());
position.setLatitude(latitude);
position.setLongitude(longitude);
+ position.setAccuracy(accuracy);
Channels.fireMessageReceived(ctx, position, e.getRemoteAddress());
}
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java
index 127229700..5a4948de0 100644
--- a/src/org/traccar/database/QueryBuilder.java
+++ b/src/org/traccar/database/QueryBuilder.java
@@ -308,7 +308,8 @@ public final class QueryBuilder {
}
private <T> void addProcessors(
- List<ResultSetProcessor<T>> processors, Class<?> parameterType, final Method method, final String name) {
+ List<ResultSetProcessor<T>> processors,
+ final Class<?> parameterType, final Method method, final String name) {
if (parameterType.equals(boolean.class)) {
processors.add(new ResultSetProcessor<T>() {
@@ -397,7 +398,7 @@ public final class QueryBuilder {
String value = resultSet.getString(name);
if (value != null) {
try {
- method.invoke(object, Context.getObjectMapper().readValue(value, Map.class));
+ method.invoke(object, Context.getObjectMapper().readValue(value, parameterType));
} catch (InvocationTargetException | IllegalAccessException | IOException error) {
Log.warning(error);
}
diff --git a/src/org/traccar/events/MaintenanceEventHandler.java b/src/org/traccar/events/MaintenanceEventHandler.java
index 4d0d93080..86836f6af 100644
--- a/src/org/traccar/events/MaintenanceEventHandler.java
+++ b/src/org/traccar/events/MaintenanceEventHandler.java
@@ -58,7 +58,9 @@ public class MaintenanceEventHandler extends BaseEventHandler {
newTotalDistance -= maintenanceStart;
if ((long) (oldTotalDistance / maintenanceInterval) < (long) (newTotalDistance / maintenanceInterval)) {
- return Collections.singleton(new Event(Event.TYPE_MAINTENANCE, position.getDeviceId(), position.getId()));
+ Event event = new Event(Event.TYPE_MAINTENANCE, position.getDeviceId(), position.getId());
+ event.set(Position.KEY_TOTAL_DISTANCE, newTotalDistance);
+ return Collections.singleton(event);
}
return null;
diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/events/OverspeedEventHandler.java
index 67aa0e758..00c3845d2 100644
--- a/src/org/traccar/events/OverspeedEventHandler.java
+++ b/src/org/traccar/events/OverspeedEventHandler.java
@@ -59,8 +59,10 @@ public class OverspeedEventHandler extends BaseEventHandler {
}
}
if (speed > speedLimit && oldSpeed <= speedLimit) {
- return Collections.singleton(
- new Event(Event.TYPE_DEVICE_OVERSPEED, position.getDeviceId(), position.getId()));
+ Event event = new Event(Event.TYPE_DEVICE_OVERSPEED, position.getDeviceId(), position.getId());
+ event.set("speed", speed);
+ event.set(ATTRIBUTE_SPEED_LIMIT, speedLimit);
+ return Collections.singleton(event);
}
return null;
}
diff --git a/src/org/traccar/location/BaseLocationProvider.java b/src/org/traccar/location/BaseLocationProvider.java
deleted file mode 100644
index d228685e2..000000000
--- a/src/org/traccar/location/BaseLocationProvider.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2015 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.
- * 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.location;
-
-import org.traccar.Config;
-import org.traccar.Context;
-import org.traccar.model.Position;
-
-import java.util.Map;
-
-public abstract class BaseLocationProvider implements LocationProvider {
-
- @Override
- public void getLocation(Map<String, Object> attributes, LocationProviderCallback callback) {
-
- Config config = Context.getConfig();
-
- Number mcc = (Number) attributes.get(Position.KEY_MCC);
- if (mcc == null && config.hasKey("location.mcc")) {
- mcc = config.getInteger("location.mcc");
- }
-
- Number mnc = (Number) attributes.get(Position.KEY_MNC);
- if (mnc == null && config.hasKey("location.mnc")) {
- mnc = config.getInteger("location.mnc");
- }
-
- Number lac = (Number) attributes.get(Position.KEY_LAC);
- Number cid = (Number) attributes.get(Position.KEY_CID);
-
- if (mcc != null && mnc != null && lac != null && cid != null) {
- getLocation(mcc.intValue(), mnc.intValue(), lac.longValue(), cid.longValue(), callback);
- }
-
- }
-
- protected abstract void getLocation(int mcc, int mnc, long lac, long cid, LocationProviderCallback callback);
-
-}
diff --git a/src/org/traccar/location/CellInfo.java b/src/org/traccar/location/CellInfo.java
deleted file mode 100644
index 2257cb1e8..000000000
--- a/src/org/traccar/location/CellInfo.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016 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.
- * 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.location;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.traccar.Config;
-import org.traccar.Context;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-public class CellInfo {
-
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- public static class Cell {
-
- private int mcc;
- private int mnc;
- private int lac;
- private int cid;
- private int signal;
-
- public Cell() {
- }
-
- public Cell(int mcc, int mnc, int lac, int cid, int signal) {
- this.mcc = mcc;
- this.mnc = mnc;
- this.lac = lac;
- this.cid = cid;
- this.signal = signal;
- }
-
- public int getMcc() {
- return mcc;
- }
-
- public void setMcc(int mcc) {
- this.mcc = mcc;
- }
-
- public int getMnc() {
- return mnc;
- }
-
- public void setMnc(int mnc) {
- this.mnc = mnc;
- }
-
- public int getLac() {
- return lac;
- }
-
- public void setLac(int lac) {
- this.lac = lac;
- }
-
- public int getCid() {
- return cid;
- }
-
- public void setCid(int cid) {
- this.cid = cid;
- }
-
- public int getSignal() {
- return signal;
- }
-
- public void setSignal(int signal) {
- this.signal = signal;
- }
- }
-
- public CellInfo() {
- }
-
- public CellInfo(Collection<Cell> cells) {
- this.cells.addAll(cells);
- }
-
- private List<Cell> cells = new ArrayList<>();
-
- public List<Cell> getCells() {
- return cells;
- }
-
- public void addCell(int lac, int cid) {
- Config config = Context.getConfig();
- if (config.hasKey("location.mcc") && config.hasKey("location.mnc")) {
- int mcc = config.getInteger("location.mcc");
- int mnc = config.getInteger("location.mnc");
- cells.add(new Cell(mcc, mnc, lac, cid, 0));
- }
- }
-
- public void addCell(int mcc, int mnc, int lac, int cid) {
- cells.add(new Cell(mcc, mnc, lac, cid, 0));
- }
-
- @Override
- public String toString() {
- try {
- return new ObjectMapper().writeValueAsString(cells);
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static CellInfo fromString(String json) {
- try {
- return new CellInfo(Arrays.asList(new ObjectMapper().readValue(json, Cell[].class)));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/src/org/traccar/location/GoogleLocationProvider.java b/src/org/traccar/location/GoogleLocationProvider.java
new file mode 100644
index 000000000..d4c449170
--- /dev/null
+++ b/src/org/traccar/location/GoogleLocationProvider.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 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.
+ * 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.location;
+
+public class GoogleLocationProvider extends UniversalLocationProvider {
+
+ private static final String URL = "https://www.googleapis.com/geolocation/v1/geolocate";
+
+ public GoogleLocationProvider(String key) {
+ super(URL, key);
+ }
+
+}
diff --git a/src/org/traccar/location/LocationProvider.java b/src/org/traccar/location/LocationProvider.java
index cc445c2b3..47b9f8909 100644
--- a/src/org/traccar/location/LocationProvider.java
+++ b/src/org/traccar/location/LocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2016 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,18 +15,18 @@
*/
package org.traccar.location;
-import java.util.Map;
+import org.traccar.model.Network;
public interface LocationProvider {
interface LocationProviderCallback {
- void onSuccess(double latitude, double longitude);
+ void onSuccess(double latitude, double longitude, double accuracy);
void onFailure();
}
- void getLocation(Map<String, Object> attributes, LocationProviderCallback callback);
+ void getLocation(Network network, LocationProviderCallback callback);
}
diff --git a/src/org/traccar/location/MozillaLocationProvider.java b/src/org/traccar/location/MozillaLocationProvider.java
index cbfc19550..90be7c456 100644
--- a/src/org/traccar/location/MozillaLocationProvider.java
+++ b/src/org/traccar/location/MozillaLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2016 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,63 +15,16 @@
*/
package org.traccar.location;
-import com.ning.http.client.AsyncCompletionHandler;
-import com.ning.http.client.Response;
-import org.traccar.Context;
-
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
-public class MozillaLocationProvider extends BaseLocationProvider {
+public class MozillaLocationProvider extends UniversalLocationProvider {
private static final String URL = "https://location.services.mozilla.com/v1/geolocate";
- private String url;
- private String template;
-
public MozillaLocationProvider() {
this("test");
}
public MozillaLocationProvider(String key) {
- this.url = URL + "?key=" + key;
-
- template = new StringBuilder()
- .append("{\"cellTowers\":[{")
- .append("\"radioType\":\"gsm\",")
- .append("\"mobileCountryCode\":%d,")
- .append("\"mobileNetworkCode\":%d,")
- .append("\"locationAreaCode\":%d,")
- .append("\"cellId\":%d")
- .append("}]}")
- .toString();
- }
-
- protected void getLocation(int mcc, int mnc, long lac, long cid, final LocationProviderCallback callback) {
- String body = String.format(template, mcc, mnc, lac, cid);
- Context.getAsyncHttpClient().preparePost(url).setBody(body).execute(new AsyncCompletionHandler() {
- @Override
- public Object onCompleted(Response response) throws Exception {
- try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {
- JsonObject json = reader.readObject().getJsonObject("location");
- if (json.containsKey("lat") && json.containsKey("lon")) {
- callback.onSuccess(
- json.getJsonNumber("lat").doubleValue(),
- json.getJsonNumber("lon").doubleValue());
- } else {
- callback.onFailure();
- }
- }
- return null;
- }
-
- @Override
- public void onThrowable(Throwable t) {
- callback.onFailure();
- }
- });
-
+ super(URL, key);
}
}
diff --git a/src/org/traccar/location/OpenCellIdLocationProvider.java b/src/org/traccar/location/OpenCellIdLocationProvider.java
index d5d1b0ace..b45797b80 100644
--- a/src/org/traccar/location/OpenCellIdLocationProvider.java
+++ b/src/org/traccar/location/OpenCellIdLocationProvider.java
@@ -18,12 +18,14 @@ package org.traccar.location;
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.Response;
import org.traccar.Context;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
-public class OpenCellIdLocationProvider extends BaseLocationProvider {
+public class OpenCellIdLocationProvider implements LocationProvider {
private String url;
@@ -35,29 +37,39 @@ public class OpenCellIdLocationProvider extends BaseLocationProvider {
this.url = url + "?format=json&mcc=%d&mnc=%d&lac=%d&cellid=%d&key=" + key;
}
- protected void getLocation(int mcc, int mnc, long lac, long cid, final LocationProviderCallback callback) {
- Context.getAsyncHttpClient().prepareGet(String.format(url, mcc, mnc, lac, cid))
- .execute(new AsyncCompletionHandler() {
- @Override
- public Object onCompleted(Response response) throws Exception {
- try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {
- JsonObject json = reader.readObject();
- if (json.containsKey("lat") && json.containsKey("lon")) {
- callback.onSuccess(
- json.getJsonNumber("lat").doubleValue(),
- json.getJsonNumber("lon").doubleValue());
- } else {
- callback.onFailure();
+ @Override
+ public void getLocation(Network network, final LocationProviderCallback callback) {
+ if (network.getCellTowers() != null && !network.getCellTowers().isEmpty()) {
+
+ CellTower cellTower = network.getCellTowers().iterator().next();
+ String request = String.format(url, cellTower.getMobileCountryCode(), cellTower.getMobileNetworkCode(),
+ cellTower.getLocationAreaCode(), cellTower.getCellId());
+
+ Context.getAsyncHttpClient().prepareGet(request).execute(new AsyncCompletionHandler() {
+ @Override
+ public Object onCompleted(Response response) throws Exception {
+ try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {
+ JsonObject json = reader.readObject();
+ if (json.containsKey("lat") && json.containsKey("lon")) {
+ callback.onSuccess(
+ json.getJsonNumber("lat").doubleValue(),
+ json.getJsonNumber("lon").doubleValue(), 0);
+ } else {
+ callback.onFailure();
+ }
}
+ return null;
}
- return null;
- }
-
- @Override
- public void onThrowable(Throwable t) {
- callback.onFailure();
- }
- });
+
+ @Override
+ public void onThrowable(Throwable t) {
+ callback.onFailure();
+ }
+ });
+
+ } else {
+ callback.onFailure();
+ }
}
}
diff --git a/src/org/traccar/location/UniversalLocationProvider.java b/src/org/traccar/location/UniversalLocationProvider.java
new file mode 100644
index 000000000..7f7028545
--- /dev/null
+++ b/src/org/traccar/location/UniversalLocationProvider.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 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.
+ * 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.location;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.ning.http.client.AsyncCompletionHandler;
+import com.ning.http.client.Response;
+import org.traccar.Context;
+import org.traccar.helper.Log;
+import org.traccar.model.Network;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+
+public class UniversalLocationProvider implements LocationProvider {
+
+ private String url;
+
+ public UniversalLocationProvider(String url, String key) {
+ this.url = url + "?key=" + key;
+ }
+
+ @Override
+ public void getLocation(Network network, final LocationProviderCallback callback) {
+ try {
+ String request = Context.getObjectMapper().writeValueAsString(network);
+ Context.getAsyncHttpClient().preparePost(url).setBody(request).execute(new AsyncCompletionHandler() {
+ @Override
+ public Object onCompleted(Response response) throws Exception {
+ try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {
+ JsonObject json = reader.readObject();
+ JsonObject location = json.getJsonObject("location");
+ callback.onSuccess(
+ location.getJsonNumber("lat").doubleValue(),
+ location.getJsonNumber("lng").doubleValue(),
+ json.getJsonNumber("accuracy").doubleValue());
+ }
+ return null;
+ }
+
+ @Override
+ public void onThrowable(Throwable t) {
+ callback.onFailure();
+ }
+ });
+ } catch (JsonProcessingException e) {
+ Log.warning(e);
+ callback.onFailure();
+ }
+ }
+
+}
diff --git a/src/org/traccar/model/CellTower.java b/src/org/traccar/model/CellTower.java
index 3447bb921..e572dfb10 100644
--- a/src/org/traccar/model/CellTower.java
+++ b/src/org/traccar/model/CellTower.java
@@ -16,17 +16,43 @@
package org.traccar.model;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.traccar.Context;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class CellTower {
- private Integer cellId;
+ public static CellTower from(int mcc, int mnc, int lac, long cid) {
+ CellTower cellTower = new CellTower();
+ cellTower.setMobileCountryCode(mcc);
+ cellTower.setMobileNetworkCode(mnc);
+ cellTower.setLocationAreaCode(lac);
+ cellTower.setCellId(cid);
+ return cellTower;
+ }
+
+ public static CellTower from(int mcc, int mnc, int lac, long cid, int rssi) {
+ CellTower cellTower = CellTower.from(mcc, mnc, lac, cid);
+ cellTower.setSignalStrength(rssi);
+ return cellTower;
+ }
+
+ public static CellTower fromLacCid(int lac, long cid) {
+ return from(
+ Context.getConfig().getInteger("location.mcc"),
+ Context.getConfig().getInteger("location.mnc"), lac, cid);
+ }
+
+ public static CellTower fromCidLac(long cid, int lac) {
+ return fromLacCid(lac, cid);
+ }
- public Integer getCellId() {
+ private Long cellId;
+
+ public Long getCellId() {
return cellId;
}
- public void setCellId(Integer cellId) {
+ public void setCellId(Long cellId) {
this.cellId = cellId;
}
@@ -60,4 +86,14 @@ public class CellTower {
this.mobileNetworkCode = mobileNetworkCode;
}
+ private Integer signalStrength;
+
+ public Integer getSignalStrength() {
+ return signalStrength;
+ }
+
+ public void setSignalStrength(Integer signalStrength) {
+ this.signalStrength = signalStrength;
+ }
+
}
diff --git a/src/org/traccar/model/Network.java b/src/org/traccar/model/Network.java
index 9dd315640..389ce1fdd 100644
--- a/src/org/traccar/model/Network.java
+++ b/src/org/traccar/model/Network.java
@@ -23,6 +23,13 @@ import java.util.Collection;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Network {
+ public Network() {
+ }
+
+ public Network(CellTower cellTower) {
+ addCellTower(cellTower);
+ }
+
private Integer homeMobileCountryCode;
public Integer getHomeMobileCountryCode() {
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 1b362632d..b43f2455e 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -23,7 +23,7 @@ public class Position extends Message {
public static final String KEY_INDEX = "index";
public static final String KEY_HDOP = "hdop";
public static final String KEY_SATELLITES = "sat";
- public static final String KEY_GSM = "gsm";
+ public static final String KEY_RSSI = "rssi";
public static final String KEY_GPS = "gps";
public static final String KEY_EVENT = "event";
public static final String KEY_ALARM = "alarm";
@@ -35,10 +35,6 @@ public class Position extends Message {
public static final String KEY_OUTPUT = "output";
public static final String KEY_POWER = "power";
public static final String KEY_BATTERY = "battery";
- public static final String KEY_MCC = "mcc";
- public static final String KEY_MNC = "mnc";
- public static final String KEY_LAC = "lac";
- public static final String KEY_CID = "cid";
public static final String KEY_FUEL = "fuel";
public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption";
public static final String KEY_RFID = "rfid";
diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java
index aa58e478f..6e16e02be 100644
--- a/src/org/traccar/protocol/ApelProtocolDecoder.java
+++ b/src/org/traccar/protocol/ApelProtocolDecoder.java
@@ -175,7 +175,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
if (subtype == MSG_STATE_FULL_INFO_T104) {
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
position.set(Position.KEY_EVENT, buf.readUnsignedShort());
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
position.set(Position.KEY_INPUT, buf.readUnsignedByte());
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java
index 1ce763463..60a9c4708 100644
--- a/src/org/traccar/protocol/AquilaProtocolDecoder.java
+++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java
@@ -99,7 +99,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java
index 390434d54..71f2080bb 100644
--- a/src/org/traccar/protocol/AstraProtocolDecoder.java
+++ b/src/org/traccar/protocol/AstraProtocolDecoder.java
@@ -100,7 +100,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder {
int quality = buf.readUnsignedByte();
position.set(Position.KEY_SATELLITES, quality & 0xf);
- position.set(Position.KEY_GSM, quality >> 4);
+ position.set(Position.KEY_RSSI, quality >> 4);
buf.readUnsignedByte(); // geofence events
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index 9c34a2e78..8e3cd2089 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -93,13 +93,13 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
break;
case "GQ":
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ buf.readUnsignedByte(); // rssi
break;
case "CE":
- position.set(Position.KEY_CID, buf.readUnsignedInt());
+ buf.readUnsignedInt(); // cid
break;
case "LC":
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
+ buf.readUnsignedShort(); // lac
break;
case "CN":
buf.readUnsignedInt(); // mcc + mnc
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
index 1c618fdee..d75ff2fe1 100644
--- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
@@ -84,7 +84,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.PREFIX_TEMP + 1, buf.readByte());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
buf.readUnsignedShort(); // mcc
buf.readUnsignedShort(); // mnc
buf.readUnsignedShort(); // lac
diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
index cac6f717f..c19b96cb9 100644
--- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
@@ -21,6 +21,8 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -121,8 +123,9 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
position.set("acc", (union & 0x8000) != 0);
}
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedMedium());
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedMedium())));
+
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
int flags = buf.readUnsignedByte();
position.set("acc", (flags & 0x2) != 0);
@@ -130,7 +133,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
// parse other flags
position.set(Position.KEY_POWER, buf.readUnsignedByte());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
return position;
}
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java
index dace89659..06290d50d 100644
--- a/src/org/traccar/protocol/BceProtocolDecoder.java
+++ b/src/org/traccar/protocol/BceProtocolDecoder.java
@@ -21,6 +21,8 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -128,11 +130,10 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
}
if (BitUtil.check(mask, 14)) {
- position.set(Position.KEY_MCC, buf.readUnsignedShort());
- position.set(Position.KEY_MNC, buf.readUnsignedByte());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedByte(),
+ buf.readUnsignedShort(), buf.readUnsignedShort())));
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
buf.readUnsignedByte();
}
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index ee4cc65b4..60b19ab06 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -95,7 +95,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
if (type != MSG_MINI_EVENT_REPORT) {
position.set("carrier", buf.readUnsignedShort());
- position.set(Position.KEY_GSM, buf.readShort());
+ position.set(Position.KEY_RSSI, buf.readShort());
}
position.set("modem", buf.readUnsignedByte());
diff --git a/src/org/traccar/protocol/CarcellProtocolDecoder.java b/src/org/traccar/protocol/CarcellProtocolDecoder.java
index 5f5877852..23889a5bd 100644
--- a/src/org/traccar/protocol/CarcellProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarcellProtocolDecoder.java
@@ -123,7 +123,7 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder {
Double internalBattery = (parser.nextDouble() + 100d) * 0.0294d;
position.set(Position.KEY_BATTERY, internalBattery);
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set("jamming", parser.next().equals("1"));
position.set(Position.KEY_GPS, parser.nextInt());
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index 790dcd932..07d26f2b1 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.ObdDecoder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -331,8 +333,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
decodeStat(position, buf);
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
return position;
@@ -366,8 +368,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // geo-fencing flags
buf.readUnsignedByte(); // additional flags
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
positions.add(position);
}
diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java
index c5dc51d81..2fc3194db 100644
--- a/src/org/traccar/protocol/CguardProtocolDecoder.java
+++ b/src/org/traccar/protocol/CguardProtocolDecoder.java
@@ -104,7 +104,7 @@ public class CguardProtocolDecoder extends BaseProtocolDecoder {
String value = data[i * 2 + 1];
switch (key) {
case "CSQ1":
- position.set(Position.KEY_GSM, Integer.parseInt(value));
+ position.set(Position.KEY_RSSI, Integer.parseInt(value));
break;
case "NSQ1":
position.set(Position.KEY_SATELLITES, Integer.parseInt(value));
diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
index 9f2a0250d..2351232f9 100644
--- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -117,10 +119,8 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
}
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt());
- position.set(Position.KEY_CID, parser.nextInt());
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt())));
return position;
}
diff --git a/src/org/traccar/protocol/CradlepointProtocolDecoder.java b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
index f46459482..b9e1a3e86 100644
--- a/src/org/traccar/protocol/CradlepointProtocolDecoder.java
+++ b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
@@ -81,7 +81,7 @@ public class CradlepointProtocolDecoder extends BaseProtocolDecoder {
parser.skip(4);
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
return position;
}
diff --git a/src/org/traccar/protocol/DishaProtocolDecoder.java b/src/org/traccar/protocol/DishaProtocolDecoder.java
index dc8bddd38..6b4f91833 100644
--- a/src/org/traccar/protocol/DishaProtocolDecoder.java
+++ b/src/org/traccar/protocol/DishaProtocolDecoder.java
@@ -90,7 +90,7 @@ public class DishaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.next());
position.set(Position.KEY_HDOP, parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
position.set(Position.KEY_CHARGE, parser.nextInt() == 2);
position.set(Position.KEY_BATTERY, parser.next());
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index 0bf7d229b..b1634042d 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -108,10 +110,8 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
position.setCourse(buf.readUnsignedShort());
- position.set(Position.KEY_MCC, buf.readUnsignedShort());
- position.set(Position.KEY_MNC, buf.readUnsignedShort());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedMedium());
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedShort(), buf.readUnsignedShort(), buf.readUnsignedMedium())));
position.setValid((buf.readUnsignedByte() & 0x01) != 0);
@@ -148,11 +148,9 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
}
if (BitUtil.check(flags, 1)) {
- position.set(Position.KEY_MCC, buf.readUnsignedShort());
- position.set(Position.KEY_MNC, buf.readUnsignedShort());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedInt());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedShort(),
+ buf.readUnsignedShort(), buf.readUnsignedInt(), buf.readUnsignedByte())));
}
if (BitUtil.check(flags, 2)) {
diff --git a/src/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/org/traccar/protocol/FifotrackProtocolDecoder.java
index 9243d1894..9ccc34384 100644
--- a/src/org/traccar/protocol/FifotrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FifotrackProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -104,10 +106,8 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_OUTPUT, parser.nextInt(16));
}
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
String[] adc = parser.next().split("\\|");
for (int i = 0; i < adc.length; i++) {
diff --git a/src/org/traccar/protocol/FlextrackProtocolDecoder.java b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
index db85acd5d..39da99fda 100644
--- a/src/org/traccar/protocol/FlextrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -121,16 +123,18 @@ public class FlextrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextInt());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_STATUS, parser.nextInt(16));
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
+
+ int mcc = parser.nextInt();
+ int mnc = parser.nextInt();
position.setAltitude(parser.nextInt());
position.set(Position.KEY_HDOP, parser.nextInt() * 0.1);
- position.set(Position.KEY_CID, parser.nextInt(16));
- position.set(Position.KEY_LAC, parser.nextInt(16));
+
+ position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextInt(16), parser.nextInt(16))));
+
position.set(Position.KEY_ODOMETER, parser.nextInt());
return position;
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 66a4e2f7e..769964f33 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -324,7 +326,9 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextDouble());
position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
- parser.next(); // battery percentage
+ if (parser.hasNext()) {
+ position.set(Position.KEY_BATTERY, parser.next() + "%");
+ }
position.set(Position.PREFIX_TEMP + 1, parser.next());
@@ -392,10 +396,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext(4)) {
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
}
parser.skip(4); // alternative networks
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index a7f1024c6..40a0d4d73 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -23,6 +23,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -155,10 +157,8 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, parser.next());
if (parser.hasNext(4)) {
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
}
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER, parser.nextInt());
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index d929ae917..0320f785f 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -21,6 +21,8 @@ import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -171,8 +173,8 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
return position;
diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
index 8a42293b9..a520bff13 100644
--- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
@@ -70,7 +70,7 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_POWER, power);
- position.set(Position.KEY_GSM, gsm);
+ position.set(Position.KEY_RSSI, gsm);
if (channel != null) {
byte[] response = {0x54, 0x68, 0x1A, 0x0D, 0x0A};
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 35cb83dac..356097fb2 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -25,6 +25,8 @@ import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -142,10 +144,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
lbsLength = buf.readUnsignedByte();
}
- position.set(Position.KEY_MCC, buf.readUnsignedShort());
- position.set(Position.KEY_MNC, buf.readUnsignedByte());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedMedium());
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedShort(), buf.readUnsignedMedium())));
if (lbsLength > 0) {
buf.skipBytes(lbsLength - 9);
@@ -159,7 +159,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, BitUtil.check(flags, 1));
position.set(Position.KEY_STATUS, flags);
position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
}
@@ -222,8 +222,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
}
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
- if (deviceSession != null) {
+ if (getDeviceSession(channel, remoteAddress, imei) != null) {
buf.skipBytes(buf.readableBytes() - 6);
sendResponse(channel, type, buf.readUnsignedShort());
}
@@ -235,11 +234,29 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- if (type == MSG_STRING) {
+ Position position = new Position();
+ position.setDeviceId(deviceSession.getDeviceId());
+ position.setProtocol(getProtocolName());
+
+ if (type == MSG_LBS_EXTEND) {
+
+ DateBuilder dateBuilder = new DateBuilder(timeZone)
+ .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
+ .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
+
+ getLastLocation(position, dateBuilder.getDate());
- Position position = new Position();
- position.setDeviceId(deviceSession.getDeviceId());
- position.setProtocol(getProtocolName());
+ int mcc = buf.readUnsignedShort();
+ int mnc = buf.readUnsignedByte();
+
+ Network network = new Network();
+ for (int i = 0; i < 7; i++) {
+ network.addCellTower(CellTower.from(
+ mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedMedium(), -buf.readUnsignedByte()));
+ }
+ position.setNetwork(network);
+
+ } else if (type == MSG_STRING) {
getLastLocation(position, null);
@@ -250,18 +267,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.set("command", buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII));
}
- buf.readUnsignedShort(); // language
-
- sendResponse(channel, type, buf.readUnsignedShort());
-
- return position;
-
} else if (isSupported(type)) {
- Position position = new Position();
- position.setDeviceId(deviceSession.getDeviceId());
- position.setProtocol(getProtocolName());
-
if (hasGps(type)) {
decodeGps(position, buf);
} else {
@@ -280,23 +287,22 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
}
- if (buf.readableBytes() > 6) {
- buf.skipBytes(buf.readableBytes() - 6);
- }
- int index = buf.readUnsignedShort();
- position.set(Position.KEY_INDEX, index);
- sendResponse(channel, type, index);
-
- return position;
-
} else {
buf.skipBytes(dataLength);
if (type != MSG_COMMAND_0 && type != MSG_COMMAND_1 && type != MSG_COMMAND_2) {
sendResponse(channel, type, buf.readUnsignedShort());
}
+ return null;
+
+ }
+ if (buf.readableBytes() > 6) {
+ buf.skipBytes(buf.readableBytes() - 6);
}
+ sendResponse(channel, type, buf.readUnsignedShort());
+
+ return position;
}
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 2c7852d16..431dd5c3c 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -25,6 +25,8 @@ import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -249,10 +251,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
int lac = parser.nextInt(16);
int cid = parser.nextInt(16);
if (mcc != 0 && mnc != 0 && lac != 0 && cid != 0) {
- position.set(Position.KEY_MCC, mcc);
- position.set(Position.KEY_MNC, mnc);
- position.set(Position.KEY_LAC, lac);
- position.set(Position.KEY_CID, cid);
+ position.setNetwork(new Network(CellTower.from(mcc, mnc, lac, cid)));
}
}
@@ -278,13 +277,17 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
+ Network network = new Network();
+ int mcc = parser.nextInt();
+ int mnc = parser.nextInt();
- String[] cells = parser.next().split(","); // decode all in future
- position.set(Position.KEY_LAC, Integer.parseInt(cells[0]));
- position.set(Position.KEY_CID, Integer.parseInt(cells[1]));
- position.set(Position.KEY_GSM, Integer.parseInt(cells[2]));
+ String[] cells = parser.next().split(",");
+ for (int i = 0; i < cells.length / 3; i++) {
+ network.addCellTower(CellTower.from(mcc, mnc, Integer.parseInt(cells[i * 3]),
+ Integer.parseInt(cells[i * 3 + 1]), Integer.parseInt(cells[i * 3 + 2])));
+ }
+
+ position.setNetwork(network);
dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java
index 8fbf98d3c..7cd0b37f2 100644
--- a/src/org/traccar/protocol/HaicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java
@@ -101,7 +101,7 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble() / 10);
position.set(Position.KEY_STATUS, parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
position.set(Position.KEY_GPS, parser.next());
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_OUTPUT, parser.next());
diff --git a/src/org/traccar/protocol/IdplProtocolDecoder.java b/src/org/traccar/protocol/IdplProtocolDecoder.java
index cfef75952..09a3db9bd 100644
--- a/src/org/traccar/protocol/IdplProtocolDecoder.java
+++ b/src/org/traccar/protocol/IdplProtocolDecoder.java
@@ -93,7 +93,7 @@ public class IdplProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
parser.next(); // vehicle status
position.set(Position.KEY_POWER, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextDouble());
diff --git a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
index debc66673..60aadd025 100644
--- a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
+++ b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -82,10 +84,8 @@ public class JpKorjarProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.nextInt() == 1);
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
return position;
}
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index ad7a00dc2..0d8b4abbc 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -25,6 +25,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -108,9 +110,10 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, battery + "%");
}
- position.set(Position.KEY_CID, buf.readUnsignedShort());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.setNetwork(new Network(
+ CellTower.fromCidLac(buf.readUnsignedShort(), buf.readUnsignedShort())));
+
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
position.set(Position.KEY_INDEX, buf.readUnsignedByte());
} else if (version == 1) {
@@ -125,11 +128,10 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
int cid = buf.readUnsignedShort();
int lac = buf.readUnsignedShort();
if (cid != 0 && lac != 0) {
- position.set(Position.KEY_CID, cid);
- position.set(Position.KEY_LAC, lac);
+ position.setNetwork(new Network(CellTower.fromCidLac(cid, lac)));
}
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
} else if (version == 2) {
@@ -256,9 +258,10 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.next());
position.set(Position.KEY_STATUS, parser.nextInt(2));
- position.set(Position.KEY_CID, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt());
- position.set(Position.KEY_GSM, parser.nextInt());
+
+ position.setNetwork(new Network(CellTower.fromCidLac(parser.nextInt(), parser.nextInt())));
+
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_ODOMETER, parser.nextLong() * 1000);
position.set(Position.KEY_INDEX, parser.nextInt());
diff --git a/src/org/traccar/protocol/L100ProtocolDecoder.java b/src/org/traccar/protocol/L100ProtocolDecoder.java
index 7eed7df9a..bdf4ba29b 100644
--- a/src/org/traccar/protocol/L100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/L100ProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -106,11 +108,10 @@ public class L100ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.nextDouble());
position.set(Position.PREFIX_TEMP + 1, parser.nextDouble());
position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_GSM, parser.nextInt());
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt());
- position.set(Position.KEY_CID, parser.nextInt());
+
+ int rssi = parser.nextInt();
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt(), rssi)));
return position;
}
diff --git a/src/org/traccar/protocol/MaestroProtocolDecoder.java b/src/org/traccar/protocol/MaestroProtocolDecoder.java
index 06ec2473d..f0b328cf9 100644
--- a/src/org/traccar/protocol/MaestroProtocolDecoder.java
+++ b/src/org/traccar/protocol/MaestroProtocolDecoder.java
@@ -78,7 +78,7 @@ public class MaestroProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.nextInt() == 1);
position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 005d38c41..60660adf6 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -21,6 +21,8 @@ import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -176,10 +178,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext(4)) {
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
}
} else {
@@ -203,11 +203,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
- position.set(Position.KEY_GSM, parser.next());
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16), parser.nextInt())));
position.set(Position.KEY_BATTERY, Double.parseDouble(parser.next()));
@@ -310,11 +307,9 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
}
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16), parser.nextInt())));
+
position.set(Position.KEY_INPUT, parser.nextInt(2));
position.set(Position.KEY_OUTPUT, parser.nextInt(2));
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 74b7c0e52..6408154e3 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -245,7 +245,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext()) {
- position.set(Position.KEY_GSM, parser.nextInt(16));
+ position.set(Position.KEY_RSSI, parser.nextInt(16));
}
if (parser.hasNext()) {
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 72ccaa037..7b4e38fe6 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -113,7 +115,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
@@ -124,10 +126,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.next());
position.set("runtime", parser.next());
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+
+ position.setNetwork(new Network(
+ CellTower.from(parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
+
position.set(Position.KEY_STATUS, parser.next());
for (int i = 1; i <= 3; i++) {
@@ -198,7 +200,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.setValid(buf.readUnsignedByte() == 1);
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
position.setCourse(buf.readUnsignedShort());
@@ -209,10 +211,11 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
position.set("runtime", buf.readUnsignedInt());
- position.set(Position.KEY_MCC, buf.readUnsignedShort());
- position.set(Position.KEY_MNC, buf.readUnsignedShort());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
+
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedShort(),
+ buf.readUnsignedShort(), buf.readUnsignedShort())));
+
position.set(Position.KEY_STATUS, buf.readUnsignedShort());
position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index da03dc8bf..360df726a 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -122,7 +122,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT);
}
- position.set(Position.KEY_GSM, BitUtil.between(flags, 16, 20));
+ position.set(Position.KEY_RSSI, BitUtil.between(flags, 16, 20));
position.set(Position.KEY_CHARGE, BitUtil.check(flags, 22));
position.setAltitude(parser.nextDouble());
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 2109a63c3..2a3d84a2c 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -184,7 +184,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_POWER, buf.readUnsignedShort() & 0x03ff);
buf.readByte(); // microcontroller temperature
- position.set(Position.KEY_GSM, (buf.getUnsignedByte(buf.readerIndex()) >> 4) & 0x07);
+ position.set(Position.KEY_RSSI, (buf.getUnsignedByte(buf.readerIndex()) >> 4) & 0x07);
int satellites = buf.readUnsignedByte() & 0x0f;
position.setValid(satellites >= 3);
@@ -263,7 +263,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_POWER, buf.readUnsignedShort() & 0x03ff);
buf.readByte(); // microcontroller temperature
- position.set(Position.KEY_GSM, buf.getUnsignedByte(buf.readerIndex()) >> 5);
+ position.set(Position.KEY_RSSI, buf.getUnsignedByte(buf.readerIndex()) >> 5);
int satellites = buf.readUnsignedByte() & 0x1f;
position.setValid(satellites >= 3);
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index 0e01f807f..c03305c1a 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -107,7 +107,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.set(Position.KEY_HDOP, buf.readUnsignedByte());
buf.readUnsignedByte(); // GPS accuracy
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
buf.readUnsignedShort(); // time since boot
buf.readUnsignedByte(); // input voltage
position.set(Position.PREFIX_TEMP + 1, buf.readByte());
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index e06ef1b57..8d4e367ab 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -102,7 +102,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
}
position.set(Position.KEY_STATUS, buf.readUnsignedByte());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
if (isFormat(format, F10, F20, F30)) {
position.set(Position.KEY_OUTPUT, buf.readUnsignedShort());
diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java
index 9e6a9a82e..d10f754e9 100644
--- a/src/org/traccar/protocol/OigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OigoProtocolDecoder.java
@@ -117,7 +117,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
}
if (BitUtil.check(mask, 8)) {
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
}
if (BitUtil.check(mask, 9)) {
@@ -204,7 +204,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
dateBuilder.setSecond(buf.readUnsignedByte());
position.setTime(dateBuilder.getDate());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
int index = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index 9e24efc38..1820ea926 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -127,7 +127,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
long extraFlags = buf.readLong();
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index f3d9e8380..54f54d392 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -136,7 +136,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext()) {
int value = parser.nextInt(16);
position.set(Position.KEY_BATTERY, value >> 8);
- position.set(Position.KEY_GSM, (value >> 4) & 0xf);
+ position.set(Position.KEY_RSSI, (value >> 4) & 0xf);
position.set(Position.KEY_SATELLITES, value & 0xf);
}
diff --git a/src/org/traccar/protocol/RaveonProtocolDecoder.java b/src/org/traccar/protocol/RaveonProtocolDecoder.java
index 19a9d6314..847bc4fb6 100644
--- a/src/org/traccar/protocol/RaveonProtocolDecoder.java
+++ b/src/org/traccar/protocol/RaveonProtocolDecoder.java
@@ -90,7 +90,7 @@ public class RaveonProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
position.set(Position.KEY_POWER, parser.nextDouble());
position.set(Position.KEY_INPUT, parser.nextInt());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
position.setCourse(parser.nextInt());
diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java
index 52d711a8d..6430b1344 100644
--- a/src/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/org/traccar/protocol/T800xProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -169,10 +171,9 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
buf.readBytes(array);
ChannelBuffer swapped = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, array);
- position.set(Position.KEY_MCC, swapped.readUnsignedShort());
- position.set(Position.KEY_MNC, swapped.readUnsignedShort());
- position.set(Position.KEY_LAC, swapped.readUnsignedShort());
- position.set(Position.KEY_CID, swapped.readUnsignedShort());
+ position.setNetwork(new Network(CellTower.from(
+ swapped.readUnsignedShort(), swapped.readUnsignedShort(),
+ swapped.readUnsignedShort(), swapped.readUnsignedShort())));
// two more cell towers
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 474718ee8..074d89703 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -133,12 +135,12 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
if (BitUtil.check(locationMask, 5)) {
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
}
if (BitUtil.check(locationMask, 6)) {
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ buf.readUnsignedByte(); // rssi
}
if (BitUtil.check(locationMask, 7)) {
diff --git a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java
index f78f01329..4a97fa1a1 100644
--- a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java
+++ b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java
@@ -21,6 +21,8 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -100,8 +102,8 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(buf.readUnsignedByte());
position.setCourse(buf.readUnsignedByte());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
return position;
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index d3bc0efdc..9dc94678e 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -165,10 +167,8 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
return position;
}
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 1fe91b942..7140190da 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -249,8 +251,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
int lac = parser.nextInt(16);
int cid = parser.nextInt(16);
if (lac != 0 && cid != 0) {
- position.set(Position.KEY_LAC, lac);
- position.set(Position.KEY_CID, cid);
+ position.setNetwork(new Network(CellTower.fromLacCid(lac, cid)));
}
position.set(Position.PREFIX_TEMP + 1, parser.next());
@@ -272,8 +273,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 2, parser.next());
position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set(Position.PREFIX_TEMP + 2, parser.next());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
@@ -307,10 +309,11 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set(Position.PREFIX_TEMP + 2, parser.next());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
+
position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.setCourse(parser.nextDouble());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
diff --git a/src/org/traccar/protocol/Tr900ProtocolDecoder.java b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
index 32362acd2..1f867d5d1 100644
--- a/src/org/traccar/protocol/Tr900ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
@@ -85,7 +85,7 @@ public class Tr900ProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(parser.nextDouble());
position.setCourse(parser.nextDouble());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
position.set(Position.KEY_EVENT, parser.nextInt());
position.set(Position.PREFIX_ADC + 1, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextInt());
diff --git a/src/org/traccar/protocol/TrvProtocolDecoder.java b/src/org/traccar/protocol/TrvProtocolDecoder.java
index 0afe065c2..3d8b6c66b 100644
--- a/src/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrvProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -104,7 +106,7 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextInt());
position.set(Position.KEY_IGNITION, parser.nextInt() != 0);
@@ -138,7 +140,7 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextInt());
@@ -147,10 +149,8 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, acc == 1);
}
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt());
- position.set(Position.KEY_CID, parser.nextInt());
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt())));
return position;
}
diff --git a/src/org/traccar/protocol/Tt8850ProtocolDecoder.java b/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
index b128068be..040783ba2 100644
--- a/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -90,10 +92,8 @@ public class Tt8850ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateBuilder.getDate());
if (parser.hasNext(4)) {
- position.set(Position.KEY_MCC, parser.nextInt());
- position.set(Position.KEY_MNC, parser.nextInt());
- position.set(Position.KEY_LAC, parser.nextInt(16));
- position.set(Position.KEY_CID, parser.nextInt(16));
+ position.setNetwork(new Network(
+ CellTower.from(parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
}
return position;
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index b67902e56..429479de0 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -171,7 +171,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
// Status
flags = buf.readUnsignedByte();
position.set(Position.KEY_IGNITION, BitUtil.check(flags, 0));
- position.set(Position.KEY_GSM, BitUtil.between(flags, 2, 5));
+ position.set(Position.KEY_RSSI, BitUtil.between(flags, 2, 5));
position.setCourse((BitUtil.from(flags, 5) * 45 + 180) % 360);
// Speed
diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java
index 8fd695b80..a0ed41caf 100644
--- a/src/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -22,6 +22,8 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -118,10 +120,8 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
blockEnd = buf.readerIndex() + blockLength;
if (blockLength > 0) {
-
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
- position.set(Position.KEY_CID, buf.readUnsignedShort());
-
+ position.setNetwork(new Network(
+ CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
}
buf.readerIndex(blockEnd);
@@ -136,7 +136,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
buf.readUnsignedByte(); // terminal info
position.set(Position.PREFIX_IO + 1, buf.readUnsignedShort());
- position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
buf.readUnsignedByte(); // GSM status
position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
position.set(Position.KEY_POWER, buf.readUnsignedShort());
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index d2a58f1b8..c4ddca219 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.ObdDecoder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -182,15 +184,15 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
break;
case DATA_LBS:
- position.set(Position.KEY_MCC, buf.readUnsignedShort());
- position.set(Position.KEY_MNC, buf.readUnsignedShort());
- position.set(Position.KEY_LAC, buf.readUnsignedShort());
if (length == 11) {
- position.set(Position.KEY_CID, buf.readUnsignedInt());
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedShort(),
+ buf.readUnsignedShort(), buf.readUnsignedInt(), -buf.readUnsignedByte())));
} else {
- position.set(Position.KEY_CID, buf.readUnsignedShort());
+ position.setNetwork(new Network(CellTower.from(
+ buf.readUnsignedShort(), buf.readUnsignedShort(),
+ buf.readUnsignedShort(), buf.readUnsignedShort(), -buf.readUnsignedByte())));
}
- position.set(Position.KEY_GSM, -buf.readUnsignedByte());
if (length > 9 && length != 11) {
buf.skipBytes(length - 9);
}
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java
index e47dd8595..37536d1dd 100644
--- a/src/org/traccar/protocol/UproProtocolDecoder.java
+++ b/src/org/traccar/protocol/UproProtocolDecoder.java
@@ -24,6 +24,8 @@ import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -154,14 +156,11 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, odometer * 2 * 1852 / 3600);
break;
case 'P':
- position.set(Position.KEY_MCC,
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII)));
- position.set(Position.KEY_MNC,
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII)));
- position.set(Position.KEY_LAC,
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII), 16));
- position.set(Position.KEY_CID,
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII), 16));
+ position.setNetwork(new Network(CellTower.from(
+ Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII)),
+ Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII)),
+ Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII), 16),
+ Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII), 16))));
break;
case 'Q':
position.set("obd-pid", ChannelBuffers.hexDump(data));
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index ca9c451c2..58ece0e75 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -89,7 +89,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
position.set("password", parser.next());
position.set(Position.KEY_EVENT, parser.next());
position.set("packet", parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
double lon = parser.nextDouble();
boolean west = parser.next().equals("W");
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 5ce12bd19..0eac50817 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -119,7 +119,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_IO + 2, parser.next());
position.set("immobilizer", parser.next());
position.set(Position.KEY_POWER, parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
}
if (parser.hasNext(7)) {
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index 13eb73254..07df2de13 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -136,7 +136,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(parser.nextDouble());
position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_GSM, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextInt());
position.set("steps", parser.nextInt());
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java
index f20f4ef35..633479350 100644
--- a/src/org/traccar/protocol/XirgoProtocolDecoder.java
+++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java
@@ -140,7 +140,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
if (!newFormat) {
position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1609.34);
diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
index 68497980b..40231a06d 100644
--- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
@@ -88,7 +88,7 @@ public class Xt013ProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("F"));
position.set(Position.KEY_GPS, parser.next());
- position.set(Position.KEY_GSM, parser.next());
+ position.set(Position.KEY_RSSI, parser.next());
position.set(Position.KEY_BATTERY, parser.next());
position.set(Position.KEY_CHARGE, parser.next());