diff --git a/auto_rx/auto_rx.py b/auto_rx/auto_rx.py index 3d8229f..73422f1 100644 --- a/auto_rx/auto_rx.py +++ b/auto_rx/auto_rx.py @@ -204,7 +204,8 @@ def start_decoder(freq, sonde_type): exporter = exporter_functions, timeout = config['rx_timeout'], telem_filter = telemetry_filter, - rs92_ephemeris = rs92_ephemeris + rs92_ephemeris = rs92_ephemeris, + imet_location = config['station_code'] ) autorx.sdr_list[_device_idx]['task'] = autorx.task_list[freq]['task'] diff --git a/auto_rx/autorx/config.py b/auto_rx/autorx/config.py index 62aa629..e8ace63 100644 --- a/auto_rx/autorx/config.py +++ b/auto_rx/autorx/config.py @@ -61,6 +61,7 @@ def read_auto_rx_config(filename): 'station_lat' : 0.0, 'station_lon' : 0.0, 'station_alt' : 0.0, + 'station_code' : 'SONDE', # Position Filter Settings 'max_altitude' : 50000, 'max_radius_km' : 1000, @@ -235,6 +236,15 @@ def read_auto_rx_config(filename): except: logging.error("Config - Could not find debugging settings - using defaults.") + # iMet station code - added 2019-03-24 + try: + auto_rx_config['station_code'] = config.get('location', 'station_code') + if len(auto_rx_config['station_code']) > 5: + auto_rx_config['station_code'] = auto_rx_config['station_code'][:5] + logging.warning("Config - Clipped station code to 5 digits: %s" % auto_rx_config['station_code']) + except: + logging.error("Config - Could not find station_code field, using default.") + # Now we attempt to read in the individual SDR parameters. auto_rx_config['sdr_settings'] = {} diff --git a/auto_rx/autorx/decode.py b/auto_rx/autorx/decode.py index 3a68eb2..54bc120 100644 --- a/auto_rx/autorx/decode.py +++ b/auto_rx/autorx/decode.py @@ -529,7 +529,7 @@ class SondeDecoder(object): self.imet_id = imet_unique_id(_telemetry, custom=self.imet_location) _telemetry['id'] = self.imet_id - + _telemetry['station_code'] = self.imet_location # If we have been provided a telemetry filter function, pass the telemetry data # through the filter, and return the response diff --git a/auto_rx/autorx/habitat.py b/auto_rx/autorx/habitat.py index b54908e..fd0e867 100644 --- a/auto_rx/autorx/habitat.py +++ b/auto_rx/autorx/habitat.py @@ -90,6 +90,12 @@ def sonde_telemetry_to_sentence(telemetry, payload_callsign=None, comment=None): if (telemetry['bt'] != -1) and (telemetry['bt'] != 65535): _sentence += " BT %s" % time.strftime("%H:%M:%S", time.gmtime(telemetry['bt'])) + # Add on the station code, which will only be present if we are receiving an iMet sonde. + # This may assist multiple receiving stations in the vicinity of an iMet launch site coordinate + # the iMet unique ID generation. + if 'station_code' in telemetry: + _sentence += " LOC: %s" % telemetry['station_code'] + # Add on any custom comment data if provided. if comment != None: comment = comment.replace(',','_') diff --git a/auto_rx/autorx/logger.py b/auto_rx/autorx/logger.py index 3bedc95..b58b819 100644 --- a/auto_rx/autorx/logger.py +++ b/auto_rx/autorx/logger.py @@ -36,7 +36,7 @@ class TelemetryLogger(object): FILE_ACTIVITY_TIMEOUT = 30 # We require the following fields to be present in the input telemetry dict. - REQUIRED_FIELDS = ['frame', 'id', 'datetime', 'lat', 'lon', 'alt', 'temp', 'type', 'freq', 'datetime_dt'] + REQUIRED_FIELDS = ['frame', 'id', 'datetime', 'lat', 'lon', 'alt', 'temp', 'humidity', 'type', 'freq', 'datetime_dt'] def __init__(self, log_directory = "./log"): @@ -116,7 +116,7 @@ class TelemetryLogger(object): Args: telemetry (dict): Telemetry dictionary to process. """ - _log_line = "%s,%s,%d,%.5f,%.5f,%.1f,%.1f,%s,%.3f" % ( + _log_line = "%s,%s,%d,%.5f,%.5f,%.1f,%.1f,%.1f,%s,%.3f" % ( telemetry['datetime'], telemetry['id'], telemetry['frame'], @@ -124,9 +124,17 @@ class TelemetryLogger(object): telemetry['lon'], telemetry['alt'], telemetry['temp'], + telemetry['humidity'], telemetry['type'], telemetry['freq_float']) + # Other fields that may not always be present. + if 'sats' in telemetry: + _log_line += ",SATS %d" % telemetry['sats'] + + if 'batt' in telemetry: + _log_line += ",BATT %.1f" % telemetry['batt'] + # Check for Burst/Kill timer data, and add in. if 'bt' in telemetry: if (telemetry['bt'] != -1) and (telemetry['bt'] != 65535): diff --git a/auto_rx/station.cfg.example b/auto_rx/station.cfg.example index 3047b07..4f4eaf6 100644 --- a/auto_rx/station.cfg.example +++ b/auto_rx/station.cfg.example @@ -73,6 +73,8 @@ greylist = [] + + #################### # STATION LOCATION # #################### @@ -82,6 +84,15 @@ station_lat = 0.0 station_lon = 0.0 station_alt = 0.0 +# Location Code (Maximum 5 characters) +# This is ONLY used by the Intermet iMet decoder, to provide additional entropy when +# generating a unique ID for the iMet sondes, which do not transmit their serial number. +# If you know the WMO number of the launch site, then this would be a good value to use. +# Otherwise the ICAO Code of the airport nearest to the launch site would also work. +# If you are not expecting to RX iMet sondes, then this can be left at its default. + +station_code = SONDE + ###########################