Compare commits

..

2 Commits

  1. 10
      apparatinterface.py
  2. 10
      configreader.py
  3. 4
      fetapd.py
  4. 16
      phoneinterface.py
  5. 6
      statemachine.py

10
apparatinterface.py

@ -66,14 +66,14 @@ class FeApUserInterface(object):
cb(self.__nsi_cnt % 10) cb(self.__nsi_cnt % 10)
def __on_nsi_falling(self, pin): def __on_nsi_falling(self, pin):
#print 'nsi' #print('nsi')
self.__nsi_cnt += 1 self.__nsi_cnt += 1
def __on_gabelschalter_change(self, pin): def __on_gabelschalter_change(self, pin):
gbstate = gpio.input(self.__pinconfig.pin_gabelschalter) gbstate = gpio.input(self.__pinconfig.pin_gabelschalter)
if self.__pinconfig.invert_gs: if self.__pinconfig.invert_gs:
gbstate = 1 - gbstate gbstate = 1 - gbstate
print 'gabelschalter:', gbstate print('gabelschalter:', gbstate)
for cb in self.__gabelschalter_callbacks: for cb in self.__gabelschalter_callbacks:
cb(gbstate) cb(gbstate)
@ -89,10 +89,10 @@ class FeApUserInterface(object):
gpio.output(self.__pinconfig.pin_wecker_b, 1) gpio.output(self.__pinconfig.pin_wecker_b, 1)
time.sleep(0.02) time.sleep(0.02)
c += 40 c += 40
print 'ring' print('ring')
gpio.output(self.__pinconfig.pin_wecker_enable, 0) gpio.output(self.__pinconfig.pin_wecker_enable, 0)
print '' print('')
time.sleep(4) time.sleep(4)
@ -123,7 +123,7 @@ if __name__ == '__main__':
t = FeApUserInterface(pinconfig) t = FeApUserInterface(pinconfig)
def dailed(num): def dailed(num):
print num print(num)
t.add_nummernschalter_callback(dailed) t.add_nummernschalter_callback(dailed)

10
configreader.py

