Sim900

friis

Senior Member
Hi,
I have the following piece of code:

Code:
sertxd ("QQQQ",cr,lf)

sertxd (#ptr," ",#hSerPtr,cr,lf)

hSerOut 0, ( "AT+CMGL=",$22,"ALL",$22,cr)
pause 2000
do while ptr <> hSerPtr
b0 = @ptrInc
sertxd (#ptr," ",#hSerPtr,cr,lf)
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop

 sertxd ("PPPP",cr,lf)
to which I get the following answer:

QQQQ
145 145
146 165
Rx 65 "A"
147 165
Rx 84 "T"
148 165
Rx 43 "+"
149 165
Rx 67 "C"
-
-
-
-
160 165
Rx 13 "
"
161 165
Rx 10 ""
162 165
Rx 79 "O"
163 165
Rx 75 "K"
164 165
Rx 13 "
"
165 165
Rx 10 ""
PPPP
Rx 65 "A"
Rx 84 "T"
Rx 43 "+"
Rx 67 "C"
Rx 77 "M"

Why does it continue writing after "PPPP" - it should continue with the pgm? I haveused the same piece of code in a previous part of the pgm without any problems.
Can anyone help?
best regards
torben
 

hippy

Ex-Staff (retired)
Why does it continue writing after "PPPP" - it should continue with the pgm?
There's no subsequent "QQQQ" and it's not printing the '#ptr,#hSerPtr' numbers, so it doesn't seem it is the code shown which is printing after the "PPPP". Without knowing what the code is after the "PPPP" or in full it's hard to tell.

One technique to debug issues like this is to add a unique marker at the start of all SERTXD then you can tell which is printing what ...

sertxd( "[1]", ..... )
 

friis

Senior Member
Hi hippy,
Sorry to have bothered you with that. I screwed up but your remark about numbering the text messages help me.
But I have had a lot of problems with AT commands. Now I can send SMS to my IPHONE from the SIM900, but I get very few SMS through to SIM900 from my IPHONE - although at a time it was not so. I have asked the phone company to trace my SMS.
Thank you very much.
torben
 

hippy

Ex-Staff (retired)
Could it be that some SMS messages that were sent to it have not been read and are still hanging around in the SIM Card memory, are causing more recent messages to be ignored or lost ?

SMS is a non-guaranteed services so, while messages usually will arrive, some might not. I am not sure what SMS offers by way of delivery confirmation or notification if not. Hopefully phone company tracing will reveal what's happening. It might be worth trying to send from some other phone, see if they are more reliable.
 

friis

Senior Member
Hi hippy,
please find below a piece of code with its accompanying ouitput:

[CODE
#PICAXE 28X2
#Terminal 19200
#No_table
#No_data
pause 2000

Code:
PowerOnReset:
setfreq m16
SerTxd( Cr, LF, "Started PowerOnReset", CR, LF )
hSerSetup B115200_16,%001

sertxd (#ptr," ",#hSerPtr,cr,lf)
hSerOut 0, ( "AT",cr)
pause 200
do while ptr <> hSerPtr
b0 = @ptrInc
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop

sertxd (#ptr," ",#hSerPtr,cr,lf)

if ptr <> 9 then
sertxd ("Connecting",cr,lf)
high c.4
pause 5000
low c.4
pause 30000
endif

sertxd (#ptr," ",#hSerPtr,cr,lf)
hSerOut 0, ( "AT+CMGD=0,4",cr)
pause 200
do while ptr <> hSerPtr
b0 = @ptrInc
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop

sertxd (#ptr," ",#hSerPtr,cr,lf)
hSerOut 0, ( "AT+CPIN?",cr)
pause 200
do while ptr <> hSerPtr
b0 = @ptrInc
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop

sertxd (#ptr," ",#hSerPtr,cr,lf)
hSerOut 0, ( "AT+CREG?",cr)
pause 200
do while ptr <> hSerPtr
b0 = @ptrInc
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop

sertxd (#ptr," ",#hSerPtr,cr,lf)
hSerOut 0, ( "AT+COPS?",cr)
pause 200
do while ptr <> hSerPtr
b0 = @ptrInc
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop

sertxd ("Enter the string to be sent",cr,lf)
pause 20000

sertxd (#ptr," ",#hSerPtr,cr,lf)
hSerOut 0, ( "AT+CMGL=",$22,"ALL",$22,cr) 'has SMS been received?
pause 200
do while ptr <> hSerPtr
b0 = @ptrInc
sertxd (#ptr," ",#hSerPtr,cr,lf)
SerTxd ( "Rx", tab, #b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""
Rx 43 "+"
Rx 67 "C"
Rx 79 "O"
Rx 80 "P"
Rx 83 "S"
Rx 58 ":"
Rx 32 " "
Rx 48 "0"
Rx 44 ","
Rx 48 "0"
Rx 44 ","
Rx 34 """
Rx 84 "T"
Rx 69 "E"
Rx 76 "L"
Rx 73 "I"
Rx 65 "A"
Rx 32 " "
Rx 68 "D"
Rx 75 "K"
Rx 34 """
Rx 13 "
"
Rx 10 ""
Rx 13 "
"
Rx 10 ""
Rx 79 "O"
Rx 75 "K"
Rx 13 "
"
Rx 10 ""
Enter the string to be sent
127 127
128 147
Rx 65 "A"
129 147
Rx 84 "T"
130 147
Rx 43 "+"
131 147
Rx 67 "C"
132 147
Rx 77 "M"
133 147
Rx 71 "G"
134 147
Rx 76 "L"
135 147
Rx 61 "="
136 147
Rx 34 """
137 147
Rx 65 "A"
138 147
Rx 76 "L"
139 147
Rx 76 "L"
140 147
Rx 34 """
141 147
Rx 13 "
"
142 147
Rx 13 "
"
143 147
Rx 10 ""
144 147
Rx 79 "O"
145 147
Rx 75 "K"
146 147
Rx 13 "
"
147 147
Rx 10 ""

Have I been looking at this for too long?
Best regards
torben









 

friis

Senior Member
Hi hippy,
I must be blind. The phone company says that 74 SMS have been received and delivered to the recepient,
Best regards
torben
 

friis

Senior Member
Hi hippy,
I got a message on my IPHONE telling me to take the SIM-card out and set it in again. Now the answer to the message is:

Enter the string to be sent
114 177 * these 2 are strange but 177 is the beginning of the command
115 197 * these 2 are strange but 197 is the end of the command
Rx 13 " * beginning of strange output
"
116 197
Rx 10 ""
117 197
Rx 43 "+"
118 197
Rx 67 "C" *CMT is explained in "Nordic Semiconductot Infocenter", but I can't make sense of it
119 197
Rx 77 "M"
120 197
Rx 84 "T"
121 197
Rx 58 ":"
122 197
Rx 32 " "
123 197
Rx 34 """
124 197
Rx 43 "+" *beginning of an earlier input phone number
125 197
Rx 52 "4"
126 197
Rx 53 "5"
127 197
Rx 56 "8"
128 197
Rx 49 "1"
129 197
Rx 49 "1"
130 197
Rx 49 "1"
131 197
Rx 54 "6"
132 197
Rx xx "x"
133 197
Rx yy "y"
134 197
Rx zz "z" *end of an earlier input phone number
135 197 *beginning of strange output (CMT output)
Rx 34 """
136 197
Rx 44 ","
137 197
Rx 34 """
138 197
Rx 34 """
139 197
Rx 44 ","
140 197
Rx 34 """
141 197
Rx 50 "2"
142 197
Rx 50 "2"
143 197
Rx 47 "/"
144 197
Rx 49 "1"
145 197
Rx 48 "0"
146 197
Rx 47 "/"
147 197
Rx 48 "0"
148 197
Rx 51 "3"
149 197
Rx 44 ","
150 197
Rx 50 "2"
151 197
Rx 50 "2"
152 197
Rx 58 ":"
153 197
Rx 53 "5"
154 197
Rx 51 "3"
155 197
Rx 58 ":"
156 197
Rx 52 "4"
157 197
Rx 52 "4"
158 197
Rx 43 "+"
159 197
Rx 48 "0"
160 197
Rx 56 "8"
161 197
Rx 34 """
162 197
Rx 13 "
"
163 197
Rx 10 ""
164 197
Rx 40 "(" *beginning of actual input
165 197
Rx 52 "4"
166 197
Rx 53 "5"
167 197
Rx 56 "8"
168 197
Rx 49 "1"
169 197
Rx 49 "1"
170 197
Rx 49 "1"
171 197
Rx 52 "4"
172 197
Rx xx "x"
173 197
Rx xx "y"
174 197
Rx zz "z"
175 197
Rx 41 ")" *end of actual input
176 197
Rx 13 "
"
177 197
Rx 10 ""
178 197
Rx 65 "A" *begining of command
179 197
Rx 84 "T"
180 197
Rx 43 "+"
181 197
Rx 67 "C"
182 197
Rx 77 "M"
183 197
Rx 71 "G"
184 197
Rx 76 "L"
185 197
Rx 61 "="
186 197
Rx 34 """
187 197
Rx 65 "A"
188 197
Rx 76 "L"
189 197
Rx 76 "L"
190 197
Rx 34 """
191 197
Rx 13 "
"
192 197
Rx 13 "
"
193 197
Rx 10 ""
194 197
Rx 79 "O"
195 197
Rx 75 "K"
196 197
Rx 13 "
"
197 197
Rx 10 "" *end of command

I am confused, but I will talk to the phone company tomorrow. All output comes before the command "AT+CMGL="
I have actually input "AT+CMGF=1" before "sertxd ("Enter...., but that makes no difference.
Best regards
torben





 
Last edited by a moderator:

hippy

Ex-Staff (retired)
Have I been looking at this for too long?
Not sure. What part of what you are seeing appears to be wrong or unexpected to you ?

AFAICT the responses all appear to be consistent with what was sent, though I haven't checked the actual meaning of responses ...
Code:
Sent       Received
AT       | AT<cr><cr><lf>OK<cr><lf>
AT+CMGD  | AT+CMGD=0,4<cr><cr><lf>OK<cr><lf>
AT+CPIN? | AT+CPIN?<cr><cr><lf>+CPIN: READY<cr><lf><cr><lf>OK<cr><lf>
AT+CREG  | AT+CREG?<cr><cr><lf>+CREG: 1,1<cr><lf><cr><lf>OK<cr><lf>
AT+COPS  | AT+COPS?<cr><cr><lf>+COPS: 0,0,"TELIA DK"<cr><lf><cr><lf>OK<cr><lf>
AT+CMGL  | AT+CMGL="ALL"<cr><cr><lf>OK<cr><lf>
I am guessing the +COPS: 0,0,"TELIA DK" is indicating there's no SMS. And that your later post is part of a response to the AT+COPS when there has been an SMS recieved -
Code:
AT+COPS  | ...OK<cr><lf>
         | +CMT: "+4581116xyz","","22/10/03,22:53:44+08"<cr><lf>(4581114xyz)<cr><lf>
AT+CMGL  | AT+CMGL="ALL"<cr><cr><lf>OK<cr><lf>
The only thing odd there is there is no "OK" after the +CMT. That could be because that was printed before, as part of the AT+COPS response.

Perhaps the +CMT is an unsolicited message, has been sent some time after AT+COPS has been responded to so you are seeing that as a prefix to the response to your AT+CMGL, even though it arrived sooner. Or maybe it's held and then sent as a prefix to the response -
Code:
AT+COPS  | ...OK<cr><lf>
AT+CMGL  | +CMT: "+4581116xyz","","22/10/03,22:53:44+08"<cr><lf>(4581114xyz)<cr><lf>
         | AT+CMGL="ALL"<cr><cr><lf>OK<cr><lf>
It's been a while since I did any GSM/SMS but it all seems to be 'as expected', at least not unexpected, to me

PS : I edited your post to obfuscate your phone numbers with 'xyz'
 

hippy

Ex-Staff (retired)
This is untested but what I would try to help figure out what is going on ...
Code:
#PICAXE 28X2
#Terminal 19200
#No_table
#No_data

Goto PowerOnReset

#Macro Send(txt)
  SerTxd(txt)
  hSerOut 0, (txt, CR)
  Gosub Response
#EndMacro

Response:
  Pause 2000
  SerTxd( TAB, "| " )
  Do While ptr <> hSerPtr
     b0 = @ptrInc
     Select Case b0
       Case   $0D : SerTxd( "<cr>" )
       Case   $0A : SerTxd( "<lf>" )
       Case < $20 : SerTxd( "<", #b0, ">" )
       Else       : SerTxd( b0 )
     End Select
  Loop
  SerTxd( CR, LF )
  Return

PowerOnReset:
  pause 2000
  setfreq m16
  SerTxd( Cr, LF, "Started PowerOnReset", CR, LF )
  hSerSetup B115200_16,%001

  Send( "AT" )
  Send( "AT+CMGD=0,4" )
  Send( "AT+CPIN?" )
  Send( "AT+CREG?" )
  Send( "AT+COPS?" )
  Send( "AT+CMGL=\"ALL\"" )
 

friis

Senior Member
Hi hippy,

This is what I had:

Send SMS number now or wait...
I get a lot of (unsolicited) +MTI data ending with the character string I entered (4581113456)
AT+CMGF=1 OK
AT+CMGL = ALL OK

I have changed it to:

Send SMS number now or wait...
I get a lot of (unsolicited) +MTI data ending with the character string I entered (4581113456) and I extract
the phone number I entered from that.

I hope that arrangement does not change. I think it was dfifferent when I had another phone company.
Best regards.
torben
 
Top