Can't read or count messages on GSM Modem - sms

I am using a Huawei E303 modem and I am not seeing new messages via AT commands. Huawei's application "Mobile Partner" is able to read these messages but I don't understand how.
I have set AT+CMGF=1 and when I try AT+CPMS? I get +CPMS:"SM",0,30,"SM",0,30,"SM",0,30
When a new message arrives I get a +CTMI: "SM", 0 every single time. That value never increments. AT+CMGL="ALL" returns response OK but no messages.
I am now out of ideas. How can I read a message if counting them always returns zero?
What is amazing is that the Huawei application can read incoming messages, can send messages without any problems.

Related

How to store receiving SMS in GSM Module memory (SM or ME)?

I am using AI Thinker A7 GSM/GPRS/GPS Module demo v7.1.
I am trying to send and receive SMS through AI-Thinker Serial Tools V1.2.3.0
This module is working fine with making a call and receiving a call, sending and receiving an SMS. They work exactly fine.
The problem is that it does not store SMS in the memory?
I have done a lot of things to make it work, but there is no progress.
For instance, my AT commands and their responses are here,
AT+CPMS=?
+CPMS: ("ME","SM"),("ME","SM"),("ME","SM")
and
AT+CPMS="SM"
+CPMS: 0,35,0,35,0,25
and
AT+CPMS="ME"
+CPMS: 0,25,0,35,0,25
And I have tried CNMI settings like these,
AT+CNMI=1,1,0,0,0
OK
After these, I send msgs, and then tried to check through AT+CPMS and AT+CMGL, but there are no messages stored.
then I tried
AT +CNMI = 2,1,0,0,0
OK
and the same with
AT +CNMI = 2,2,0,0,0
OK
similarly
AT +CNMI = 0,1,0,0,0
OK
But still, I have not succeeded in getting message stored in memories.
Please help, if there are any other settings I need to do or my commands are wrong or my module doesn't support storing SMS (i highly doubt it since it has memory spaces which are showing that 25 SMS in SM, 35 in ME can be stored)??
If I understand your problem correctly, you are trying to read incoming SMS but can't list them.
Well, you need to understand that your GSM module doesn't store any incoming SMS by default. You have to command your GSM Module to store it. As you mentioned, you were very close to command for that. you need to command it this way:
AT+CPMS=mem1,mem2,mem3
AT+CPMS="SM","SM","SM"
As per documentation, you can mention three memories as the parameter for different operations like:
mem1 (in this example SM) - a memory from which messages are read and delete
mem2 (in this example SM; but could be ME) - a memory from which writing and sending operations are made
mem3 (in this example SM; but could be ME) - memory to which received messages are preferred to be stored
Now your GSM module will store all incoming messages into the SIM card and you'll be able to list all the messages with AT+CMGL=ALL
This way it worked for me.

AT+CMGS doesn't work correctly

I have a problem with AT command for sending SMS - AT+CMGS. After sending AT+CMGS=<length of PDU datagram><CR> I wait for response of modem. After reading <CR><LF>><Space> I send <PDU datagram><CTRL-Z> but I don't get any answer from modem. If I send any command after that the response to that command is +CMGS=<reference number> which is exactly the response which I expected later.
But if I wait for about 100ms after reading <CR><LF>><Space> and than send PDU datagram than everything works well and I receive expected answer from modem.
It is really necessary to wait after receiving response from modem? I thought that I can send response immediately after reading <CR><LF>><Space>. Can someone help me to understand where could be a problem?
Thanks a lot
You are correct in your assumption, 27.005 states for AT+CMGS:
the TA shall send a four character sequence
<CR><LF><greater_than><space> (IRA 13, 10, 62, 32) after command line
is terminated with <CR>; after that text can be entered from TE to
ME/TA.
(TA (terminal adapter) is modem, TE (terminal equipment) is sender of AT commands)
However, in practice some additional small delay might be needed even in cases where the modem have signalled that it is ready to receive.

How to test when the end of an SMS message has been reached

