i am trying to write a program in phyton which is running on a GT864-PY the program schould be able to download a webpage (code) with gprs and after this sending the data out on the serial port…the problem is, i am getting just an OK but nothing more
any help is useful
import the built-in modules
import MDM
import MOD
import SER
TIMEOUT_REG = 100
TIMEOUT_MINIMUM = 5
HTML_UC_END = ‘ENDSOURCETABLE’
ACTIVE_CHECK = ‘OK’
################## FUNCTION DEFINITION ####################
#returns data downloaded in a duration of time equal to TIMEOUT_DWNLD
def GetData():
data = ’ ’
timer = MOD.secCounter()
timeout = MOD.secCounter() + 300
datatmp = MDM.receive(400)
while ((datatmp.find(HTML_UC_END) == -1) and (timer > 0) ):
data = data + datatmp
datatmp = MDM.receive(50)
timer = timeout - MOD.secCounter()
if ((datatmp.find(HTML_UC_END) != -1)):
data = data + datatmp
else:
data = ’ ’
return data
a = MDM.send(‘at#cmuxscr=0\r’,0)
a = SER.set_speed(‘115200’,‘8N1’)
a = MDM.send(‘AT\r’,0)
activeCheck = MDM.receive(10)
if(activeCheck.find(ACTIVE_CHECK)!=-1):
a = SER.send(‘On\r\n’)
else:
a = SER.send(‘Off\r\n’)
activates GPRS
a = MDM.send(‘AT#GPRS=1\r’)
a = MDM.receive(TIMEOUT_REG)
a = MDM.send(‘AT+cpin=“xxxx”\r’,0)
a = MDM.receive(TIMEOUT_REG)
a = MDM.send(‘AT+CGDCONT=1,“IP”,internet.t-mobile\r’,0)
a = MDM.receive(TIMEOUT_REG)
a = MDM.send(‘AT#USERID=“tm”\r’,0)
a = MDM.receive(TIMEOUT_REG)
a = MDM.send(‘AT#PASSW=“tm”\r’,0)
a = MDM.receive(TIMEOUT_REG)
a = MDM.send(‘AT#SKTSET = 0,xxxx,“www.apage.com”\r’,0)
a = MDM.receive(TIMEOUT_REG)
a = MDM.send(‘AT#SKTSAV\r’,0)
a = MDM.receive(4*TIMEOUT_MINIMUM)
a = MDM.send(‘AT#SKTOP\r’,0)
timer = MOD.secCounter()
timeout = MOD.secCounter() + 100
res = MDM.receive(TIMEOUT_MINIMUM)
res = res.find(‘CONNECT’)
while ((res == -1)and (timer > 0) ):
res = MDM.receive(TIMEOUT_MINIMUM)
res = res.find(‘CONNECT’)
timer = timeout - MOD.secCounter()
if ( res != -1 ):
a = SER.send(‘Connected’,0);
a = MDM.send(‘GET / HTTP/1.1\r\n’,0)
a = MDM.receive(TIMEOUT_MINIMUM)
a = MDM.send(‘Connection: keep-alive\r\n’,0)
a = MDM.send(‘\r\n\r\n\r\n\r\n’,0)
data = ’ ’
a = MDM.receive(4*TIMEOUT_MINIMUM)
data = GetData()
if (data!=’ '):
a = SER.send(data,0);
else:
a = SER.send(‘Fehler’,0);
else:
a = SER.send(‘Keine Verbindung’,0);
a = MDM.send(‘+++\r’,0)