summaryrefslogtreecommitdiffstats
path: root/For Weekly Test
diff options
context:
space:
mode:
authoraa1112011-07-18 17:42:37 +0200
committeraa1112011-07-18 17:42:37 +0200
commitd1be948fa3480f6b71d3dcdaf3a17625ce2e2ce5 (patch)
tree35bcc3159cee5839f6d1d266e84173cfb15f6d08 /For Weekly Test
parentmoving the files. (diff)
parentMerge branch 'master' of lab.ks.uni-freiburg.de:lsfks/projekte/gsm-selftest (diff)
downloadgsm-selftest-d1be948fa3480f6b71d3dcdaf3a17625ce2e2ce5.tar.gz
gsm-selftest-d1be948fa3480f6b71d3dcdaf3a17625ce2e2ce5.tar.xz
gsm-selftest-d1be948fa3480f6b71d3dcdaf3a17625ce2e2ce5.zip
okMerge branch 'master' of lab.ks.uni-freiburg.de:lsfks/projekte/gsm-selftest
Conflicts: Handler/landlineCall.py
Diffstat (limited to 'For Weekly Test')
-rw-r--r--For Weekly Test/20-07-2011/Controller.py2
-rw-r--r--For Weekly Test/20-07-2011/Testing.py20
-rw-r--r--For Weekly Test/20-07-2011/classClient.py8
-rw-r--r--For Weekly Test/20-07-2011/classClient.pycbin2884 -> 2791 bytes
-rw-r--r--For Weekly Test/20-07-2011/classController.py8
-rw-r--r--For Weekly Test/20-07-2011/classController.pycbin5346 -> 5353 bytes
-rw-r--r--For Weekly Test/20-07-2011/landlineCall.py166
-rw-r--r--For Weekly Test/20-07-2011/landlineReceiver.py161
-rw-r--r--For Weekly Test/20-07-2011/sipCall.py21
9 files changed, 360 insertions, 26 deletions
diff --git a/For Weekly Test/20-07-2011/Controller.py b/For Weekly Test/20-07-2011/Controller.py
index a4e64f1..5d4367c 100644
--- a/For Weekly Test/20-07-2011/Controller.py
+++ b/For Weekly Test/20-07-2011/Controller.py
@@ -100,6 +100,8 @@ if dbStatus == 1:
else:
x = classController.test(sipCall, "localhost", "Box1", "132.0.0.2","404")
x.FuncTest()
+ print ""
+ sleep(10)
db.addResult(taskID, testResult)
if repeatTest == "true":
#select temporary table, if there are have test from gsmrz to sip then skip
diff --git a/For Weekly Test/20-07-2011/Testing.py b/For Weekly Test/20-07-2011/Testing.py
new file mode 100644
index 0000000..78d1a47
--- /dev/null
+++ b/For Weekly Test/20-07-2011/Testing.py
@@ -0,0 +1,20 @@
+import sys
+import os
+import time
+import MySQLdb
+import subprocess
+import signal
+
+import classClient
+import classDb
+import classPing
+
+from time import sleep
+
+num= "445"
+data = "start|"+num
+first = data[0:5]
+second = data[6:]
+print first
+print second
+print data
diff --git a/For Weekly Test/20-07-2011/classClient.py b/For Weekly Test/20-07-2011/classClient.py
index 625e48e..ce02d19 100644
--- a/For Weekly Test/20-07-2011/classClient.py
+++ b/For Weekly Test/20-07-2011/classClient.py
@@ -64,11 +64,3 @@ class Connection:
else:
return 0
-#MAIN PART
-x = Connection('localhost',50008)
-print x.connect()
-x.sendData('hello server :)')
-print x.receiveData()
-x.sendData('I send you another message')
-x.closeConnection()
-
diff --git a/For Weekly Test/20-07-2011/classClient.pyc b/For Weekly Test/20-07-2011/classClient.pyc
index 85f1aa7..9255493 100644
--- a/For Weekly Test/20-07-2011/classClient.pyc
+++ b/For Weekly Test/20-07-2011/classClient.pyc
Binary files differ
diff --git a/For Weekly Test/20-07-2011/classController.py b/For Weekly Test/20-07-2011/classController.py
index e26250d..f39aafb 100644
--- a/For Weekly Test/20-07-2011/classController.py
+++ b/For Weekly Test/20-07-2011/classController.py
@@ -161,9 +161,7 @@ class test:
print "Receiver handler : Ready"
print ""
- x.sendData("start")#send message to handler to start the call
- sleep(0.5)
- x.sendData(self.destNo)
+ x.sendData("start|"+self.destNo)#send message to handler to start the call
x.closeConnection()
x.connect()
@@ -194,9 +192,7 @@ class test:
#if failed, tell everybody to try one more time
if resultOrig == 486 or resultDest == 486:
- x.sendData("start")
- sleep(0.5)
- x.sendData(self.destNo)
+ x.sendData("start|"+self.destNo)
x.closeConnection()
x.connect()
diff --git a/For Weekly Test/20-07-2011/classController.pyc b/For Weekly Test/20-07-2011/classController.pyc
index 6abfa92..3104b8a 100644
--- a/For Weekly Test/20-07-2011/classController.pyc
+++ b/For Weekly Test/20-07-2011/classController.pyc
Binary files differ
diff --git a/For Weekly Test/20-07-2011/landlineCall.py b/For Weekly Test/20-07-2011/landlineCall.py
new file mode 100644
index 0000000..4741d13
--- /dev/null
+++ b/For Weekly Test/20-07-2011/landlineCall.py
@@ -0,0 +1,166 @@
+import sys
+import pjsua as pj
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop =False
+
+
+LOG_LEVEL=2
+current_call = None
+status = None
+
+
+# Logging
+def log_cb(level, str, len):
+ print str, "SIP log"
+
+
+# Receive events from account
+class MyAccountCallback(pj.AccountCallback):
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+
+# Receive events from Call
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+
+ def on_state(self):
+ global current_call
+ global status
+
+ if self.call.info().state <> pj.CallState.DISCONNECTED:
+ if self.call.info().state_text == "CONNECTING":
+ print "CONNECTING CALL"
+
+ print "CALL CONFIRMED and ESTABLISH", self.call.info().state_text
+ sleep(2)
+ #current_call.hangup()
+ status = 200
+ server.sendData(status)
+ else:
+ sleep(0.5)
+
+
+ if self.call.info().last_reason <> "":
+
+ if self.call.info().last_reason == "Busy Here":
+
+ print "486 Busy Here"
+ print ""
+ status = 486
+ server.sendData(status)
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+ print 'Current call Disconnected'
+
+#Function to make call
+def make_call(uri):
+ try:
+ print "Making call to", uri
+ cb=MyCallCallback()
+ return acc.make_call(uri, cb)
+ except pj.Error, e:
+ print "408 Request Time-out (Couldn't find the user in time) " + str(e)
+ return None
+
+
+
+
+lib = pj.Lib()
+while stop <> True:
+
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+ server = classServer.ServerHandler(50099)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+ try:
+ acc_cfg = pj.AccountConfig("sipgate.de","1289459","MMW9AX")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+ print my_sip_uri
+
+ server.sendData('ready')
+ print "Status: ", server.connected
+
+ while 1:
+ try:
+ data = server.receiveData()
+
+ if data == "start":
+
+ while 1:
+
+ num = server.receiveData()
+ if num <> "":
+
+ number = "sip:"+num+"@132.230.4.8"
+ current_call = make_call(number)
+ break
+
+ if data == "487":
+ stop = True
+ break
+
+ except ValueError:
+ print "813 General socket layer error: Failed send message"
+ server.closeConnection()
+ del server
+
+ server.closeConnection()
+ del server
+
+ else:
+ Regis_status= "Bad"
+ print "488 Not Acceptable Here"
+
+ lib.destroy()
+ lib = None
+ acc = None
+
+
+ server.closeConnection()
+ del server
+ except ValueError:
+ print "401 Unauthorized " + str(e)
+
+print "Goodbye"
+sleep(3)
+acc.delete()
+lib.destroy()
+server.closeConnection()
+del server
+lib = None
+acc = None
+
diff --git a/For Weekly Test/20-07-2011/landlineReceiver.py b/For Weekly Test/20-07-2011/landlineReceiver.py
new file mode 100644
index 0000000..0890f36
--- /dev/null
+++ b/For Weekly Test/20-07-2011/landlineReceiver.py
@@ -0,0 +1,161 @@
+import sys
+import pjsua as pj
+import string
+import classServer
+
+from time import sleep
+from datetime import datetime
+
+stop = False
+
+LOG_LEVEL=2
+current_call = None
+status = None
+global accept
+accept = None
+
+
+# Logging
+def log_cb(level, str, len):
+ print str, "SIP Handler Receiver Log"
+
+
+
+class MyAccountCallback(pj.AccountCallback):
+
+ global status
+
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ def on_incoming_call(self, call):
+ global current_call
+ global number
+
+ if current_call:
+ call.answer(486, "Busy")
+ return
+
+ number = call.info().remote_uri
+
+ current_call = call
+
+ call_cb = MyCallCallback(current_call)
+ current_call.set_callback(call_cb)
+
+ current_call.answer(180)
+ print "accept call"
+
+ if current_call <> None:
+ accept = True
+
+ if accept == True:
+ #sleep(0.5)
+ print "here"
+ current_call.answer(200)
+ sleep(1)
+ #current_call.hangup()
+ #status = 200
+ server.sendData('200')
+
+class MyCallCallback(pj.CallCallback):
+
+ def __init__(self, call=None):
+ pj.CallCallback.__init__(self, call)
+
+
+ def on_state(self):
+ global current_call
+ global success
+
+ if self.call.info().state == pj.CallState.CONNECTING:
+ print self.call.info().state_text
+ status = 200
+ #server.sendData('200')
+
+ if self.call.info().state == pj.CallState.DISCONNECTED:
+ current_call = None
+
+ print '701 The called party has hung up'
+
+
+lib = pj.Lib()
+
+try:
+
+
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
+
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+
+
+ lib.start()
+ lib.set_null_snd_dev()
+
+
+
+ try:
+ acc_cfg = pj.AccountConfig("sipgate.de","1289459","MMW9AX")
+ acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
+
+ if acc.info().reg_status < 700:
+
+ my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
+ server = classServer.ServerHandler(50106)
+ tried = server.openSocket()
+ print tried
+ server.sendData('ready')
+ server.closeConnection()
+ tried = server.openSocket()
+ while stop <> True:
+
+ data = server.receiveData()
+
+ if data == "487":
+ print "BYE BYE"
+ sleep(5)
+ stop = True
+ break
+
+ if current_call == None:
+ accept = None
+ continue
+ else:
+ accept = True
+ #print "Incoming call from :"
+ #current_call.answer(200)
+
+
+
+
+ transport = None
+ acc.delete()
+ acc = None
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+
+ else:
+ print "Bad Register"
+
+ lib.destroy()
+ lib = None
+ acc = None
+ server.closeConnection()
+
+
+ except pj.Error, e:
+ print "401 Unauthorized " +str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ lib.destroy()
+ lib = None
+ server.closeConnection()
+ del server
diff --git a/For Weekly Test/20-07-2011/sipCall.py b/For Weekly Test/20-07-2011/sipCall.py
index f41756d..a863ce8 100644
--- a/For Weekly Test/20-07-2011/sipCall.py
+++ b/For Weekly Test/20-07-2011/sipCall.py
@@ -24,7 +24,6 @@ class MyCallCallback(pj.CallCallback):
else:
sleep(0.5)
-
if self.call.info().last_reason == "Busy Here":
server.sendData('486')
@@ -73,17 +72,15 @@ while stop <> True:
while 1:
try:
data = server.receiveData()
-
- if data == "start":
-
- while 1:
-
- num = server.receiveData()
- if num <> "":
-
- number = "sip:"+num+"@132.230.4.8"
- current_call = make_call(number)
- break
+ event = data[0:5]
+ num = data[6:]
+ if event == "start" and num <> "":
+
+ server.closeConnection()
+ tried = server.openSocket()
+
+ number = "sip:"+num+"@132.230.4.8"
+ current_call = make_call(number)
if data == "487":
stop = True