diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-17 16:59:36 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-17 16:59:36 +1200 |
commit | 57941c8095839951caf868368963ba13e8fc3da3 (patch) | |
tree | 8e3e4290a47d0ad61c2cab291a74bba7e0e00057 | |
parent | d643e9a75f1c6580d098b68cffc2c709db611d8e (diff) | |
download | traccar-server-57941c8095839951caf868368963ba13e8fc3da3.tar.gz traccar-server-57941c8095839951caf868368963ba13e8fc3da3.tar.bz2 traccar-server-57941c8095839951caf868368963ba13e8fc3da3.zip |
Decode numeric OsmAnd parameters
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 6 | ||||
-rwxr-xr-x | tools/test-generator.py | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 382865e8f..579dbe3e6 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -129,7 +129,11 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, value); break; default: - position.set(entry.getKey(), value); + try { + position.set(entry.getKey(), Double.parseDouble(value)); + } catch (NumberFormatException e) { + position.set(entry.getKey(), value); + } break; } } diff --git a/tools/test-generator.py b/tools/test-generator.py index 7f8916f4d..9e9cf892e 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -5,6 +5,7 @@ import math import urllib import httplib import time +import random id = '123456789012345' server = 'localhost:5055' @@ -33,7 +34,7 @@ for i in range(0, len(waypoints)): lon = lon1 + (lon2 - lon1) * j / count points.append((lat, lon)) -def send(conn, lat, lon, course, speed, alarm, ignition, accuracy): +def send(conn, lat, lon, course, speed, alarm, ignition, accuracy, rpm, fuel): params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed)) if alarm: params = params + (('alarm', 'sos'),) @@ -41,6 +42,10 @@ def send(conn, lat, lon, course, speed, alarm, ignition, accuracy): params = params + (('ignition', 'true'),) if accuracy: params = params + (('accuracy', accuracy),) + if rpm: + params = params + (('rpm', rpm),) + if fuel: + params = params + (('fuel', fuel),) conn.request('GET', '?' + urllib.urlencode(params)) conn.getresponse().read() @@ -64,6 +69,8 @@ while True: alarm = (index % 10) == 0 ignition = (index % len(points)) != 0 accuracy = 100 if (index % 10) == 0 else 0 - send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy) + rpm = random.randint(500, 4000) + fuel = random.randint(0, 80) + send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy, rpm, fuel) time.sleep(period) index += 1 |