import MOD
import SER
SER.set_speed('9600','8N1')
print "Start"
timerstart = MOD.secCounter()
print (timerstart)
a = SER.send('ATE\r')
a = SER.receive(1)
#print (a)
a = SER.send('AT#GPRS=0\r')
a = SER.receive(10)
print "connecting..."
a = SER.send('AT#GPRS=1\r')
a = SER.receive(10)
print (a[7:20])
a=SER.send('AT#GPRS?\r')
res = SER.receive(1)
print (res[9])
if (res[9])=='1':
print( 'connect!' )
while (res[9])=='1':
a=SER.send('AT#GPRS?\r')
res = SER.receive(1)
MOD.sleep(50)
print "disconnect"
timerend = MOD.secCounter()
print (((timerend-timerstart)/60), 'min')