summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortriatmoko2011-07-18 20:28:53 +0200
committertriatmoko2011-07-18 20:28:53 +0200
commit360f15d7b6fab7f6218c4cbad757cf1dbfb39059 (patch)
tree8aaf3b7780e4d6cd3a2835bf273283620c1d13bc
parentmodified for test weekly (diff)
downloadgsm-selftest-360f15d7b6fab7f6218c4cbad757cf1dbfb39059.tar.gz
gsm-selftest-360f15d7b6fab7f6218c4cbad757cf1dbfb39059.tar.xz
gsm-selftest-360f15d7b6fab7f6218c4cbad757cf1dbfb39059.zip
fix bug on localsip part.
-rw-r--r--For Weekly Test/20-07-2011/Controller.py4
-rw-r--r--For Weekly Test/20-07-2011/Testing.py38
-rw-r--r--For Weekly Test/20-07-2011/classController.py9
-rw-r--r--For Weekly Test/20-07-2011/classController.pycbin5466 -> 5434 bytes
-rw-r--r--For Weekly Test/20-07-2011/localsipReceiver.py106
-rw-r--r--For Weekly Test/20-07-2011/sipCall.py9
-rw-r--r--Handler/landlineReceiver.py8
-rw-r--r--Handler/sipCall.py14
8 files changed, 75 insertions, 113 deletions
diff --git a/For Weekly Test/20-07-2011/Controller.py b/For Weekly Test/20-07-2011/Controller.py
index 99cc11a..50c0f76 100644
--- a/For Weekly Test/20-07-2011/Controller.py
+++ b/For Weekly Test/20-07-2011/Controller.py
@@ -53,7 +53,7 @@ if dbStatus == 1:
sipGateServer = classPing.Ping('sipgate.de')
sipGateServerStatus = sipGateServer.ping(3)
- sipLocalServer = classPing.Ping('132.230.4.60')
+ sipLocalServer = classPing.Ping('132.230.252.228')
sipLocalServerStatus = sipLocalServer.ping(3)
# Fetch The task information from DB
@@ -130,7 +130,7 @@ if dbStatus == 1:
db.addResult(taskID, x.testResult)
if callTo == "localsip":
- if sipLocalSeverStatus == 0:
+ if sipLocalServerStatus == 0:
print "[failed] 500 Server Internal Error"
else:
diff --git a/For Weekly Test/20-07-2011/Testing.py b/For Weekly Test/20-07-2011/Testing.py
index 78d1a47..4a8a964 100644
--- a/For Weekly Test/20-07-2011/Testing.py
+++ b/For Weekly Test/20-07-2011/Testing.py
@@ -11,10 +11,34 @@ import classPing
from time import sleep
-num= "445"
-data = "start|"+num
-first = data[0:5]
-second = data[6:]
-print first
-print second
-print data
+command="--command=python sipCall.py"
+subprocess.Popen(args=["gnome-terminal", command])
+sleep(5)
+x = classClient.Connection("localhost", "50097")
+x.connect()
+origHandler = x.receiveData(0)
+print origHandler
+
+command="--command=python localsipReceiver.py"
+subprocess.Popen(args=["gnome-terminal", command])
+sleep(5)
+y = classClient.Connection("localhost", "50107")
+y.connect()
+
+while 1:
+ destHandler = y.receiveData(0)
+ if destHandler <> "":
+ break
+
+print destHandler
+
+if destHandler == "ready":
+ y.closeConnection()
+ y.connect()
+
+ #x.sendData("start|076120397897")
+while 1:
+ destHandlers = y.receiveData(0)
+ #origHandlers = x.receiveData(0)
+
+ print destHandlers#, origHandlers
diff --git a/For Weekly Test/20-07-2011/classController.py b/For Weekly Test/20-07-2011/classController.py
index 08f4e63..a9c5f82 100644
--- a/For Weekly Test/20-07-2011/classController.py
+++ b/For Weekly Test/20-07-2011/classController.py
@@ -78,8 +78,6 @@ class test:
print "Connecting to Caller handler", self.origAdd,self.portOrig
print "Caller handler status:", x.connect()
- x.sendData('hello Handler')
-
# wait respond from origin handler
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(60)
@@ -126,7 +124,7 @@ class test:
if self.dest == "landlineReceiver.py":
self.portDest = 50106
- if self.dest == "LocalSIPReceiver.py":
+ if self.dest == "localsipReceiver.py":
self.portDest = 50107
#mean external GSM
@@ -154,12 +152,13 @@ class test:
if destHandler == "ready":
print "Receiver handler : Ready"
- print ""
+ print "self.destNo"
+
x.sendData("start|"+self.destNo)#send message to handler to start the call
signal.signal(signal.SIGALRM, timeout_handler)
- signal.alarm(120)
+ signal.alarm(1200)
print "------------ Test Result ------------"
print ""
diff --git a/For Weekly Test/20-07-2011/classController.pyc b/For Weekly Test/20-07-2011/classController.pyc
index 5f32faa..c9e0996 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/localsipReceiver.py b/For Weekly Test/20-07-2011/localsipReceiver.py
index 96f058f..5739af2 100644
--- a/For Weekly Test/20-07-2011/localsipReceiver.py
+++ b/For Weekly Test/20-07-2011/localsipReceiver.py
@@ -1,134 +1,66 @@
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 success
-
- 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
+ current_call = call
+ print current_call
+
+ sleep(1)
+ call.answer(200)
- call_cb = MyCallCallback(current_call)
- current_call.set_callback(call_cb)
-
- current_call.answer(180)
- print "accept call"
+ sleep(0.5)
if current_call <> None:
- accept = True
-
- if accept == True:
- sleep(0.5)
- current_call.answer(200)
- sleep(1.5)
- current_call.hangup()
- status = 200
- server.sendData(success)
-
-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
-
- if self.call.info().state == pj.CallState.DISCONNECTED:
- current_call = None
- print '701 The called party has hung up'
+ print "hangup the call"
+ call.hangup()
+
+ print "send result"
+ server.sendData('200')
lib = pj.Lib()
+stop = False
try:
- server = classServer.ServerHandler(50104)
+ server = classServer.ServerHandler(50107)
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()
- lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+ lib.init(log_cfg = pj.LogConfig(level=1, 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("132.230.252.228", "4976120397897", "hB8M3WyFt61C")
acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
-
+ print acc.info().reg_status
if acc.info().reg_status < 700:
- my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
-
server.sendData('ready')
-
+ server.closeConnection()
+ tried = server.openSocket()
while stop <> True:
- data = server.receiveData()
+ data = server.receiveData(0)
if data == "487":
stop = True
break
-
- if current_call == None:
- accept = None
- continue
- else:
- print "Incoming call from :", number
-
-
+ sleep(3)
-
transport = None
acc.delete()
acc = None
diff --git a/For Weekly Test/20-07-2011/sipCall.py b/For Weekly Test/20-07-2011/sipCall.py
index 7cbbf4c..2ca7b14 100644
--- a/For Weekly Test/20-07-2011/sipCall.py
+++ b/For Weekly Test/20-07-2011/sipCall.py
@@ -16,7 +16,7 @@ class MyCallCallback(pj.CallCallback):
if self.call.info().state <> pj.CallState.DISCONNECTED:
if self.call.info().state_text == "CONNECTING":
print "CALL : ", self.call.info().state_text
- sleep(1.5)
+ sleep(5)
if self.call.info().state <> pj.CallState.DISCONNECTED:
print "will Hangup call"
current_call.hangup()
@@ -70,17 +70,22 @@ while stop <> True:
server.sendData('ready')
print "Status: ", server.connected
-
+ sleep(10)
while 1:
try:
data = server.receiveData(0)
+ #data = 334
+ #event = "start"
+ #num = "076120397897"
event = data[0:5]
num = data[6:]
+ print event
if event == "start" and num <> "":
print "Make a call to :", num
number = "sip:"+num+"@132.230.4.8"
current_call = make_call(number)
+ sleep(19)
if data == "487":
stop = True
diff --git a/Handler/landlineReceiver.py b/Handler/landlineReceiver.py
index f61ff6a..470b4c6 100644
--- a/Handler/landlineReceiver.py
+++ b/Handler/landlineReceiver.py
@@ -14,15 +14,17 @@ class MyAccountCallback(pj.AccountCallback):
def on_incoming_call(self, call):
current_call = call
-
- sleep(0.5)
+
+ sleep(1)
call.answer(200)
sleep(0.5)
if current_call <> None:
+ print "hangup the call"
call.hangup()
+ print "send result"
server.sendData('200')
@@ -50,7 +52,7 @@ try:
while stop <> True:
- data = server.receiveData()
+ data = server.receiveData(0)
if data == "487":
stop = True
diff --git a/Handler/sipCall.py b/Handler/sipCall.py
index a863ce8..7cbbf4c 100644
--- a/Handler/sipCall.py
+++ b/Handler/sipCall.py
@@ -16,10 +16,12 @@ class MyCallCallback(pj.CallCallback):
if self.call.info().state <> pj.CallState.DISCONNECTED:
if self.call.info().state_text == "CONNECTING":
print "CALL : ", self.call.info().state_text
- sleep(1)
+ sleep(1.5)
if self.call.info().state <> pj.CallState.DISCONNECTED:
+ print "will Hangup call"
current_call.hangup()
-
+
+ print "send result"
server.sendData('200')
else:
sleep(0.5)
@@ -71,14 +73,12 @@ while stop <> True:
while 1:
try:
- data = server.receiveData()
+ data = server.receiveData(0)
event = data[0:5]
num = data[6:]
if event == "start" and num <> "":
-
- server.closeConnection()
- tried = server.openSocket()
-
+
+ print "Make a call to :", num
number = "sip:"+num+"@132.230.4.8"
current_call = make_call(number)