@ -1,5 +1,5 @@
import csv import csv
import ConfigParser import configparser
import apparatinterface import apparatinterface
import phoneinterface import phoneinterface
import statemachine import statemachine
@ -20,7 +20,7 @@ class ConfigurationReader(object):
} }
def __init__(self): def __init__(self):
self.__cp = ConfigParser.ConfigParser(defaults=ConfigurationReader.DEFAULTS) self.__cp = configparser.ConfigParser(defaults=ConfigurationReader.DEFAULTS)
self.pinconfig = None self.pinconfig = None
self.dialconfig = None self.dialconfig = None
self.phoneconfig = None self.phoneconfig = None
@ -45,9 +45,9 @@ class ConfigurationReader(object):
shortcuts = {} shortcuts = {}
with open(fname, 'r') as csvfile: with open(fname, 'r') as csvfile:
for row in csv.DictReader(csvfile): for row in csv.DictReader(csvfile):
print 'row', row print('row', row)
shortcuts[row['shortcut']] = row['number'] shortcuts[row['shortcut']] = row['number']
print 'shortcuts:', shortcuts print('shortcuts:', shortcuts)
return shortcuts return shortcuts
def __read_blacklist(self): def __read_blacklist(self):
@ -61,7 +61,7 @@ class ConfigurationReader(object):
def read(self, f): def read(self, f):
self.__cp.read(f) self.__cp.read(f)
print 'pin_nsa:', self.__get_global_val_int('pin_nsa'), print('pin_nsa:', self.__get_global_val_int('pin_nsa'),)
self.pinconfig = apparatinterface.FeApPinConfiguration( self.pinconfig = apparatinterface.FeApPinConfiguration(
gpio_numbering = self.__get_global_val('gpio_numbering'), gpio_numbering = self.__get_global_val('gpio_numbering'),
pin_nsa = self.__get_global_val_int('pin_nsa'), pin_nsa = self.__get_global_val_int('pin_nsa'),

4
fetapd.py

@ -65,7 +65,7 @@ def phone_cb(event):
controller.queue_event('invalid_number') controller.queue_event('invalid_number')
if __name__ == '__main__': if __name__ == '__main__':
print FeTAp print(FeTAp)
cfg = configreader.ConfigurationReader() cfg = configreader.ConfigurationReader()
cfg.read('fetap.ini') cfg.read('fetap.ini')
@ -82,5 +82,5 @@ if __name__ == '__main__':
except KeyboardInterrupt: except KeyboardInterrupt:
phone.stop() phone.stop()
feap.set_wecker(False) feap.set_wecker(False)
c.stop() controller.stop()

16
phoneinterface.py

@ -41,7 +41,7 @@ class PhoneEvent(object):
@classmethod @classmethod
def string(cls, val): def string(cls, val):
for k, v in vars(cls).iteritems(): for k, v in vars(cls).items():
if v == val: if v == val:
return k return k
@ -87,12 +87,12 @@ class PhoneInterface(object):
#self.__core.video_display_enabled = False #self.__core.video_display_enabled = False
def __global_state_changed(self, core, state, msg): def __global_state_changed(self, core, state, msg):
print 'Global state changed:', state, msg print('Global state changed:', state, msg)
# TODO: Do we need events emitted here? # TODO: Do we need events emitted here?
pass pass
def __registration_state_changed(self, core, proxyconf, state, msg): def __registration_state_changed(self, core, proxyconf, state, msg):
print 'Registration state changed:', proxyconf, state, msg print('Registration state changed:', proxyconf, state, msg)
evt = None evt = None
if state == linphone.RegistrationState.Progress: if state == linphone.RegistrationState.Progress:
evt = PhoneEvent.RegInProgress evt = PhoneEvent.RegInProgress
@ -105,10 +105,10 @@ class PhoneInterface(object):
for cb in self.__event_cbs: for cb in self.__event_cbs:
cb(evt) cb(evt)
else: else:
print 'Unhandled registration state:', linphone.RegistrationState.string(state) print('Unhandled registration state:', linphone.RegistrationState.string(state))
def __call_state_changed(self, core, call, state, msg): def __call_state_changed(self, core, call, state, msg):
print 'Call state changed:', call, state, msg print('Call state changed:', call, state, msg)
evt = None evt = None
if state == linphone.CallState.IncomingReceived: if state == linphone.CallState.IncomingReceived:
evt = PhoneEvent.CallIncoming evt = PhoneEvent.CallIncoming
@ -131,7 +131,7 @@ class PhoneInterface(object):
for cb in self.__event_cbs: for cb in self.__event_cbs:
cb(evt) cb(evt)
else: else:
print 'Unhandled call state:', linphone.CallState.string(state) print('Unhandled call state:', linphone.CallState.string(state))
def __pollthread(self): def __pollthread(self):
while self.__running: while self.__running:
@ -199,7 +199,7 @@ class PhoneInterface(object):
self.__audioproc.terminate() self.__audioproc.terminate()
def read_text(self, text): def read_text(self, text):
self.__ttsproc.stdin.write(text + '\n') self.__ttsproc.stdin.write(text.encode('utf8') + b'\n')
self.__ttsproc.stdin.flush() self.__ttsproc.stdin.flush()
def get_remote_number(self): def get_remote_number(self):
@ -207,7 +207,7 @@ class PhoneInterface(object):
if __name__ == '__main__': if __name__ == '__main__':
def event_cb(evt): def event_cb(evt):
print 'Got event:', PhoneEvent.string(evt) print('Got event:', PhoneEvent.string(evt))
try: try:
phone = PhoneInterface('.linphonerc-foo', '.linphonerc') phone = PhoneInterface('.linphonerc-foo', '.linphonerc')

6
statemachine.py

@ -1,5 +1,5 @@
import threading import threading
import Queue as queue import queue
class DialConfiguration(object): class DialConfiguration(object):
@ -263,10 +263,10 @@ class DialingState(BaseState):
def on_timeout(self): def on_timeout(self):
number = self.__number number = self.__number
print 'Dialing number:', number print('Dialing number:', number)
if number in self._controller.dialconfig.shortcuts: if number in self._controller.dialconfig.shortcuts:
number = self._controller.dialconfig.shortcuts[number] number = self._controller.dialconfig.shortcuts[number]
print 'shortcut resolved:', number print('shortcut resolved:', number)
self._controller.phone.call(number) self._controller.phone.call(number)
return ConnectingState return ConnectingState

Loading…
Cancel
Save