|
|
@ -241,18 +241,23 @@ class DialingState(BaseState): |
|
|
|
self._controller.phone.stop_playing() |
|
|
|
self._controller.phone.stop_playing() |
|
|
|
self.__number += str(num) |
|
|
|
self.__number += str(num) |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.abort_timeout() |
|
|
|
self._controller.set_timeout(5000) |
|
|
|
self._controller.set_timeout(self._controller.dialconfig.dial_timeout * 1000) |
|
|
|
|
|
|
|
|
|
|
|
def on_timeout(self): |
|
|
|
def on_timeout(self): |
|
|
|
print 'Dialing number:', self.__number |
|
|
|
number = self.__number |
|
|
|
self._controller.phone.call(self.__number) |
|
|
|
print 'Dialing number:', number |
|
|
|
|
|
|
|
if number in self._controller.dialconfig.shortcuts: |
|
|
|
|
|
|
|
number = self._controller.dialconfig.shortcuts[number] |
|
|
|
|
|
|
|
print 'shortcut resolved:', number |
|
|
|
|
|
|
|
self._controller.phone.call(number) |
|
|
|
return ConnectingState |
|
|
|
return ConnectingState |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StateMachineController(object): |
|
|
|
class StateMachineController(object): |
|
|
|
def __init__(self, phone, feap): |
|
|
|
def __init__(self, phone, feap, dialconfig): |
|
|
|
self.__phone = phone |
|
|
|
self.__phone = phone |
|
|
|
self.__feap = feap |
|
|
|
self.__feap = feap |
|
|
|
|
|
|
|
self.__dialconfig = dialconfig |
|
|
|
|
|
|
|
|
|
|
|
self.__state = InitState(self) |
|
|
|
self.__state = InitState(self) |
|
|
|
|
|
|
|
|
|
|
@ -307,6 +312,10 @@ class StateMachineController(object): |
|
|
|
def feap(self): |
|
|
|
def feap(self): |
|
|
|
return self.__feap |
|
|
|
return self.__feap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
|
|
def dialconfig(self): |
|
|
|
|
|
|
|
return self.__dialconfig |
|
|
|
|
|
|
|
|
|
|
|
def stop(self, hard=False): |
|
|
|
def stop(self, hard=False): |
|
|
|
if hard: |
|
|
|
if hard: |
|
|
|
self.__running = False |
|
|
|
self.__running = False |
|
|
@ -354,7 +363,7 @@ if __name__ == '__main__': |
|
|
|
|
|
|
|
|
|
|
|
phone = PhoneInterface(cfg.phoneconfig) |
|
|
|
phone = PhoneInterface(cfg.phoneconfig) |
|
|
|
feap = FeApUserInterface(cfg.pinconfig) |
|
|
|
feap = FeApUserInterface(cfg.pinconfig) |
|
|
|
c = StateMachineController(phone, feap) |
|
|
|
c = StateMachineController(phone, feap, cfg.dialconfig) |
|
|
|
|
|
|
|
|
|
|
|
feap.add_gabelschalter_callback(gabelschalter_cb) |
|
|
|
feap.add_gabelschalter_callback(gabelschalter_cb) |
|
|
|
feap.add_nummernschalter_active_callback(nummernschalter_active_cb) |
|
|
|
feap.add_nummernschalter_active_callback(nummernschalter_active_cb) |
|
|
|