Thank you for your reply.
I didnt include the AT+SKTD in my quote because I know that part works - if I type it manually in Hpyerterminal then I see the html of the page but if I do the exact same thing in code I get nothing. Thats why I thought it must be an incorrect formatting of the GET request - the only difference between typing it out in hyperterminal and writing it in code is how the now lines are sent - Hyperterm is ctrl-J and ctrl-M whereas python is either \r\n or sendbytes.
The host part of the request is an addition to the http protocol from version 1.1 onwards and doesnt exist in http/1.0 so it is not required to send this. As I am trying to send as little data as possible it is not included and using RSTerm to send the request, also without the host part of the header, returns the html of the web page with no problems.
I have tried it with the newlines as \r\n and that doesnt work, ive tried it using sendbytes and that doesnt work, ive tried using \r at the end of send and also sendbytes for the actual newlines and that doesnt work, I just dont know what the correct way of sending the GET request to the device is, with the new lines. The actual GET request itself should work as I have tested it with RSTerm and Hyperterm.
In total, what I am doing is this:
#includes
import MOD
import MDM
import GPS
#globals
run = 0
#functions
def init():
#if(run==0):
MDM.send('AT\r',0)
# r = MDM.receive(10)
# if r == '\r\nOK\r\n': return 1
# else: return 0
#if(run==1):
#MDM.send('AT+CPIN?\r',0)
#r = MDM.receive(10)
#if r = ready
#return 1
#else
#send at+cpin=xxxx
#receive OK?
#return 1
#else
#return 0
#if(run==2):
MDM.send('AT+CGATT=1\r',0)
r = MDM.receive(10)
# if(r == '\r\n+CGATT: 1\r\n'): return 1
# else: return 0
#if(run==3):
#initialise GPS
#pass
#if(run==4):
MDM.send('AT+CGDCONT=1,"IP","pp.vodafone.co.uk"\r',0)
r = MDM.receive(10)
# if r == '\r\nOK\r\n': return 1
# else: return 0
#if(run==5):
MDM.send('AT#USERID=web\r',0)
r = MDM.receive(10)
# if(r == '\r\nOK\r\n'): return 1
# else: return 0
#if(run==6):
MDM.send('AT#PASSW=web\r',0)
r = MDM.receive(10)
# if(r == '\r\nOK\r\n'): return 1
# else: return 0
#if(run==7):
MDM.send('AT#GPRS=1\r',0)
r = MDM.receive(10)
# if(r == '\r\nERROR\r\n'):
# run = 4
# return 0
# else: return 1
return 1
def sync():
MDM.send('AT#SKTD=0,80,"mywebserv.com"\r',0)
#r = MDM.receive(20)
#while(r.find('CONNECT')==-1):
MOD.sleep(120)
# r = MDM.receive(20)
MDM.send('GET /gps/index.php?s=50 HTTP/1.0\r',0)
MDM.sendbytes(0x0D,0)
MDM.sendbytes(0x0A,0)
MDM.send('Connection: close\r',0)
MDM.sendbytes(0x0D,0)
MDM.sendbytes(0x0A,0)
MDM.sendbytes(0x0D,0)
MDM.sendbytes(0x0A,0)
#r = MDM.receive(20)
#while(r.find('\r\nContent-Length\r\n')==-1):
# MOD.sleep(30)
# r = MDM.receive(20)
#main code
#while run <= 7:
# if(init()==1):
# run=run+1
init()
run = 1
while run:
sync()
#set timer
MOD.sleep(30000);
run = 0
As you can see most of it is commented out as I was not sure my error checking was working correctly. If I get the device to send an SMS to my phone before the AT#SKTD then I receive it so I know it is executing the code to get the web page, but it just doesnt work - again making me think it is the newlines in the GET request being wrong.