summaryrefslogtreecommitdiffstats
path: root/Handler/gsmincom_.py
diff options
context:
space:
mode:
Diffstat (limited to 'Handler/gsmincom_.py')
-rw-r--r--Handler/gsmincom_.py135
1 files changed, 0 insertions, 135 deletions
diff --git a/Handler/gsmincom_.py b/Handler/gsmincom_.py
deleted file mode 100644
index 0c0d5a3..0000000
--- a/Handler/gsmincom_.py
+++ /dev/null
@@ -1,135 +0,0 @@
-import sys
-import pjsua as pj
-import socket
-import time
-import os
-import string
-import classServer
-
-from time import sleep
-from datetime import datetime
-
-stop ="false"
-
-
-success = ""
-
-
-
-
-try:
-
- global ser
- portAddress = '/dev/ttyACM0'
- portName = portAddress[-4:]
- portExist = os.popen('dmesg | grep ' + portName).read()
-
-
- ser = Serial(
- port=portAddress,
- baudrate=19200,
- bytesize=EIGHTBITS,
- parity=PARITY_NONE,
- stopbits=STOPBITS_ONE)
- ser.open()
-
- server = classServer.ServerHandler(50105)
- 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()
-
-
- print "here:", server.connected
-
-
- if server.connected == 1:
-
- server.sendData('I am ready')
-
- while stop <> "true":
-
- data = server.receiveData()
- if data == "terminated":
- print "I will", data
- break
-
- buffer = buffer + ser.read(ser.inWaiting())
- if '\n' in buffer:
- lines = buffer.split('\n')
- last_received = lines.pop(0)
-
- buffer = '\n'.join(lines)
-
- last_received=last_received.split('\n')
- line = last_received[0].replace(chr(13), '')
-
-
- if len(line) > 0:
-
- if line=='RING':
- if pickUp == 0:
-
- print "Somebody calling"
- sleep(1)
- ser.write('ATA\r')
-
- sleep(1)
- ser.write('AT+CSQ\r')
-
- sleep(2)
- ser.write('AT+CLCC\r')
- line=''
-
- if line[0:5] == '+CSQ:':
-
- space = int(string.find(line,' '))+1
- coma = int(string.find(line,','))
- signalStr = (int(line[space:coma])*2)-113
-
- line=''
-
- if line[0:6]=='+CLCC:':
-
- pickUp = 1
-
- print "I will hangup the call"
- sleep(5)
-
- ser.write('AT+CHUP\r')
- pickUp = 0
-
- quotation1 = int(string.find(line,'"'))+1
- lineTemp = line[quotation1:]
-
- quotation2 = int(string.find(lineTemp,'"'))
- numberOfCaller = line[quotation1:quotation1+quotation2]
-
- server.sendData('I got call from' +numberOfCaller)
- print "caller number", numberOfCaller
- sleep(1)
- server.sendData('success')
- sleep (3)
- ser.close()
-
-
- server.closeConnection()
- del server
- else:
-
- print "not connected"
-
- del server
-
- ser.close()
-except ValueError:
- print "Exception: " + str(e)
- server.closeConnection()
- del server
-
-print "GOODBYE"
-sleep(5)