Error sending more than one SMS

Hi,

I’m trying to send an SMS to multiple phone numbers:

TRACE((1, "adl_smsSend: %d",
            adl_smsSend(0, "0123456789", "Hello World!", ADL_SMS_MODE_TEXT)
         ));
    TRACE((1, "adl_smsSend: %d",
            adl_smsSend(0, "0987654321", "Hello World!", ADL_SMS_MODE_TEXT)
         ));

The first call to adl_smsSend works fine but the second one returns ADL_RET_ERR_BAD_STATE. I have already tried “at+cmms=2” but this didn’t help. :frowning:

Can someone help me please?
Thanks in advance!
e.r.n.i.e

Think what would happen if you were doing this manually: you’d wait for the OK from the 1st command before starting the second - wouldn’t you…?

Thanks for your quick answer, but I don’t understand it. The first call to adl_smsSend returns OK immediately. So for which OK do I have to wait and how do I do this? Maybe I should have mentioned that I’m new to this wavecom stuff. :blush:

Hiya,

You probably have to wait for the ADL_SMS_EVENT_SENDING_OK event to arrive in your SMS Control Event Handler function before sending a second SMS. The control event handler is configured in your adl_smsSubscribe() function call that is required before sending using and of the SMS api functions.

Remember that ADL is event driven - In general, you subscribe to a service and get a handle back if subscription is successful. At subscription time, you also usually get the opportunity to register an event call-back function that will be called whenever an event occurs. Once finished with the service, you unsubscribe from it.

I notice in your code that you are using a handle of 0 in the adl_smsSend() function call. This indicates to me that you haven’t subscribed to the service properly - and I’m surprised that you were able to send an SMS at all.

Have a close look at the SMS automation sample provided with OpenAT.

ciao, Dave

Are you confusing OK as a return code from an API function with the string “OK” returned by an AT command?

The OK return code from the adl_smsSend API function simply indicates that the command has been accepted - as davidc notes, you have to wait for an event to show when the operation completes…

I propose you to make a queue for the outgoing SMS. When you want to send an SMS you put it (with the phone number) in the queue. You may only eliminate the SMS when you recieve an ADL_SMS_EVENT_SENDING_OK, at this moment you may also send the next one. It’s the best way if you need to send a lot of SMS “at the same time”.
I also recomend an attempt counter, to limit the number of times you try to send the same message. If you don’t do that you may block your “wireless CPU”.
Be carefull also with the situations in which you’re not connected to the net (checked with AT+CREG).

And you also need to think carefully about how to handle the error cases when the SMS is not sent…
(including retries, retry counters, etc…)

If you want to send “a lot of SMS”, a GSM modem may well not be a good solution.

More details of the actual requirement would help in giving more appropriate advice…

What I mean with:

Is more or less the same awneil indicate:

I also agree with awneil that more requirements information is necessary to think in a good way of helping e.r.n.i.e

@fer.caballero:
can you please give more information on how to make use of queues to send multiple sms (i want to send only 5 messages)?
Thanks

Are you talking specifically about the ADL Queue facilities provided by Open-AT, or just about “queues” in general.

For just 5 entries, a simple array should suffice…

  1. There is not multitasking in my application
  2. I am talking specifically about ADL Queue facility
  3. my question is,
    I am receiving the contact numbers through text and storing it to flash memory, whenever there is a change in state of GPIO21/25, I am reading the contacts from flash and sending text messages. I am able to send text to only one contact. when I tried to send to other contacts (by reading from flash, adl_smsSend(handle, read_flash, “hi”, Text)) in sms control handler, I started receiving “hi” continuously (until I stop the running application but when I tried adl_smsSend(handle, “123456789”, “hi”, Text) , I received the text only once.

even I tried with AT+CMMS but it doesnt worked for me.

Can you please suggest better way to send text to multiple contacts?

Thanks

So you’re just sending the same message to a list of 5 recipients?

If so, I don’t see any reason to complicate this with queues and stuff - just step through the list of destination numbers!

What you need to do, for each destination, is to send the message and then wait until you have received both ADL_SMS_EVENT_SENDING_OK and ADL_SMS_EVENT_SENDING_MR

It might not be a good idea to send from within the control handler…

yes.

yes, I understood this logic (in control handler after successful smssend ADL_SMS_EVENT_SENDING_MR gets executed and then ADL_SMS_EVENT_SENDING_OK) but as i said i need read the phone number (5 numbers) from flash and send the messages. the confusing bit for me is wait until you have received both…
. where shld i wait (i think in cntrol handler)?

yes, its not a good idea…because I tried to send within handler, sms was sent but sent multiple rather i would say infinite loop gets created.
Can you please give me a clue/ idea about waiting state and sending text outside the control handler?
thanks

No! You should certainly not wait in the Control Handler :exclamation:

Think about it: If you put a wait in the Control Handler, then the handler will be “stuck” and the system will not be able to call it again :exclamation:

You need to understand that Open-AT is an Event-Driven system - see this thread for some materials on Event-Driven systems:

thanks for quick reply Awneil,

yaa i came across this problem and i think I managed to find the solution. please see below

Now I am able to send multiple text by doing following steps,

  1. I am subscribing “smssubscribe” multiple times with different handles (handle1, 2, 3…), is it fine?
  2. smssend(handle1, number1, …)
  3. in handle1 when event “sms sent ok” received then smssend(handle2, number2, …)
  4. in handle2 when event “sms sent ok” received then smssend(handle3, number3, …)

is it a correct rather good way to send multiple texts?

Thanks for this document, I will read it.

thanks

No, I don’t think it’s a good way.

There is really no need for nor point to multiple subscriptions!

I would implement this as a State Machine - again, see the previous linked articles…

[/quote]
I would implement this as a State Machine - again, see the previous linked articles…
[/quote]
Thank you very much.

Open At soft can many bags? the simcom is good

Eh?? :confused:

It’s just a dumb modem - no support for anything like Open-AT.

Can I just ask: How else can one send an sms to multiple recipients?