diff --git a/chasemapper/__init__.py b/chasemapper/__init__.py index 6747341..89ec3a5 100644 --- a/chasemapper/__init__.py +++ b/chasemapper/__init__.py @@ -8,4 +8,4 @@ # Now using Semantic Versioning (https://semver.org/) MAJOR.MINOR.PATCH -__version__ = "1.3.6" +__version__ = "1.4.0" diff --git a/chasemapper/sondehub.py b/chasemapper/sondehub.py index a52ea97..98d911a 100644 --- a/chasemapper/sondehub.py +++ b/chasemapper/sondehub.py @@ -29,7 +29,9 @@ class SondehubChaseUploader(object): """ Upload supplied chase car positions to Sondehub on a regular basis """ SONDEHUB_STATION_POSITION_URL = "https://api.v2.sondehub.org/listeners" + SONDEHUB_STATION_POSITION_URL_AMATEUR = "https://api.v2.sondehub.org/amateur/listeners" SONDEHUB_SONDE_RECOVERED_URL = "https://api.v2.sondehub.org/recovered" + SONDEHUB_SONDE_RECOVERED_URL_AMATEUR = "https://api.v2.sondehub.org/amateur/recovered" def __init__( self, @@ -38,6 +40,7 @@ class SondehubChaseUploader(object): upload_enabled=True, upload_timeout=10, upload_retries=2, + amateur=False # Upload to amateur DB instead of regular sondehub ): """ Initialise the Sondehub Chase uploader, and start the update thread """ @@ -47,6 +50,7 @@ class SondehubChaseUploader(object): self.upload_enabled = upload_enabled self.upload_timeout = upload_timeout self.upload_retries = upload_retries + self.amateur = amateur self.car_position = None self.car_position_lock = Lock() @@ -55,7 +59,14 @@ class SondehubChaseUploader(object): self.uploader_thread = Thread(target=self.upload_thread) self.uploader_thread.start() - logging.info("Sondehub - Chase-Car Position Uploader Started") + if amateur: + self.position_url = self.SONDEHUB_STATION_POSITION_URL_AMATEUR + self.recovery_url = self.SONDEHUB_SONDE_RECOVERED_URL_AMATEUR + logging.info("Sondehub-Amateur - Chase-Car Position Uploader Started") + else: + self.position_url = self.SONDEHUB_STATION_POSITION_URL + self.recovery_url = self.SONDEHUB_SONDE_RECOVERED_URL + logging.info("Sondehub - Chase-Car Position Uploader Started") def update_position(self, position): """ Update the chase car position state @@ -137,7 +148,7 @@ class SondehubChaseUploader(object): "Content-Type": "application/json", } _req = requests.put( - self.SONDEHUB_STATION_POSITION_URL, + self.position_url, json=_position, # TODO: Revisit this second timeout value. timeout=(self.upload_timeout, 6.1), @@ -203,7 +214,7 @@ class SondehubChaseUploader(object): "Content-Type": "application/json", } _req = requests.put( - self.SONDEHUB_SONDE_RECOVERED_URL, + self.recovery_url, json=_doc, # TODO: Revisit this second timeout value. timeout=(self.upload_timeout, 6.1), diff --git a/horusmapper.cfg.example b/horusmapper.cfg.example index b25a65d..6aeb8ab 100644 --- a/horusmapper.cfg.example +++ b/horusmapper.cfg.example @@ -41,8 +41,16 @@ car_source_port = 12345 # Online Tracker System # Where to upload chase-car positions and balloon recovery notifications to. +# Note - you can only select one of these at a time. +# # sondehub = Sondehub v2 Database, for viewing on the SondeHub tracker (https://tracker.sondehub.org) +# Use this for chasing meteorological radiosondes! +# +# sondehubamateur = SondeHub Amateur Database, for viewing on the SondeHub-Amateur Tracker (https://amateur.sondehub.org) +# Use this when chasing your own flights, and you want to show up on the sondehub-amateur tracker. +# # habitat = Habitat Database, for viewing on the HabHub tracker (https://tracker.habhub.org) +# Use this when chasing your own flights, and you want to show up on the HabHub tracker. online_tracker = sondehub # Other profiles can be defined in sections like the following: diff --git a/horusmapper.py b/horusmapper.py index dd96224..aec8c11 100644 --- a/horusmapper.py +++ b/horusmapper.py @@ -205,6 +205,12 @@ def client_settings_update(data): update_rate=chasemapper_config["habitat_update_rate"], callsign=chasemapper_config["habitat_call"], ) + elif _tracker == "sondehubamateur": + online_uploader = SondehubChaseUploader( + update_rate=chasemapper_config["habitat_update_rate"], + callsign=chasemapper_config["habitat_call"], + amateur=True + ) else: logging.error( "Unknown Online Tracker %s, not starting uploader." % _tracker @@ -959,7 +965,7 @@ def start_listeners(profile): 'telemetry_source_port' (int): Data source port 'car_source_type' (str): Car Position source type (none, horus_udp, gpsd, or station) 'car_source_port' (int): Car Position source port - 'online_tracker' (str): Which online tracker to upload chase-car info to ('habitat' or 'sondehub') + 'online_tracker' (str): Which online tracker to upload chase-car info to ('habitat' or 'sondehub' or 'sondehubamateur') """ global data_listeners, current_profile, online_uploader, chasemapper_config @@ -992,6 +998,12 @@ def start_listeners(profile): update_rate=chasemapper_config["habitat_update_rate"], callsign=chasemapper_config["habitat_call"], ) + elif _tracker == "sondehubamateur": + online_uploader = SondehubChaseUploader( + update_rate=chasemapper_config["habitat_update_rate"], + callsign=chasemapper_config["habitat_call"], + amateur=True + ) else: logging.error( "Unknown Online Tracker %s, not starting uploader" diff --git a/static/js/sondehub.js b/static/js/sondehub.js index 25a6835..39cfc5f 100644 --- a/static/js/sondehub.js +++ b/static/js/sondehub.js @@ -8,6 +8,7 @@ // URL to scrape recent vehicle position data from. var sondehub_vehicle_url = "https://api.v2.sondehub.org/listeners/telemetry?duration=1h"; +var sondehub_vehicle_url_amateur = "https://api.v2.sondehub.org/amateur/listeners/telemetry?duration=1h"; // Not really sure if this is necessary. @@ -163,6 +164,25 @@ function get_sondehub_vehicles(){ } } +// Request the latest vehicle positions from Sondehub-Amateur +function get_sondehub_amateur_vehicles(){ + + if(!sondehub_request_running){ + sondehub_request_running = true; + console.log("Requesting vehicles from Sondehub Amateur...") + $.ajax({ + url: sondehub_vehicle_url_amateur, + dataType: 'json', + timeout: 15000, + async: true, + success: function(data) { + console.log(data); + process_sondehub_vehicles(data); + } + }); + } +} + /* Habitat ChaseCar lib (copied from SondeHub Tracker) * Uploads geolocation for chase cars to habitat diff --git a/templates/index.html b/templates/index.html index 7e7bf40..3b14e6a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -682,6 +682,9 @@ else if (chase_config.profiles[chase_config.selected_profile].online_tracker === "sondehub"){ get_sondehub_vehicles(); } + else if (chase_config.profiles[chase_config.selected_profile].online_tracker === "sondehubamateur"){ + get_sondehub_amateur_vehicles(); + } else{ // Do nothing... }