summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa1112011-07-14 21:12:02 +0200
committeraa1112011-07-14 21:12:02 +0200
commit56ff403cba98b2a0df40a416a9c92343aea9805f (patch)
treec5e8b410428c00da7b9a18e344f3a5d9fab060e3
parentMerge branch 'master' of lab.ks.uni-freiburg.de:lsfks/projekte/gsm-selftest (diff)
downloadgsm-selftest-56ff403cba98b2a0df40a416a9c92343aea9805f.tar.gz
gsm-selftest-56ff403cba98b2a0df40a416a9c92343aea9805f.tar.xz
gsm-selftest-56ff403cba98b2a0df40a416a9c92343aea9805f.zip
The final code for landlineCall. However, this code works only for manual input. Communication between Controller and code will be implemented soon.
-rw-r--r--notFinishedCode/landlineCall.py63
1 files changed, 39 insertions, 24 deletions
diff --git a/notFinishedCode/landlineCall.py b/notFinishedCode/landlineCall.py
index 477794a..58ad851 100644
--- a/notFinishedCode/landlineCall.py
+++ b/notFinishedCode/landlineCall.py
@@ -6,13 +6,15 @@ import string
server = "sipgate.de"
username = "1289459"
password = "MMW9AX"
-number = "00497612034661449"
+number = "00497612034661455"
LOG_LEVEL = 2
current_call = None
+is486 = False
isConfirmed = False
isRinging = False
isConnected = False
+TIMEOUT_LIMIT = 30
userInput = ""
# Logging callback
@@ -37,28 +39,26 @@ class MyCallCallback(pj.CallCallback):
global isConfirmed
global isConnected
global isRinging
-
-
- if self.call.info().state == pj.CallState.NULL:
- print "CALL NOT INITIALIZED"
+ global is486
if self.call.info().state == pj.CallState.CALLING:
- print "TRYING TO CALL..."
-
- if self.call.info().state == pj.CallState.CONNECTING:
- print "CONNECTING..."
+ print "CALLING..."
+ if self.call.info().last_code == 486:
+ is486 = True
+
if self.call.info().state == pj.CallState.EARLY:
- print "CALLEE IS RINGING!!"
isRinging = True
if self.call.info().state == pj.CallState.CONFIRMED:
isConfirmed = True
isConnected = True
+ isRinging = False
if self.call.info().state == pj.CallState.DISCONNECTED:
current_call = None
isConnected = False
+
def make_call(uri):
try:
@@ -88,32 +88,47 @@ print "You want to call then."
while userInput <> "quit":
- timeCounter = 0
- firstTime = True
+ timeCounterRinging = 0
+ firstTimeRinging = True
if acc.info().reg_status < 700:
numberToCall = "sip:"+number+"@"+server
current_call = make_call(numberToCall)
while 1:
- if isConnected:
+
+ if isRinging:
sleep(1)
- timeCounter = timeCounter + 1
- if firstTime:
- print "WAITING..."
- firstTime = False
-
- if isConfirmed and isConnected == False:
- print "THE NUMBER THAT YOU'VE DIALLED IS EITHER BUSY OR OFFLINE!!"
+ timeCounterRinging = timeCounterRinging + 1
+ if firstTimeRinging:
+ print "RINGING..."
+ firstTimeRinging = False
+ if is486:
+ print "THE NUMBER THAT YOU'VE DIALLED IS BUSY!!"
isConfirmed = False
- isConnected = False
- break
+ isConnected = False
+ isRinging = False
+ is486 = False
+ break
- if timeCounter == 12 and isConnected and isConfirmed:
+ if isConnected and isConfirmed:
+ print "CALL SUCCESSFULLY ESTABLISHED!!"
+ sleep(5)
current_call.hangup()
- print "CALL SUCCESSFULLY ESTABLISHED AND TERMNIATED!!"
+ print "CALL SUCCESSFULLY TERMINATED!!"
+ isConfirmed = False
+ isConnected = False
+ isRinging = False
+ is486 = False
+ break
+
+ if timeCounterRinging == TIMEOUT_LIMIT and isRinging:
+ current_call.hangup()
+ print "THE NUMBER THAT YOU'VE DIALLED IS NOT ANSWERING!!"
isConfirmed = False
isConnected = False
+ isRinging = False
+ is486 = False
break
else: