Skip to content

Commit

Permalink
add new named branches
Browse files Browse the repository at this point in the history
  • Loading branch information
xssfox committed Sep 7, 2024
1 parent 651c258 commit c804579
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lambda/sonde_api_to_iot_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,15 @@ def telemetry_filter(telemetry):
return ("errors",f"SondeMonitor version is out of date and doesn't handle DFM radiosondes correctly. Please update to 6.2.8.8 or later")
if telemetry["software_name"] == "rdzTTGOsonde":
ttgo_branch, ttgo_version = parse_rdz_ttgo_version(telemetry["software_version"])
if ttgo_branch == "devel":
if ttgo_version < (20230427,0,0):
return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later")
elif ttgo_branch == "master":
if ttgo_version < (0,9,3):
return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later")
else:
return ("errors",f"rdzTTGOsonde branch and version was unable to be determined. We are unsure if this version handles DFM sondes correctly. Please update to master 0.9.3, devel20230427 or later")
if ttgo_branch not in ["main", "dev"]: # presume that this is fixed in the new named branch releases
if ttgo_branch == "devel":
if ttgo_version < (20230427,0,0):
return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later")
elif ttgo_branch == "master":
if ttgo_version < (0,9,3):
return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later")
else:
return ("errors",f"rdzTTGOsonde branch and version was unable to be determined. We are unsure if this version handles DFM sondes correctly. Please update to master 0.9.3, devel20230427 or later")
# Check if DFM17->DFM09 misid - https://github.com/projecthorus/sondehub-infra/issues/141
if "subtype" in telemetry and telemetry["subtype"] == "DFM09":
try:
Expand Down Expand Up @@ -357,7 +358,7 @@ def parse_rdz_ttgo_version(version):
# RDZ TTGO has two branches, master and devel, however there are also a bunch of other custom versions
# devel20230829, master_v0.9.3, master_v0.9.2, devel20230427, devLZ20230812, devel20230829.NE, Alex_ver_2.7_M, multich_v3
# in the cases that don't match develxxxx or master_vxxxx format we'll give a 0,0,0 version here
m = re.search(r'([a-zA-Z_]+?)_?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?', version)
m = re.search(r'([a-zA-Z_]+?)(?:_v)?(\d+)(?:\.(\d+))?(?:\.(\d+))?', version)
return (m.groups()[0],tuple([int(x if x != None else 0) for x in m.groups()[1:]]))
except:
return ("unknown", (0,0,0))
Expand Down
21 changes: 21 additions & 0 deletions lambda/sonde_api_to_iot_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ def test_good_ttgo_master_payload(self):
sns.publish.assert_called()
self.assertEqual(output["body"], "^v^ telm logged")
self.assertEqual(output["statusCode"], 200)
def test_good_ttgo_devel_payload_new_name(self):
payload = copy.deepcopy(example_body)
payload[0]["datetime"] = datetime.datetime.now().isoformat()
payload[0]["software_name"] = "rdzTTGOsonde"
payload[0]["software_version"] = "dev20230829"
payload[0]["type"] = "DFM"
output = lambda_handler(compress_payload(payload), fakeContext())
sns.publish.assert_called()
self.assertEqual(output["body"], "^v^ telm logged")
self.assertEqual(output["statusCode"], 200)
def test_good_ttgo_main_payload(self):
payload = copy.deepcopy(example_body)
payload[0]["datetime"] = datetime.datetime.now().isoformat()
payload[0]["software_name"] = "rdzTTGOsonde"
payload[0]["software_version"] = "main1234"
payload[0]["type"] = "DFM"
output = lambda_handler(compress_payload(payload), fakeContext())
sns.publish.assert_called()
self.assertEqual(output["body"], "^v^ telm logged")
self.assertEqual(output["statusCode"], 200)

def test_bad_ttgo_devel_payload(self):
payload = copy.deepcopy(example_body)
payload[0]["datetime"] = datetime.datetime.now().isoformat()
Expand Down

0 comments on commit c804579

Please sign in to comment.