Fixed greylist functionality, added comment field to habitat telemetry sentence.

pull/24/head
Mark Jessop 2017-12-22 10:59:39 +10:30
rodzic 4a1a31f4ba
commit 4a42486496
2 zmienionych plików z 16 dodań i 5 usunięć

Wyświetl plik

@ -256,7 +256,8 @@ def sonde_search(config, attempts = 5):
# Detect peaks.
peak_indices = detect_peaks(power, mph=(power_nf+config['min_snr']), mpd=(config['min_distance']/step), show = False)
if len(peak_indices) == 0:
# If we have found no peaks, and no greylist has been provided, re-scan.
if (len(peak_indices) == 0) and (len(config['greylist'])==0):
logging.info("No peaks found on this pass.")
search_attempts -= 1
time.sleep(10)
@ -658,7 +659,12 @@ def internet_push_thread(station_config):
# Habitat Upload
if station_config['enable_habitat']:
habitat_upload_payload_telemetry(data, payload_callsign=config['payload_callsign'], callsign=config['uploader_callsign'])
# We make the habitat comment field fixed, as we only need to add the payload type/serial/frequency.
habitat_comment = "%s %s %s" % (data['type'], data['id'], data['freq'])
habitat_upload_payload_telemetry(data,
payload_callsign=config['payload_callsign'],
callsign=config['uploader_callsign'],
comment=habitat_comment)
logging.debug("Data pushed to Habitat.")
# Update Rotator positon, if configured.

Wyświetl plik

@ -28,7 +28,7 @@ def crc16_ccitt(data):
crc16 = crcmod.predefined.mkCrcFun('crc-ccitt-false')
return hex(crc16(data))[2:].upper().zfill(4)
def telemetry_to_sentence(sonde_data, payload_callsign="RADIOSONDE"):
def telemetry_to_sentence(sonde_data, payload_callsign="RADIOSONDE", comment=None):
# RS produces timestamps with microseconds on the end, we only want HH:MM:SS for uploading to habitat.
data_datetime = datetime.datetime.strptime(sonde_data['datetime_str'],"%Y-%m-%dT%H:%M:%S.%f")
short_time = data_datetime.strftime("%H:%M:%S")
@ -36,13 +36,18 @@ def telemetry_to_sentence(sonde_data, payload_callsign="RADIOSONDE"):
sentence = "$$%s,%d,%s,%.5f,%.5f,%d,%.1f,%.1f,%.1f" % (payload_callsign,sonde_data['frame'],short_time,sonde_data['lat'],
sonde_data['lon'],int(sonde_data['alt']),sonde_data['vel_h'], sonde_data['temp'], sonde_data['humidity'])
# Add on a comment field if provided - note that this will result in a different habitat payload doc being required.
if comment != None:
comment = comment.replace(',','_')
sentence += "," + comment
checksum = crc16_ccitt(sentence[2:])
output = sentence + "*" + checksum + "\n"
return output
def habitat_upload_payload_telemetry(telemetry, payload_callsign = "RADIOSONDE", callsign="N0CALL"):
def habitat_upload_payload_telemetry(telemetry, payload_callsign = "RADIOSONDE", callsign="N0CALL", comment=None):
sentence = telemetry_to_sentence(telemetry, payload_callsign = payload_callsign)
sentence = telemetry_to_sentence(telemetry, payload_callsign = payload_callsign, comment=comment)
sentence_b64 = b64encode(sentence)