PDA

View Full Version : Can't read an sms Using TC35i & 16F690



financecatalyst
- 1st October 2009, 09:59
Hi Everyone
I am now able to send text messeges using my TC35i & PIC16F690. New Problem, I am unable to read an sms. Here is my code:
rea:
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,rea,[WAIT("OK")]
HIGH LED
PAUSE 1000
LOW LED
serout2 tx,baud,["AT+CMGR=1",13]
Serin2 rx,baud,5000,rea,[WAIT("REC UNREAD"),skip 3, STR num\12,skip 27,STR sms\10] 'CODE NEVER MOVES FORWARD FROM HERE
HIGH LED
PAUSE 1000
LOW LED
if sms[0]="t" and sms[1]="e" and sms[2]="s" and sms[3]="t" then
goto done
ELSE
goto rea
ENDIF


done:
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,main,[WAIT("OK")]
HIGH LED
PAUSE 1000
LOW LED
serout2 tx,baud,["AT+CMGS=",34,"XXXXMY NUMBERXXXX",34,13]
Serin2 rx,baud,5000,main,[WAIT(">")]
PAUSE 500
SEROUT2 tx,baud,["done",26]
goto rea

aratti
- 1st October 2009, 14:27
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.



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)



Delete_Sms:
serout2 tx,baud,["AT+CMGD=1",13] ' Delete sms from memory position 1
RETURN


Al.

financecatalyst
- 1st October 2009, 15:01
Hi Aratti, thanks for the answer.
Unfortunately the code still stands still at main function. I am attaching the main code here:

start:
GOSUB ONE
serout2 tx,baud,["AT+CMGD=1",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
goto one
goto main


main:
gosub two
serout2 tx,baud,["AT^SMGR=1",13]
Serin2 rx,baud,5000,main,[WAIT("REC UNREAD")] ' Removed all STR statements to get it to work
goto start
one:
for c=1 to 10
portc=255
pause 20
portc=0
pause 20
next c
return
two:
for c=1 to 5
portc=255
pause 400
portc=0
pause 400
next c
return

aratti
- 1st October 2009, 15:37
I suspect that you have few "Rec Read" message in memory. Delete them all and than send a new one and try again your code.

Since you don't know how many sms are stored them loop several time with the "AT+CMGD=1",13 , wait for the "OK", leave a pause 5000 and repeat.

Al.

financecatalyst
- 1st October 2009, 20:56
I suspect that you have few "Rec Read" message in memory. Delete them all and than send a new one and try again your code.

Since you don't know how many sms are stored them loop several time with the "AT+CMGD=1",13 , wait for the "OK", leave a pause 5000 and repeat.

Al.

Hi, I actually inserted the sim in my mobile, deleted all text messeges from the sim and still having the same bad luck. Just to let you know, that I am using internet to send the text messeges (if that makes any difference).
Is there any way I can point an incomming sms to be stored in location one?
Is there any command I may be missing pointing to where the sms goes?

Thanks

aratti
- 1st October 2009, 23:07
You must delate also sms present in the modem (TC35i memory). Follow my advice given in previous post.

First sms goes in position 1; second in position 2; etc. etc. This is way you must keep the modem memory clean deleting sms as soon as they have been read, so incoming sms are always stored in position 1.

Al.

financecatalyst
- 1st October 2009, 23:30
Hi Aratti
Tried deleting from location 1 to 9. Results are the same, the code can't seem to see REC UNREAD. Any other trick you suggest? :)

financecatalyst
- 2nd October 2009, 00:52
Here is the code at Present:
main:
serout2 tx,baud,["AT^SMGR=1",13]
Serin2 rx,baud,5000,main,[WAIT("REC UNREAD")]
portc=255
End
start:
gosub one
serout2 tx,baud,["AT+CMGD=1",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=2",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=3",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=4",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=5",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=6",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=7",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=8",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGD=9",13]
serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
gosub one
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,start,[WAIT("OK")]
pause 1000
goto one
goto main

financecatalyst
- 2nd October 2009, 02:21
Additional information:

main:
serout2 tx,baud,["AT^SMGR=1",13] ' I have tried it with AT+CMGR=1
Serin2 rx,baud,5000,main,[WAIT("REC UNREAD")] ' I have tried this string with REC READ, STO UNSENT, STO SENT - Nothing works!
portc=255
end

aratti
- 2nd October 2009, 09:44
Try to short the qualifier string and maintain the same AT comand:



serout2 tx,baud,["AT^SMGR=1",13]
Serin2 rx,baud,5000,main,[WAIT("UNREAD")]


Al.

financecatalyst
- 2nd October 2009, 15:15
Try to short the qualifier string and maintain the same AT comand:



serout2 tx,baud,["AT^SMGR=1",13]
Serin2 rx,baud,5000,main,[WAIT("UNREAD")]


Al.

Finally one step forward: The following code worked but of course this is not the target... but dont know where to go from here to check the messege and check the content & number...
main:
gosub two
serout2 tx,baud,["AT+CMGR=1",13]
Serin2 rx,baud,40000,main,[WAIT("+CMGR")]
portc=255
end

aratti
- 2nd October 2009, 15:36
Finally one step forward: The following code worked but of course this is not the target... but dont know where to go from here to check the messege and check the content & number...

Now you need hyperterminal. You will download a typical sms on the screen and then you can count where the data that interest you commence, so you can plan the number of skips, their dimention as well as the string that should capture your data.

The other way is to use a large array and sent it to a LCD to do the same job.

Al.

financecatalyst
- 2nd October 2009, 17:29
Ok, Downloaded the hyperterminal for vista and bought the serial to usb cable.
Progress:
Checked all locations using at+cmgl=" REC READ", "REC UNREAD" STO SENT & UNSENT.
All show no sign of an remaining sms.

After that:

Sent an sms to my phone. Did at+cmgr=1, but it shows +cmgr: 0, ,0
Then I did at+cmgl="REC UNREAD" - - - Result is only OK ( No sign of an received sms at all.

What settings should be used for CPMS & CNMI?
I have got cpms as sm, sm, sm & CNMI as 2,0,0,1 - Are these correct?

financecatalyst
- 2nd October 2009, 18:40
Its working now: this is what I did:

CNMI=00001
CNMS=me, me, mt ' stores and reads from TA memory & NOT sim

What I would like to do is change it to store, read, delete from sim only. I know I have to change CNMS=SM, SM, SM but for this to take effect I need help in changing value of CNMI (Which I am unable to figure out)
Any advise on CNMI values?

Thanks

aratti
- 4th October 2009, 22:41
Any advise on CNMI values?



I have never used the sim memory. There are problem with the reading of incoming sms.

It will work pretty well with "MT". Remember that you will delete the sms immediatly after reading it. Otherwise you will not be able to locate it.

Al.