tobadia / petGPS

A DIY, python-based framework to set up a server and exchange TCP packets with a chinese GPS+SIM (2G) device whose communication protocol is derived from something called GT06
MIT License
96 stars 34 forks source link

Old position reported #12

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello,

I'm just starting using this python script and facing a strange issue for me, which maybe is normal I don't know.

Before switching to the script, GPS365 report a wifi position on 04 August which is good :

Capture d’écran   2021-08-04 à 18 02 59

then switched to my computer, and it report a position from 27 July which was a good position this day but outdated :

pi@ragnar:~ $ tail logs/location_log.txt -f 2021/08/04 17:41:00 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.4064013 +2.7940479 116.1 2021/08/04 17:43:01 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:45:01 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:47:07 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:49:02 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:51:03 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:53:04 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:55:04 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:57:14 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 17:58:35 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 18:00:36 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 18:02:36 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175 2021/08/04 18:04:42 10.0.0.2 359339075435809 LBS-GSM-WIFI 2021/07/28 21:34:51 1 +48.407402100000006 +2.7956312 1175

here is an example of received frames :

[ 10.0.0.2 ] IN Hex : 78780713374c0819390d0a (length in bytes = 11 ) The current packet is for protocol: status which has method: [ 10.0.0.2 ] STATUS : Battery = 55 ; Sw v. = 76 ; Status upload interval = 8 ; Signal strength = 25 [ 10.0.0.2 ] IN Hex : 78780517210728193451caeac75f117c4fcaeac75f117e4fcaeac75f117d5118d6c7902df45b1ad6c7902df45c0200d01455fc1d985a55fc1d9664000d0a (length in bytes = 62 ) The current packet is for protocol: wifi_offline_positioning which has method: datetime_position_response [ 10.0.0.2 ] POSITION/WIFI : BSSID = ca:ea:c7:5f:11:7c ; RSSI = -79 [ 10.0.0.2 ] POSITION/WIFI : BSSID = ca:ea:c7:5f:11:7e ; RSSI = -79 [ 10.0.0.2 ] POSITION/WIFI : BSSID = ca:ea:c7:5f:11:7d ; RSSI = -81 [ 10.0.0.2 ] POSITION/WIFI : BSSID = 18:d6:c7:90:2d:f4 ; RSSI = -91 [ 10.0.0.2 ] POSITION/WIFI : BSSID = 1a:d6:c7:90:2d:f4 ; RSSI = -92 [ 10.0.0.2 ] POSITION/LBS : LAC = 22012 ; CellID = 7576 ; MCISS = -90 [ 10.0.0.2 ] POSITION/LBS : LAC = 22012 ; CellID = 7574 ; MCISS = -100 [ 10.0.0.2 ] OUT Hex : 787807172107282134510D0A (length in bytes = 12 ) Decoding location-based data using Google Maps Geolocation API... Google Maps Geolocation API queried with: {'wifi': [{'macAddress': 'ca:ea:c7:5f:11:7c', 'signalStrength': -79}, {'macAddress': 'ca:ea:c7:5f:11:7e', 'signalStrength': -79}, {'macAddress': 'ca:ea:c7:5f:11:7d', 'signalStrength': -81}, {'macAddress': '18:d6:c7:90:2d:f4', 'signalStrength': -91}, {'macAddress': '1a:d6:c7:90:2d:f4', 'signalStrength': -92}], 'gsm-cells': [{'locationAreaCode': 22012, 'cellId': 7576, 'signalStrength': -90}, {'locationAreaCode': 22012, 'cellId': 7574, 'signalStrength': -100}], 'gsm-carrier': {'n_gsm_cells': 2, 'MCC': 208, 'MNC': 20}, 'gps': {}} Google Maps Geolocation API returned: {'location': {'lat': 48.407402100000006, 'lng': 2.7956312}, 'accuracy': 1175} [ 10.0.0.2 ] OUT Hex : 787815172b34382e3430373430322C2b322e3739353633310D0A (length in bytes = 26 )

so I don't know why this is an old one ? note there is no gps location for now.

board is ZX303, pet is a Beagle Dog but we don't care :)

thanks.

tobadia commented 3 years ago

Hey, I haven't had the chance to get back to this code in a (long) time dur to "other random stuffs" in life. If memory serves right, there's a discussion between server and device where the server has to answer the correct packet to acknowledge a LBS packet. Somethign along the lines of : 1- Device sends LBS packet 2- Server responds with proper content/timestamp/whatever 3- Device understands that packet was properly received and stops sending it

From my tests, an identical LBS packet that kept being sent was because the device didn't understand that it was received (think of it as an "offline" mode, i.e. position is stored before being 'approved' by server). It could be that the answer my server is giving is not the correct one. I remember fixing (trying to fix?) that long ago. That was in commit ef03a6a518cacfa21f89b6ffafb7d82b94a0fce5.

Judging by your example, there could be something off between the timestamp received/sent causing that mismatch :

ghost commented 3 years ago

thanks for your fast reply. You are right I was using an old python script from 2019 , I did the update and now all is working fine.

By the way is there any simple way to exploit location_log.txt file, for example display all the positions on a map ?

EDIT : found it, I used Google Mymaps, all I had to do is to change Tab delimiter with "," , add a header line, works great.

Sans titre

tobadia commented 3 years ago

No worries. I have a RShiny UI that I designed and didn't feel was decent enough to put it on github, but honestly this has been sitting around for too long. I'll add it to the repo or to another one tonight if I can find some time to clean things up slightly.

My initial plan was to make the server + rendering a whole Python thing (with Flask?) but my Python skills are really low and this would take ages.

Le jeu. 5 août 2021 à 17:54, theccm @.***> a écrit :

thanks for your fast reply. You are right I was using an old python script from 2019 , I did the update and now all is working fine.

By the way is there any simple way to exploit location_log.txt file, for example display all the positions on a map ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tobadia/petGPS/issues/12#issuecomment-893570183, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADECJWSJI4KBFRJNCEPCWBLT3KXZZANCNFSM5BRPLS6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .