Interfacing SIM900A HTTP URL command sequence

Thread Starter

Vindhyachal Takniki

Joined Nov 3, 2014
594
1. I am interfacing SIM900A with MCU. Need to hit a http url (URL has data embedded into it, so I made it my code). This is to be repeated every 5 mins.

2. Here is initialization algo which I have written & implemented in C, this is done one time in code:
Code:
1. send_command("AT" , "OK" , 5000);   
If "Ok" not received or no response till 5000ms then send go to START,
else "OK" received then proceed

2. send_command("AT+CFUN=0" , "OK" , 5000);   
If "Ok" not received or no response till 5000ms then send go to START
else "OK" received then proceed

3. send_command("AT+CFUN=1" , "OK" , 5000);   
If "Ok" not received or no response till 5000ms then send go to START
else "OK" received then proceed

4. send_command("AT+CPIN?" , "READYOK" , 5000); 
If "READYOK" not received or no response till 5000ms then send go to START
else "READYOK" received then proceed

5. send_command("AT+HTTPTERM" , "OK" or "ERROR" , 5000);   
If no response for 5000ms then goto START
else if "OK" then proceed
else if "ERROR", then also proceed, it means that HTTP was terminated earlier also


6. send_command("AT+SAPBR=0,1" , "OK" or "ERROR" , 5000); 
If no response for 5000ms then goto START
else if "OK" then proceed
else if "ERROR", then also proceed, it means that GPRS was terminated earlier


7. send_command("AT+SAPBR=3,1,"Contype","GPRS"" , "OK" , 5000); 
If "OK" not received or no response till 5000ms then send goto START
else "OK" received then proceed

8. send_command("AT+SAPBR=3,1,"APN","airtelgprs.com"" , 5000);   
If "OK" not received or no response till 5000ms then send goto START
else "OK" received then proceed

9. send_command("AT+SAPBR=1,1" , 5000);   
If "OK" not received or no response till 5000ms then send goto START
else "OK" received then proceed


10. send_command("AT+SAPBR=2,1" , 5000);   
If "OK" not received or no response till 5000ms then send goto START
else "OK" received then proceed

11. send_command("AT+HTTPINIT" , 5000);   
If "OK" not received or no response till 5000ms then send goto START
else "OK" received then proceed


12. send_command("AT+HTTPPARA="CID",1" , 5000);   
If "OK" not received or no response till 5000ms then send goto START
else "OK" received then proceed


3.This is when I hit HTTP URL and read response, this is repeated in loop:

Code:
1. send_command("AT+HTTPPARA="URL","http://xxxxx" , 5000);   
If "OK" not received or no response till 5000ms then send goto HIT_HTTP_URL
else "OK" received then proceed


2. send_command("AT+HTTPACTION=0" , 5000);   
If "OK" not received or no response till 5000ms then send goto HIT_HTTP_URL
else "OK" received then proceed


3. send_command("AT+HTTPREAD" , 5000);   
If "XYZ" not received or no response till 5000ms then send goto HIT_HTTP_URL
else "XYZ" received then data success
//"XYZ"  is response read from server on successfully hitting the server

4. I have implemented in C with MCU and can see data hit on server which i can access

5. Is it right sequence or I am missing something in it? ANy code suggestion on it?
ANy missing command, or wrong timeouts?
 
Top