Add callback from statemachine to update webinterface status

This commit is contained in:
sqozz 2021-02-24 20:40:33 +01:00
parent ccb76fd306
commit 24848c9afb
2 changed files with 5 additions and 0 deletions

View file

@ -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')

View file

@ -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)):