@@ -203,7 +203,12 @@ def __init__(
203203 # which don't necessarily have a consistent packet count to time increment ratio.
204204 # This is a tradeoff between being able to handle multiple iMet sondes on a single frequency, and
205205 # not flooding the various databases with sonde IDs in the case of a bad sonde.
206- self .imet_id = None
206+
207+ # iMet ID store v2
208+ # Now instead of just latching onto an ID, we allow up to 4 new IDs to be created per decoder.
209+ # This should hopefully handle a few iMets on the same frequency in a graceful manner.
210+ self .imet_max_ids = 4
211+ self .imet_id = []
207212
208213 # This will become our decoder thread.
209214 self .decoder = None
@@ -876,7 +881,7 @@ def generate_decoder_command_experimental(self):
876881 )
877882
878883 # M20 decoder
879- decode_cmd = f"./mXXmod --json --ptu -vvv --softin -i { self .raw_file_option } 2>/dev/null"
884+ decode_cmd = f"./m20mod --json --ptu -vvv --softin -i { self .raw_file_option } 2>/dev/null"
880885
881886 # M20 sondes transmit in short, irregular pulses - average over the last 2 frames, and use a peak hold
882887 demod_stats = FSKDemodStats (averaging_time = 2.0 , peak_hold = True )
@@ -1315,16 +1320,30 @@ def handle_decoder_line(self, data):
13151320
13161321 # Fix up the time.
13171322 _telemetry ["datetime_dt" ] = fix_datetime (_telemetry ["datetime" ])
1318- # Generate a unique ID based on the power-on time and frequency, as iMet sondes don't send one.
1319- # Latch this ID and re-use it for the entire decode run.
1320- if self .imet_id == None :
1321- self .imet_id = imet_unique_id (_telemetry )
1323+
1324+ # Generate a unique ID based on the power-on time and frequency, as iMet sonde telemetry is painful
1325+ # and doesn't send any ID.
1326+ _new_imet_id = imet_unique_id (_telemetry )
1327+
1328+ # If we have seen this ID before, keep using it.
1329+ if _new_imet_id in self .imet_id :
1330+ _telemetry ["id" ] = _new_imet_id
1331+ else :
1332+ # We have seen less than 4 different IDs while this decoder has been runing.
1333+ # Accept that this may be a new iMet sonde, and add the ID to the iMet ID list.
1334+ if len (self .imet_id ) < self .imet_max_ids :
1335+ self .imet_id .append (_new_imet_id )
1336+ _telemetry ["id" ] = _new_imet_id
1337+ else :
1338+ # We have seen see many IDs this decode run, suspect this is likely an old iMet-1
1339+ # Which doesn't have a useful frame counter.
1340+ self .log_error ("Exceeded maximum number of iMet sonde IDs for a decoder (4) - discarding this frame." )
1341+ return False
13221342
13231343 # Re-generate the datetime string.
13241344 _telemetry ["datetime" ] = _telemetry ["datetime_dt" ].strftime (
13251345 "%Y-%m-%dT%H:%M:%SZ"
13261346 )
1327- _telemetry ["id" ] = self .imet_id
13281347
13291348 # iMet-5x Specific Actions
13301349 if self .sonde_type == "IMET5" :
0 commit comments