From 24848c9afb5004d181c04ac055091dec0172b32d Mon Sep 17 00:00:00 2001
From: sqozz <sqozz@geekify.de>
Date: Wed, 24 Feb 2021 20:40:33 +0100
Subject: [PATCH] Add callback from statemachine to update webinterface status

---
 fetapd.py       | 1 +
 statemachine.py | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/fetapd.py b/fetapd.py
index 1f7740f..2cc54d4 100644
--- a/fetapd.py
+++ b/fetapd.py
@@ -75,6 +75,7 @@ if __name__ == '__main__':
     feap = FeApUserInterface(cfg.pinconfig)
     controller = statemachine.StateMachineController(phone, feap, cfg.dialconfig)
     webinterface = FeTapWeb({}, controller)
+    controller.publish_state = webinterface.publish_status
 
     # TODO: Use real events from daemon
     controller.queue_event('registration_in_progress')
diff --git a/statemachine.py b/statemachine.py
index 9e30a25..dd0fab5 100644
--- a/statemachine.py
+++ b/statemachine.py
@@ -307,6 +307,10 @@ class StateMachineController(object):
             oldstate = self.state.__class__
             print('%s -> %s' % (oldstate.__name__, newstate.__name__))
             self.state = newstate(self)
+            self.publish_state()
+
+    def publish_state(self):
+        pass
 
     def queue_event(self, evname, *evargs, **evkwargs):
         if not hasattr(AbstractState, 'on_%s' % (evname)):