I have a
sim908 shield and I'm trying to send some data periodically to a server using
For every command, I wait for the response to check if everything is working.
Actually the sketch works but, often, I noticed errors during http request.
State of the art:
Here it is the sequence of AT commands (not the entire code) into the loop:
1) Check the Network Registration and, if necessary, wait
2) Set params for GPRS connection (no user or password required)
3) Get current bearer
4) If bearer == 0,0,0,0 (not assigned) get a new bearer
5) Init HTTP
6) Set CID and URL
7) Execute the HTTP command (POST)
8) Close HTTP connection
Why HTTP init (step 5) or HTTP posting (step 7) often fails? What is wrong in this procedure? I'm missing something? There is a way to make the procedure more stable?
Thank you in advance :)
If occurs an error during sending data via HTTP, is a great idea to renew the bearer (step 4)
Answers to the comments:
a) Shield has an antenna and it works. If I try to disconnect the antenna, code still search the network (step 1) untill I reconnect the antenna.
b) Some times I have this error initializing HTTP (step 5):
+CME ERROR: 3
Some times I have only "OK" as response posting data (step 7) instead of:
Or this response:
c) I have error at step 4 (AT+SAPBR=1,1) only if I execute the command when I have yet a bearer. The error in this case is:
+CME ERROR: 3
For this reason I do a check (step 3)