summaryrefslogtreecommitdiffstats
path: root/misc_scripts/dump1090_krakenmap.py
blob: e34962dbe3809ac1fc146559f84940ef53c02df8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
import time

# The unique ICAO ID of the aircraft in HEX. Ensure it is LOWERCASE.
HEX_ID = "c822ed"

API_SERVER = 'https://map.krakenrf.com:443'

# Your Kraken Pro Cloud username and password
login = {'username': 'username', 'password': 'password'}

x = requests.post(API_SERVER + '/login', json = login)
token = x.text

print(x.text)

while True:
    f = open('aircraft.json')
    data = json.load(f)

    for aircraft in data['aircraft']:
#        print(aircraft['hex'])
        if aircraft['hex'] == HEX_ID:
            try:
                beaconData = {'lat': aircraft['lat'], 'lon': aircraft['lon'], 'speed': aircraft['gs'], 'height': aircraft['alt_geom']}
                x = requests.post(API_SERVER + '/beacon', json = beaconData, headers = {'Authorization': token})

                print (aircraft['lat'])
                print (aircraft['lon'])
            except:
                print('EXCEPTION: Probably out of range')
                pass # 

    time.sleep(1)