0

I am trying to send a HTTP GET operation using the SIM5218 modem via 3G. I have already managed to send that request while using minicom. Here is the command I used :

at+netopen=,,1
at+chttpact="mywebsite.com",80
GET /myscript.py?var=varTest HTTP/1.0 
<ctrl-m><ctrl-j><ctrl-m><ctrl-j> <ctrl-Z>

Now I want the SIM5218 to do the same request with a lua script.

printdir(1)
str='GET /myscript.py?var=Testlua HTTP/1.0\r\n\r\n'
sio.send('at+chttpact="mywebsite.fr",80')
rtc=sio.recv(5000)
sio.send(str);
sio.send(string.char(0x1A))
sio.send(string.char(0x00))
rtc=sio.recv(5000)
print(rtc);

This is not working, I know that I have to send my GET in a different way but I don't know how.

Thanks in advance.

greatwolf
  • 20,287
  • 13
  • 71
  • 105

1 Answers1

0

Maybe this will be helpful:

1) Set APN: AT+CGSOCKCONT=1,"IP","internet.someprovider.zz"

This command should return OK

2) Set auth info for your APN: AT+CSOCKAUTH=1,2,"user","password"

In my case I use CHAP (2)

3) Open network: AT+NETOPEN=,,1

4) After that you can check if PDP is activated by running command: AT+IPADDR

5) Open connection: AT+CHTTPACT="mywebsite.com",80

This command should return +CHTTPACT: REQUEST

6) I always use HTTP/1.1. So request should look like this: request='GET /someRelativeUri HTTP/1.1\r\nHost: www.mywebsite.com\r\n\r\n'

7) Send command by pressing Ctrl+Z (0x1A)

sio.send(request .. string.char(0x1A))

8) Read response, timeout is 30 seconds: response=sio.recv(30000)

If all is OK, then response should contain substring "+CHTTPACT: 0"

Andrew Karpov
  • 431
  • 2
  • 7