Latest Position bug

webfrank9 years ago

I found a bug on latest position handling. My GPS, a GT-06 protocol, sends data, when connection is available, in reverse time order:

2015-09-15 10:36:40 DEBUG: [049771F5: 5023 < 172.16.199.2] HEX: 78781f120f090f10232ac30406801b019edf5e05351e00de0a9c4a006b10003a4cb70d0a78781f120f090f10240dc504067edd019ecfc905353200de0a9c4a006b10003bacd00d0a
2015-09-15 10:36:40 DEBUG: [049771F5: 5023 > 172.16.199.2] HEX: 78780512003a3c7d0d0a
2015-09-15 10:36:40  INFO: [049771F5] id: 1, time: Tue Sep 15 10:35:42 CEST 2015, lat: 37.519375, lon: 15.105047777777777, speed: 2.6997850000000003, course: 286.0
2015-09-15 10:36:40 DEBUG: [049771F5: 5023 > 172.16.199.2] HEX: 78780512003b2df40d0a
2015-09-15 10:36:40  INFO: [049771F5] id: 1, time: Tue Sep 15 10:36:13 CEST 2015, lat: 37.519198333333335, lon: 15.102831666666667, speed: 2.6997850000000003, course: 306.0
2015-09-15 10:36:43  INFO: [5C0AFEDA] disconnected
2015-09-15 10:36:51  INFO: [E2036D13] disconnected
2015-09-15 10:37:07  INFO: [181689CE] disconnected
2015-09-15 10:37:15  INFO: [93D86A2F] disconnected
2015-09-15 10:38:02  INFO: [04B7E59A] connected
2015-09-15 10:38:12  INFO: [1BF253A4] connected
2015-09-15 10:38:24  INFO: [B8B697C5] connected
2015-09-15 10:38:35  INFO: [8AE30D60] connected
2015-09-15 10:38:40  INFO: [049771F5] disconnected
2015-09-15 10:38:46  INFO: [4E843199] connected
2015-09-15 10:38:52 DEBUG: [4E843199: 5023 < 172.16.199.2] HEX: 78780d010387113120859834003e6ac00d0a78781f120f090f10192dc70405c3c0019e74a656340a00de0a9c85006646002193d10d0a
2015-09-15 10:38:52 DEBUG: [4E843199: 5023 > 172.16.199.2] HEX: 78780501003e10a80d0a
2015-09-15 10:38:52 DEBUG: [4E843199: 5023 > 172.16.199.2] HEX: 787805120021922f0d0a
2015-09-15 10:38:52  INFO: [4E843199] id: 1, time: Tue Sep 15 10:25:45 CEST 2015, lat: 37.49258666666667, lon: 15.08987, speed: 46.436302000000005, course: 10.0

Updating latest position as latest inserted id I do not have the real latest position received.

I think it should be re-thinked the logic of writing positionId on device record and retrieve latest position from position table using deviceId and reverse sorting by fixTime and getting first row, that is the real latest position.

Anton Tananaev9 years ago

Changed the logic. In the next release GPS fix time will be taken into account when updating device latest position reference.