Code:
Ini:
Flag=0
Count=Count+1
if Count > 10 then Error ' Modem doesn' t answer exit to error label
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,Ini,[WAIT("OK")]
Flag=1 ' Modem OK Flag setted to 1
serout2 tx,baud,["AT+CPMS=MT",13] ' set the phone memory to read
Return
AT+CMGF=1 set the modem to work in text mode (0= PDU mode), so you don't need to repeat this AT command several times. I suggest you to use a subroutine and call it only at the begining (set count = 0). Next thing you need to do is to tell to the modem which memory you will use for sms recording. Also this AT command is needed only once.
Code:
SMS:
serout2 tx,baud,["AT^SMGR=1",13]
Serin2 rx,baud,5000,SMS,[WAIT("REC UNREAD"),skip 3, STR num\12,skip 27,STR sms\10]
Here I start from the assumption that the skips are corrected, if not the risk is that the modem has sent all the data, but SERIN2 has not filled the strings and wait forever for other data that will never be transmitted. So this could be the answer to your statement: CODE NEVER MOVES FORWARD FROM HERE
Finally, as soon as you have read the incoming sms you should delate it to free the memory space ( if not second incoming sms will be placed in position 2, while you call for sms in position 1)
Code:
Delete_Sms:
serout2 tx,baud,["AT+CMGD=1",13] ' Delete sms from memory position 1
RETURN
Al.
Bookmarks