Fixed bug from issue #3, where old updates would get re-published due to a bad condition on an if statement. Also fixed design flaw where None was sometimes returned from getEvents(), causing trouble in the event-handling loop. There is now always a list of events; it should just be empty in every case where we don't find current data.

This commit is contained in:
Chris Smith 2021-04-06 20:39:11 -05:00
parent 75e7764299
commit 4748d06de7

View file

@ -258,12 +258,12 @@ def getEvents():
KML = http.open(conf['inReach']['URL']).read() KML = http.open(conf['inReach']['URL']).read()
except Exception as e: except Exception as e:
print("Error reading URL: " + conf['inReach']['URL']) print("Error reading URL: " + conf['inReach']['URL'])
return None return events
try: try:
data = xml.dom.minidom.parseString(KML).documentElement data = xml.dom.minidom.parseString(KML).documentElement
except Exception as e: except Exception as e:
print("Can't process KML feed on this pass.") print("Can't process KML feed on this pass.")
return None return events
#The first placemark will have the expanded current location information. #The first placemark will have the expanded current location information.
for PM in data.getElementsByTagName('Placemark'): for PM in data.getElementsByTagName('Placemark'):
res = parsePlacemark(PM) res = parsePlacemark(PM)
@ -316,7 +316,7 @@ def sendAPRS(device, DevID, ARPreamble, tstamp, lat, long, alt, course, speed, c
aprsPacket = ''.join([getSSID(DevID),ARPreamble, ':@', time.strftime("%d%H%Mz",tstamp), pos]) aprsPacket = ''.join([getSSID(DevID),ARPreamble, ':@', time.strftime("%d%H%Mz",tstamp), pos])
#Check to make sure the update is new: #Check to make sure the update is new:
if lastUpdate[DevID] > etime: if not etime > lastUpdate[DevID]:
return None return None
#In theory a course/speed of 000/000 sholdn't be much different #In theory a course/speed of 000/000 sholdn't be much different