I am trying to send data through GPRS via SIM300 modem. The logic of my program should be. 1) it should send the data till it receives "dieman" from the server. 2) the modem is such that after every command there is a reply. 3) all the communication takes place serially.
Firstly the GPRS commands as tried in hyperterminal
AT OK AT+CGATT=1 OK AT+CGDCONT=1,"IP","airtelgprs.com" OK AT+CSTT="airtelgprs.com","","" OK AT+CIICR OK AT+CIFSR 212.22.22.22 //EG OF AN IP ADDRESS AT+CIPSTART="TCP",""80"">http://www.google.com","80" OK CONNECT OK AT+CIPSEND >THIS IS THE DATA I WANNA SEND // YOU CAN SEND THE DATA VIA GPRS NOW [CTRL+Z] SEND OK
this is what i want to implement in C in 8052. here OK are the response from the modem.
now i implemented the C version but my code is very inefficient. I could have ignored the response from the modem by simply inserting delays but i want my code such that if the reply from the modem is not "OK" it should transmit the command again.
No, that would be a very bad idea indeed!
See my comment on "Arbitrary delays" in this thread: http://www.keil.com/forum/18684/
"i want my code such that if the reply from the modem is not "OK" it should transmit the command again"
That isn't a very good idea, either!
You should really make some attempt to determine the reason for the failure and, from that, determine what recovery action is appropriate.
As also mentioned in the above-mentioned thread, look-up AT+CMEE in your AT Commands manual...
OK, if i use the above code with improved quality of names assigned to variables is the code fine. And for generating a delay if i use TIMER in 8051. then is the problem solved.
is my logic for checking whether OK is received is correct?
No.
Walk through it by hand - with pencil and paper.
Or use the simulator.
The first usage might work - but what about the 2nd and subsequent...?
As Per said, what about echo from the modem?
Again, you are using arbitrary delays to guess when the response is complete...
See: http://www.keil.com/forum/18568/
View all questions in Keil forum