I am writing an application which acts on commands received via SMS (in Python, but the problem occurs in other languages).
This page on the CMGL command shows the following command and response:
AT+CMGL="ALL"
+CMGL: 1,"REC UNREAD","+31628870634",,"11/01/09,10:26:26+04"
This is text message 1
+CMGL: 2,"REC UNREAD","+31628870634",,"11/01/09,10:26:49+04"
This is text message 2
OK
Most implementations I have looked at look for a valid status such as OK or ERROR to detect the end of the response.
I am trying to find a way to determine the difference between this status code and the end of the message.
Otherwise it would be possible for a malicious sender to send a message of
Hello<CR><LF>OK<CR><LF>+CMGL: 1,(rest of fake message...)
Because I am receiving data on the serial port, there is no clear way to tell when I have reached the end of one message from the GSM board.
Could anyone point me to some information on the best practice here please? Other implementations I have seen do not seem to cover this issue.
The only idea I have had so far (but feels quite messy) is to keep reading until a timeout has been hit. Then check the number of OK / ERROR lines in the message and only accept the last.

+CMS ERROR 41 on Telit Modem

I am a developer, working on "Telit" GE865-Quad using AT commands.
I am planning an application, witch sends SMS when certain condition occurs. When the application does not send SMS the modem is shut-down (Therefore every time I want to send SMS I have to turn on the modem). This application sends 3 SMS to different numbers one after the other.
The application is working just fine. The problem apear after a while (after sending certain amount of SMS), when I give the command to send SMS I get "+CMS ERROR 41" ("Temporary failure"). Once this message appear, every time I try to send SMS I get the same ERROR - It is like the SIM card is stuck. The only way I have found to get rid of this error is to enter the SIM card to my privet phone and send SMS.
I have spoken to "Telit" representative and he could not give a satisfying answer other then adding more delay between messages.
This is some of the relevant code :
(Turning on sequence) // From "Telit" GE865-Quad DataSheet
> #QSS: 3 //Before I start working with the modem i wait for this response with means the SIM is ready to use and the registration is to cellular network is complete*/
AT+CMGF=1 // Text Mode
OK
AT+CMGS=+xxxxxxxxxxxx // My number.
"This is the message i want to send" //Preparing the desired message require some coding But I think this is irrelevant to the subject.
//Delay for 3 secs//
And again : AT+CMGS=+xxxxxxxxxxxx // My number.
"This is the message I want to send"
//Delay for 3 secs//
(The same thing one more time)
The questions are:
Why does it happen, what am I doing wrong??
How can I unblock the SIM? What does the phone do so I can keep sending SMS?
The purpose is the keep sending SMS automatically.
This is the first time I publish a message in this website so if something is unclear please let me know. :)
Thanks for all the helpers.
Itay.
today i encountered this +CMS ERROR: 41 error, many times.
There was about 40 unread messages in the receiving modem.
After i deleted all received messages error disappeared.
I think may be operator is protecting customers from spam.
Dmitri
It is due Either SMS service on your SIM is not available or your SMS subscription is expired.

How to handle delivery report in GSM Modem?

i want to use GSM Modem in an application for some purpose.
what i want is handling SMS delivery report for list of sent sms.
GSM Modem inbox & outbox are limited to 15 items. every time i read the inbox the gsm modem return a list an clear the list.
how to check delivery status of sms that had been deleted from GSM Modem inbox ?
i need something unique that enables me to identify each message.
every time i read the inbox the gsm modem return a list an clear the list.
Messages that are stored in modem's memory will not be removed after you read them. You just read message with at+cmgl={message id in storage} command and then remove it using at+cmgd={message id in storage} command (or not, as you wish. You can clear all modem's storages using at+cmgd=1,4 command).
Back to the question: after sending SMS, you'll get a response from modem, smth like this: +cmgs: {sms id, 0 to 255} OK. In case, if Service Center has delivered the SMS successfully, modem will return this response: +cds: {some id which does not matter} {PDU status report}. You need just decode this PDU to obtain status report, id of original SMS and other useful data. If sent sms's ID and ID from status report are equal, you have status report exactly for your message. Note, if you remove message from modem's storage before receiving of delivery report, you'll get report which will be containing all usual information, but status of delivery will be most likely 71 instead of 0.

Resources