From 96f2ddba048b064381cf9375514f7b9d84186218 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 13 Jan 2017 03:51:37 +1300 Subject: Add accuracy to OsmAnd protocol --- tools/test-generator.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/tools/test-generator.py b/tools/test-generator.py index a23e2576e..1a50c5c61 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -33,13 +33,14 @@ for i in range(0, len(waypoints)): lon = lon1 + (lon2 - lon1) * j / count points.append((lat, lon)) -def send(conn, lat, lon, course, alarm, ignition, speed): - params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course)) +def send(conn, lat, lon, course, speed, alarm, ignition, accuracy): + params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed)) if alarm: params = params + (('alarm', 'sos'),) if ignition: params = params + (('ignition', 'true'),) - params = params + (('speed', speed),) + if ignition: + params = params + (('accuracy', accuracy),) conn.request('GET', '?' + urllib.urlencode(params)) conn.getresponse().read() @@ -59,12 +60,10 @@ conn = httplib.HTTPConnection(server) while True: (lat1, lon1) = points[index % len(points)] (lat2, lon2) = points[(index + 1) % len(points)] - alarm = ((index % 10) == 0) - ignition = ((index % len(points)) != 0) - if (index % len(points)) != 0: - speed = device_speed - else: - speed = 0 - send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm, ignition, speed) + speed = device_speed if (index % len(points)) != 0 else 0 + 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) time.sleep(period) index += 1 -- cgit v1.2.3