summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--notFinishedCode/serverHandler.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/notFinishedCode/serverHandler.py b/notFinishedCode/serverHandler.py
index 7fe5e51..956d565 100644
--- a/notFinishedCode/serverHandler.py
+++ b/notFinishedCode/serverHandler.py
@@ -106,14 +106,17 @@ def receiveMessage(timeout):
logger.logEvent('RECEIVER READY SENT')
else:
logger.logEvent('$receiver ready not sent: ' + str(outcome))
+ return 7
elif message == 'RECEIVE START' and lastState == 2:
outcome = receiveStart()
print 'outcome ' + str(outcome)
if outcome == 1:
logger.logEvent('RECEIVE STATUS REPORTED')
+ return 2
else:
logger.logEvent('$receive status not reported: ' + str(outcome))
+ return 3
elif message[0:6] == 'CALLER' and lastState == 1:
outcome = initCaller()
@@ -124,14 +127,17 @@ def receiveMessage(timeout):
logger.logEvent('CALLER READY SENT')
else:
logger.logEvent('$caller ready not sent: ' + str(outcome))
+ return 6
elif message == 'CALL START' and lastState == 4:
outcome = callStart(numberToCall)
print 'outcome ' + str(outcome)
if outcome == 1:
logger.logEvent('CALLER STATUS SENT')
+ return 4
else:
logger.logEvent('$caller status not sent: ' + str(outcome))
+ return 5
elif message == 'TERMINATE CONNECTION' and (lastState == 5 or lastState == 3):
outcome = terminateConnection()
@@ -207,7 +213,7 @@ def receiveStart():
########CALL PART########
def initCaller():
- print 'initCaller'
+ print 'initCaller1'
#initialize caller here
global lastState
@@ -216,7 +222,7 @@ def initCaller():
return sendMessage
def callStart(numberToCall):
- print 'initCaller'
+ print 'initCaller2'
#call the number here
global lastState
@@ -291,14 +297,20 @@ while 1:
if test == 1:
print 'initialized system'
receivedMessage = 0
- while receivedMessage < 4 and resetState!= 1:
- receivedMessage += receiveMessage(30)
+ while receivedMessage < 8 and resetState!= 1:
+ if receivedMessage == 4 or receivedMessage == 5 or receivedMessage == 2 or receivedMessage == 3:
+ receivedMessage = receiveMessage(10)
+ else:
+ receivedMessage = receiveMessage(30)
elif test ==2:
print 'initialized system but device not working'
logger.logEvent('initialized system but device not working')
receivedMessage = 0
while receivedMessage < 4 and resetState!= 1:
- receivedMessage += receiveMessage(30)
+ if receivedMessage == 4 or receivedMessage == 5 or receivedMessage == 2 or receivedMessage == 3:
+ receivedMessage = receiveMessage(10)
+ else:
+ receivedMessage = receiveMessage(30)
elif test ==0:
print 'nobody can connect, reboot board, restart cellphone'