summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortriatmoko2011-07-15 14:21:01 +0200
committertriatmoko2011-07-15 14:21:01 +0200
commit8345cb9cc0af35ec33940dae14e800675cbef580 (patch)
tree78c22139ed849391e57dbcbf38873d90356d5b4b
parenttimeout for controller. (diff)
parentThe final code for landlineCall. However, this code works only for manual inp... (diff)
downloadgsm-selftest-8345cb9cc0af35ec33940dae14e800675cbef580.tar.gz
gsm-selftest-8345cb9cc0af35ec33940dae14e800675cbef580.tar.xz
gsm-selftest-8345cb9cc0af35ec33940dae14e800675cbef580.zip
Merge branch 'master' of lab.ks.uni-freiburg.de:lsfks/projekte/gsm-selftest
-rw-r--r--notFinishedCode/GSMClass.py13
-rw-r--r--notFinishedCode/landlineCall.py76
2 files changed, 60 insertions, 29 deletions
diff --git a/notFinishedCode/GSMClass.py b/notFinishedCode/GSMClass.py
index a6019b6..e994814 100644
--- a/notFinishedCode/GSMClass.py
+++ b/notFinishedCode/GSMClass.py
@@ -132,7 +132,7 @@ class serialPort():
else:
return 4
else:
- return 0
+ return 2
except Exception, e:
import traceback
if self.debugMode == 1:
@@ -175,6 +175,17 @@ class serialPort():
return 2 #not yet in a call
elif received == 'ACTIVE':
return 1 #in a call
+ elif received == 'HELD':
+ return 5 #held call
+ elif received == 'DIALING':
+ return 6 #dialing
+ elif received == 'ALERTING':
+ return 7 #alerting the call
+ elif received == 'INCOMING':
+ return 8 #incoming call
+ elif received == 'WAITING':
+ return 9 #waiting for a call
+
else:
return received #in some other state
except Exception, e:
diff --git a/notFinishedCode/landlineCall.py b/notFinishedCode/landlineCall.py
index 76565f1..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
-isDisconnected = False
+is486 = False
isConfirmed = False
isRinging = False
+isConnected = False
+TIMEOUT_LIMIT = 30
userInput = ""
# Logging callback
@@ -35,30 +37,28 @@ class MyCallCallback(pj.CallCallback):
def on_state(self):
global current_call
global isConfirmed
- global isDisconnected
+ 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
- isDisconnected = True
- isConfirmed = False
+ isConnected = False
+
def make_call(uri):
try:
@@ -87,32 +87,52 @@ print "You want to call then."
while userInput <> "quit":
- timeCounter = 0
+
+ timeCounterRinging = 0
+ firstTimeRinging = True
if acc.info().reg_status < 700:
numberToCall = "sip:"+number+"@"+server
current_call = make_call(numberToCall)
while 1:
- if isConfirmed and isDisconnected == False:
+
+ if isRinging:
sleep(1)
- timeCounter = timeCounter + 1
-
- if isConfirmed == False and isDisconnected:
- 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
- isDisconnected = False
- break
+ isConnected = False
+ isRinging = False
+ is486 = False
+ break
- if timeCounter == 12 and isDisconnected == False:
+ 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
- isDisconnected = False
+ isConnected = False
+ isRinging = False
+ is486 = False
break
else:
- print "REGISTRATION ERROR"
+ print "REGISTRATION ERROR!!!"
lib.destroy()
lib = None
acc = None
@@ -120,10 +140,10 @@ while userInput <> "quit":
userInput = sys.stdin.readline().rstrip("\r\n")
sleep(2)
-print "Deleting library and account info..."
+print "LOGGING OUT..."
acc.delete()
lib.destroy()
lib = None
acc = None
-print "Deleting was successful!"
+print "LOGOUT WAS SUCCESSFULL!!"