# SMS deletion on SIM

**URL:** <https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507>\
**Category:** Open AT\
**Created:** [June 16, 2010, 8:14am UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507 "2010-06-16T08:14:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LKtelematics](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@LKtelematics](https://forum.sierrawireless.com/u/LKtelematics)\
**Post date:** [June 16, 2010, 8:14am UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/1 "2010-06-16T08:14:11Z")

</div>

After processing a received SMS, I want to delete it from the SIM with the means of  
adl\_atCmdSend(“AT+CMGD=1\r\n” , NULL, NULL);

However, the message was not deleted.

Not being sure, if the command needet to be subscribed before use, I did so in advance with  
adl\_atCmdSubscribe(“AT+CMGD” ,NULL, ADL\_CMD\_TYPE\_PARA |ADL\_CMD\_TYPE\_ACT);

but without any effect.

What prefents the deletion of SMS #1 on the SIM?  
at

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [June 16, 2010, 8:42am UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/2 "2010-06-16T08:42:31Z")

</div>

> [@LKtelematics](#):
>
> After processing a received SMS

How do you process it?

> [@](#):
>
> I want to delete it from the SIM with the means of  
> adl\_atCmdSend(“AT+CMGD=1\r\n” , NULL, NULL);

Note that AT Command are terminated by CR - not CRLF.

How do you know that its index will always be 1 ?

Why don’t you subscribe to the responses? The response would show you any error code that’s returned…

> [@](#):
>
> Not being sure, if the command needet to be subscribed before use

No it doesn’t - subscribing a command is for when you want to “catch” an incoming command

> [@](#):
>
> , I did so in advance with  
> adl\_atCmdSubscribe(“AT+CMGD” ,NULL, ADL\_CMD\_TYPE\_PARA |ADL\_CMD\_TYPE\_ACT);

That could be messing things up…

---

<div class="post-metadata">

**Author:** ![LKtelematics](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@LKtelematics](https://forum.sierrawireless.com/u/LKtelematics)\
**Post date:** [June 16, 2010, 11:24am UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/3 "2010-06-16T11:24:43Z")

</div>

You hint with the termination of the AT command was good.  
The line “adl\_atCmdSend(“AT+CMGD=1\r” , NULL, NULL);” works  
(however, I am a bit surprised that terminating with “\r\n” refuses the correct procession)

The SMS index 1 was just an exemple.

For further analysis I defined a response-handler to obtain the error code.  
However, I get only the ascii"OK" or “ERROR” (content of “StrData[]” of structure adl\_atResponse\_t).  
Is this, what you meant by ‘error code’?

thanks so far  
at

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [June 16, 2010, 1:31pm UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/4 "2010-06-16T13:31:32Z")

</div>

> [@LKtelematics](#):
>
> (however, I am a bit surprised that terminating with “\r\n” refuses the correct procession)

Indeed!  
It is unnecessary - but I didn’t think that it should actually break anything!

> [@](#):
>
> I get only the ascii"OK" or “ERROR” (content of “StrData” of structure adl\_atResponse\_t).  
> Is this, what you meant by ‘error code’?

I would expect you to get a +CMS ERROR: ` `` - but maybe a “malformed” command just gives ERROR?`

---

<div class="post-metadata">

**Author:** ![LKtelematics](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@LKtelematics](https://forum.sierrawireless.com/u/LKtelematics)\
**Post date:** [June 16, 2010, 2:47pm UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/5 "2010-06-16T14:47:01Z")

</div>

> [@](#):
>
> I would expect you to get a +CMS ERROR: ` `` - but maybe a “malformed” command just gives ERROR?`
> 
> `
> `

`
Here we go…
You have to activate via “AT+CMEE=1\r” the delivering of an error code.
By default, only an “ERROR” will be answered.
at`

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [June 16, 2010, 3:04pm UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/6 "2010-06-16T15:04:02Z")

</div>

> [@LKtelematics](#):
>
> You have to activate via “AT+CMEE=1\r” the delivering of an error code.

True for manual operation - but you shouldn’t have to do that in an Open-AT application…

> [@ADL User Guide](#):
>
> Inner AT Commands Configuration
> 
> The ADL library needs for its internal processes to set-up some AT command configurations that differ from the default values. The concerned commands are listed hereafter:
> 
> ```auto
> AT Command Fixed value
> AT+CMEE 1
> ```

---

<div class="post-metadata">

**Author:** ![shivaprasad](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@shivaprasad](https://forum.sierrawireless.com/u/shivaprasad)\
**Post date:** [June 19, 2010, 5:21am UTC](https://forum.sierrawireless.com/t/sms-deletion-on-sim/4507/7 "2010-06-19T05:21:11Z")

</div>

I think this code may help you.  
On SmsHandler event , we receive the SmsText, and SMS sender Number.  
Here in the code i am validating the sender number  
If return is true it will be saving in the SIM or else will not.

server\_number1=“xxxxxxxxxxx”

bool SMSHandler(ascii \*SmsTel, ascii \*SmsTimeLength,ascii \*SmsText )  
{  
TRACE (( 1, “SMS RECEIVED” ));  
if(wm\_strcmp( server\_number1,SmsTel ) == 0)  
{  
return TRUE;  
}  
else  
{  
return FALSE;  
}

}
