# ADL\_RET\_ERR\_BAD\_STATE in sending SMS

**URL:** <https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623>\
**Category:** Legacy AirPrime modules\
**Created:** [December 11, 2014, 4:19pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623 "2014-12-11T16:19:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![contrive](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@contrive](https://forum.sierrawireless.com/u/contrive)\
**Post date:** [December 11, 2014, 4:19pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/1 "2014-12-11T16:19:49Z")

</div>

Hi everybody,

I have a problem with Q26CL702 module of a customer in France.

Every time he tries to send an sms (the application use the function adl\_smssend) the reply is -8.

Module and SIM card are initializated and registered. In fact the +wind:16 unsolicited is received and using at+cmgs command the sms are sent.

SMS are received correctly, calls are made and received. Just the sms sent with the adl function don’t work…

I send another device and it doesn’t work. But the first one was returned and here works.

We have also other customer in France (and many other in different countries) which don’t complain.

He’s using FREE and ORANGE FR operator.

Has someone experienced this problem?

Here is the configuration of the module…

“DWL”,“V08b13”,"",“Sierra Wireless”,55344,“111611 18:03”,“dda36757”,“00010000”  
“FW”,“FW\_SRC\_747\_8\_F4\_3.Q2687G”,“R7.47.4.201208311102.Q26CL702”,“Sierra Wireless”,2221264,“083112 11:02”,“6aa633a2”,“00020000”  
“OAT”,“05.01.20141211155159”,“xxxx”,“xxxx”,613624,“121114 15:52”,“080d3f55”,“00260000”  
-“Developer Studio”,“2.3.2.201310241753”  
-“Open AT Application Framework package”,“2.37.4.201209061149”  
-“Open AT OS Package”,“6.37.0.201202060950”  
-“Firmware Package”,“7.47.4.201208311102”  
-“ExtendedATApplication Library Package”,“1.11.0.201209041207”  
-“Internet Library Package”,“5.43.1.201206250935”  
“ROM”,“800000”  
“RAM”,“200000”  
“DWLNAME”,“Q26CL702”

Thanks

---

<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:** [December 11, 2014, 8:01pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/2 "2014-12-11T20:01:38Z")

</div>

What happens if you try to send an SMS “manually”… ❓

---

<div class="post-metadata">

**Author:** ![contrive](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@contrive](https://forum.sierrawireless.com/u/contrive)\
**Post date:** [December 12, 2014, 8:12am UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/3 "2014-12-12T08:12:22Z")

</div>

Hi,

If I send SMS using AT+CMGS everything works.

I have tried to send “manually” with application turned on (at+wopen=1) or turned off (at+wopen=0).

The +WIND:16 is received correctly, SIM card is full init (calls and incoming sms are OK)  
and at+creg? is registered (+creg=0,1 for ORANGE FR; +creg: 0,5 for FREE)

Is there any short code for barring originated SMS (which however is not the case since at+cmgs works)?

I’m going to check the reply of adl\_smssubscribe in case there are some issue from the beginning…

Thanks

---

<div class="post-metadata">

**Author:** ![contrive](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@contrive](https://forum.sierrawireless.com/u/contrive)\
**Post date:** [December 12, 2014, 9:43am UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/4 "2014-12-12T09:43:33Z")

</div>

Update:

the result of adl\_smsSubscribe function is 0.  
From documentation this is a good value for the sms handler…

but the -8 error still comes up…

I can’t figure why that’s happen…maybe should I try to use Q2687RD and not Q26CL702 module  
and maybe use firmware v7.52 and not v7.47.4?

Thanks

---

<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:** [December 12, 2014, 1:28pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/5 "2014-12-12T13:28:38Z")

</div>

Are you sure this happens on every attempt to send ❓

A common mistake is to try to send a message before the previous one is fully complete - in which case ADL\_RET\_ERR\_BAD\_STATE makes sense…

Internally, I think adl\_smssend() still uses AT commands - so is the application doing anything else with AT commands which could “block” the sending? Particularly, commands which take a “long” time to execute - like AT+COPS=?

---

<div class="post-metadata">

**Author:** ![contrive](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@contrive](https://forum.sierrawireless.com/u/contrive)\
**Post date:** [December 15, 2014, 9:36am UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/6 "2014-12-15T09:36:09Z")

</div>

Hi and thanks for reply.

It happens every sms is sent using adl\_smssend function and I’m pretty sure that there aren’t other sms in sending status.

However, the application polls some AT commands like

at+creg?  
at+cgreg?  
at+csq  
at+cops?  
at+cced=0,1

to know what is the registration and network status. The process is execute maybe once every minute…

I was not aware that some AT commands are long to execute: do you know if there is some documentation with a list of this commands?

I will try to exclude at+cops? command to check if it could be a cause…

Thanks

---

<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:** [December 15, 2014, 8:43pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/7 "2014-12-15T20:43:18Z")

</div>

Have you considered using unsolicited responses to advise changes in network state - rather than continually polling…?

> [@](#):
>
> I was not aware that some AT commands are long to execute: do you know if there is some documentation with a list of this commands?

Yes, they do - and yes, it would be useful to have it documented ❗

Sending an SMS is a command that take a (relatively) “long” time - that’s why adl\_smsSend() returns immediately and uses a callback to later advise the success/failure status…

Is your application careful to not do a network status poll in the period between adl\_smsSend() and receiving the result… ❓

> [@](#):
>
> I will try to exclude at+cops? command to check if it could be a cause…

Note that at+cops? is not the same as at+cops=? ❗

---

<div class="post-metadata">

**Author:** ![contrive](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@contrive](https://forum.sierrawireless.com/u/contrive)\
**Post date:** [December 17, 2014, 8:08am UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/8 "2014-12-17T08:08:14Z")

</div>

Hi,

> [@](#):
>
> Have you considered using unsolicited responses to advise changes in network state - rather than continually polling…?

You are right: maybe it’s better to wait unsolicited respect to poll network status: however I inherit the project so I have to modify with care; but I think it is a good pratice.

> [@](#):
>
> Is your application careful to not do a network status poll in the period between adl\_smsSend() and receiving the result… ?

No, the application polls independently the network status and the sms send process. However I don’t understand why over the 2000 devices we have around the world, just the devices I sent to that customer won’t send SMS (during the production test they worked)

> [@](#):
>
> Note that at+cops? is not the same as at+cops=?

I confirm that application uses at+cops? (ask for current carrier operator)

So far, I can’t find a solution: I will try to remove network status poll and I’ll let you know.

Thank you

---

<div class="post-metadata">

**Author:** ![milan\_va](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@milan\_va](https://forum.sierrawireless.com/u/milan_va)\
**Post date:** [December 17, 2014, 11:50am UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/9 "2014-12-17T11:50:18Z")

</div>

Hi Contrive,

that’s an interesting problem… 3/4 of my application is working around various ADL issues, making sure the module is logged in, and restarting various services as they fail.

Your problem first.  
Sometimes the documentation is fuzzy, but when there’s explanation “initialization not yet performed, or sending an SMS already in progress”, my bet is it’s one of the two.  
Can you make an AT command for the customer, that will only perform adl\_smsSend() and return the error code? It would be best to create a new application that does nothing else, or perhaps add a minute wait in startup of your application.

Second, I have 2 automatons, say Monitor and Sender.  
Monitor has many numbered states, and fires every second.  
100: ask AT+CREG? and goto 101  
101: wait for +CREG response -\>102 or timeout  
102: ask AT+CSQ and goto 103  
103: wait for +CSQ -\> 104 or timeout  
104: ask AT+CPAS and goto 105  
105: wait for +CPAS -\> must not be +CPAS: 5; back to 100 or timeout  
on timeout:  
201: setup a 50-second wait  
203: wait, if a response comes goto 100  
205: send AT+WAC  
207: wait 10 seconds, on response goto 100  
208: restart module ☹

The point is that Monitor can be interrupted at even steps. The Sender will wait for an even step, and set a busy flag.  
The Monitor will wait in even step until the Sender is done.  
It’s all much more involved, some hundreds of lines of code, but this is the idea. Maybe not the best way, but it works.

---

<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:** [December 17, 2014, 12:54pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/10 "2014-12-17T12:54:15Z")

</div>

> [@contrive](#):
>
> > [@I](#):
> >
> > Is your application careful to not do a network status poll in the period between adl\_smsSend() and receiving the result… ?
> 
> No, the application polls independently the network status and the sms send process. However I don’t understand why over the 2000 devices we have around the world, just the devices I sent to that customer won’t send SMS (during the production test they worked)

Thinking about it, I don’t think it should be a problem: I think adl\_smsSend() does complete the SMS command(s) before it returns - so there shouldn’t (sic!) be a problem…

Does your application also receive SMS ❓

If so, do you also have problems with SMS reception…?

There is a longstanding suspicion that something can go wrong with SMS reception, resulting in the receive handler not being notified: [Received SMS messages not reaching the SMS Handler](https://forum.sierrawireless.com/t/received-sms-messages-not-reaching-the-sms-handler/4685/1)

I’m not sure what happens to SMS sending in that case…

---

<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:** [December 17, 2014, 12:55pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/11 "2014-12-17T12:55:44Z")

</div>

Is the SIM message store full ❓

I know that prevents SMS receiving (not related to Open-AT) - I guess it could also affect sending…?

---

<div class="post-metadata">

**Author:** ![contrive](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@contrive](https://forum.sierrawireless.com/u/contrive)\
**Post date:** [February 24, 2015, 3:23pm UTC](https://forum.sierrawireless.com/t/adl-ret-err-bad-state-in-sending-sms/7623/12 "2015-02-24T15:23:12Z")

</div>

The sms are correctly received and the SIM message store is empty (every time an SMS is received, it is deleted after processing). I have verified also with at+cpms? command…

I have and update:

- I sent customer a new product mounting Q2687RD (instead of Q26CL702) and firmware R7.47.4  
adl\_smsend error -8 still appear

Then:

- I installed firmware R7.52 (which is compatible with Q2687RD) and downloaded the application (compiled for R7.52).  
No way to work…

Result: we lost the customer…

Is there a method to retrieve some traces in remote using a normal serial terminal (I can’t ask customer to install devStudio)? So I can send to Sierra and see what could be the problem.

Thanks
