diff options
author | krakenrf <78108016+krakenrf@users.noreply.github.com> | 2022-10-18 12:16:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 12:16:48 +0200 |
commit | 32dd4f406019e7cb405fc7c44bab40d90bc7ba05 (patch) | |
tree | ea2c92378f885031e4bb6de1c959e071df543654 /misc_scripts | |
parent | Update sondehub_krakenmap.py (diff) | |
download | krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.tar krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.tar.gz krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.tar.bz2 krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.tar.lz krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.tar.xz krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.tar.zst krakensdr_docs-32dd4f406019e7cb405fc7c44bab40d90bc7ba05.zip |
Diffstat (limited to 'misc_scripts')
-rw-r--r-- | misc_scripts/gpsd_tracker_krakenmap.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/misc_scripts/gpsd_tracker_krakenmap.py b/misc_scripts/gpsd_tracker_krakenmap.py new file mode 100644 index 0000000..5a3e5b4 --- /dev/null +++ b/misc_scripts/gpsd_tracker_krakenmap.py @@ -0,0 +1,35 @@ +# Uses an attached USB GPS and GPSd to get location data, and then upload it as a marker to the Kraken Cloud Mapper. + +import gpsd +import time +import requests + +gpsd.connect() +time.sleep(2) + +API_SERVER = 'https://map.krakenrf.com:443' +login = {'username': 'username', 'password': 'password'} + +while(1): + try: + x = requests.post(API_SERVER + '/login', json = login) + break + except: + time.sleep(1) + pass + +token = x.text + +while(1): + try: + packet = gpsd.get_current() + lat, lon = packet.position() + print("lat: " + str(lat)) + print("lon: " + str(lon)) + + beaconData = {'lat': lat, 'lon': lon, 'speed': 0, 'height': 0} + x = requests.post(API_SERVER + '/beacon', json = beaconData, headers = {'Authorization': token}) + + except (gpsd.NoFixError, UserWarning): + print("waiting for fix") + time.sleep(1) |