start/stop explorer publising in correlation with modem

This commit is contained in:
DJ2LS 2024-01-11 14:22:00 +01:00
parent eff0383202
commit a1c92a0a03

View file

@ -14,6 +14,7 @@ class SM:
self.modem = False self.modem = False
self.beacon = False self.beacon = False
self.explorer = False
self.app = app self.app = app
self.config = self.app.config_manager.read() self.config = self.app.config_manager.read()
self.modem_fft = app.modem_fft self.modem_fft = app.modem_fft
@ -27,8 +28,6 @@ class SM:
) )
runner_thread.start() runner_thread.start()
self.start_explorer_publishing()
def runner(self): def runner(self):
while True: while True:
cmd = self.modem_service.get() cmd = self.modem_service.get()
@ -36,14 +35,17 @@ class SM:
self.log.info("------------------ FreeDATA ------------------") self.log.info("------------------ FreeDATA ------------------")
self.log.info("------------------ MODEM ------------------") self.log.info("------------------ MODEM ------------------")
self.start_modem() self.start_modem()
self.start_explorer_publishing()
elif cmd in ['stop'] and self.modem: elif cmd in ['stop'] and self.modem:
self.stop_modem() self.stop_modem()
self.stop_explorer_publishing()
# we need to wait a bit for avoiding a portaudio crash # we need to wait a bit for avoiding a portaudio crash
threading.Event().wait(0.5) threading.Event().wait(0.5)
elif cmd in ['restart']: elif cmd in ['restart']:
self.stop_modem() self.stop_modem()
self.stop_explorer_publishing()
# we need to wait a bit for avoiding a portaudio crash # we need to wait a bit for avoiding a portaudio crash
threading.Event().wait(0.5) threading.Event().wait(0.5)
if self.start_modem(): if self.start_modem():
@ -121,6 +123,9 @@ class SM:
try: try:
# optionally start explorer module # optionally start explorer module
if self.config['STATION']['enable_explorer']: if self.config['STATION']['enable_explorer']:
explorer.explorer(self.app, self.config, self.states) self.explorer = explorer.explorer(self.app, self.config, self.states)
except Exception as e: except Exception as e:
self.log.warning("[EXPLORER] Publishin not started because of error", e=e) self.log.warning("[EXPLORER] Publishing not started because of error", e=e)
def stop_explorer_publishing(self):
del self.explorer