# Sending multiple SMS

**URL:** <https://forum.sierrawireless.com/t/sending-multiple-sms/1267>\
**Category:** Open AT\
**Created:** [April 18, 2007, 7:11am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267 "2007-04-18T07:11:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![daimoniro](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@daimoniro](https://forum.sierrawireless.com/u/daimoniro)\
**Post date:** [April 18, 2007, 7:11am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/1 "2007-04-18T07:11:30Z")

</div>

Good Morning,  
this is my problem: I have to send a SMS to a list of mobile

```auto
for(i = 0; i < NumMobile;i++)
{
	sprintf(SmsTel,"%u",ArrayNumMobile[i]);
	adl_smsSend(SMS_handle,SmsTel,SmsText,ADL_SMS_MODE_TEXT);
}
```

where in the ArrayNumMobile I have a list of mobile number.

The first send is ok, but the second and the following doesn’t send anything.

Checking the return value of adl\_smsSend, it returns ADL\_RET\_ERR\_BAD\_STATE telling me that a sending of SMS is already in progress.

I ha ve to wait some time (how much?) or there is some smarter way to know when I can send the following SMS?

Thank you very much

---

<div class="post-metadata">

**Author:** ![jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jan](https://forum.sierrawireless.com/u/jan)\
**Post date:** [April 18, 2007, 7:16am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/2 "2007-04-18T07:16:27Z")

</div>

Hi daimoniro,

I think the answer is here:

[http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=536](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=536)

Best Regards,  
Jan

---

<div class="post-metadata">

**Author:** ![capitanui](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capitanui](https://forum.sierrawireless.com/u/capitanui)\
**Post date:** [December 8, 2010, 4:07pm UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/3 "2010-12-08T16:07:32Z")

</div>

> [@jan](#):
>
> Hi daimoniro,
> 
> I think the answer is here:
> 
> [http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=536](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=536)
> 
> Best Regards,  
> Jan

I have the same problem but this link isn’t available anymore!..does anyone know a solution?  
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 8, 2010, 4:24pm UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/4 "2010-12-08T16:24:03Z")

</div>

Think about what events are passed to the event handler - which one(s) do you think indicate that a message has been sent, and the system is ready for the next…?

---

<div class="post-metadata">

**Author:** ![JasonDiplomat](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JasonDiplomat](https://forum.sierrawireless.com/u/JasonDiplomat)\
**Post date:** [December 8, 2010, 5:39pm UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/5 "2010-12-08T17:39:25Z")

</div>

> [@capitanui](#):
>
> > [@jan](#):
> >
> > Hi daimoniro,
> > 
> > I think the answer is here:
> > 
> > [http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=536](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?t=536)
> > 
> > Best Regards,  
> > Jan
> 
> I have the same problem but this link isn’t available anymore!..does anyone know a solution?  
> thanks

Is this the thread in question?

> [@Diverting sms messages](https://forum.sierrawireless.com/t/diverting-sms-messages/550/1):
>
> I’m programming a small software for Wavecom fastrack M1306B GSM-modem and i’m trying to make the modem forward text messages to a specific number, no matter how many messages the modem receives or when it receives them. The main problem is that the modem sends error messages (+CMS ERROR: 515 or +CMS ERROR: 512) when sending more than two messages simultaneously or with short intervals. For example, if i send 5 messages to the modem one after the other or simultaneosly, only 4 or less messages …

---

<div class="post-metadata">

**Author:** ![capitanui](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capitanui](https://forum.sierrawireless.com/u/capitanui)\
**Post date:** [December 9, 2010, 6:56am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/6 "2010-12-09T06:56:13Z")

</div>

> [@awneil](#):
>
> Think about what events are passed to the event handler - which one(s) do you think indicate that a message has been sent, and the system is ready for the next…?

I am waiting for the ADL\_SMS\_EVENT\_SENDING\_OK…

I try to send sms from a for loop…wich reads a list of numbers from flash…verifies the access level of that number and if it’s 0…it means it’s an administrator number and needs to get sms…

```auto
sms_Handle = adl_smsSubscribe(SmsHdlr, SmsCtrlHdlr, ADL_SMS_MODE_TEXT);
	TRACE((1,"sms_Handle = %d", sms_Handle));

	if (sms_Handle >= 0)
	{
		for (i=0; i<=MAX_SMS_NRS; i++)
		{
			if (adl_flhExist("smsACL", i) > 0)
			{
				read = adl_flhRead("smsACL",i,sizeof(app_sms_acl),(u8*) &smsACL[i]);
				TRACE((1,"read=%d",read));

				if (read == OK)
				{
					if (smsACL[i].nivel_acc == 0)
						{
						TRACE((1,"smsACL[%d].nivel_acc = %d",i,smsACL[i].nivel_acc));
						TRACE((1,smsACL[i].nr_tel));

						sms_Send = adl_smsSend(sms_Handle, smsACL[i].nr_tel, SMS_OK_MSG, ADL_SMS_MODE_TEXT);
						}else adl_atSendResponse(ADL_AT_RSP, "ERROR : No ADMIN SMS number configured in SMS ACL");

				}
			}else TRACE ((1,"ERROR : No SMS number configured in SMS ACL at id = %d",i));
		}
	}
```

It tries to transmit 2 times and after that i am receiving the sms event but of corse only one sms is sent…Does anyone knows how can i work around this ?

---

<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 9, 2010, 7:29am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/7 "2010-12-09T07:29:45Z")

</div>

> [@capitanui](#):
>
> I am waiting for the ADL\_SMS\_EVENT\_SENDING\_OK…

No, you are not!

You are just looping blindly - your loop does not wait for anything!

> [@](#):
>
> I try to send sms from a for loop…

You can’t do that!

After you send each message, you need to wait for the event that tells you that the unit is ready to accept the next message!

Think about it: if you were doing this manually, you would wait for the “OK” from one AT Command before sending the next - wouldn’t you?

Besides, doing stuff like this in a loop is never a good idea in Open-AT - you are very likely to end up triggering a watchdog reset!

(there was an entry about this in the FAQ/WIKI thread - but SiWi seem to have lost it: [Lots of missing topics!](https://forum.sierrawireless.com/t/lots-of-missing-topics/4726/1) )

---

<div class="post-metadata">

**Author:** ![capitanui](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capitanui](https://forum.sierrawireless.com/u/capitanui)\
**Post date:** [December 9, 2010, 9:03am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/8 "2010-12-09T09:03:46Z")

</div>

> [@awneil](#):
>
> > [@capitanui](#):
> >
> > I am waiting for the ADL\_SMS\_EVENT\_SENDING\_OK…
> 
> No, you are not!
> 
> You are just looping blindly - your loop does not wait for anything!
> 
> > [@](#):
> >
> > I try to send sms from a for loop…
> 
> You can’t do that!
> 
> After you send each message, you need to wait for the event that tells you that the unit is ready to accept the next message!
> 
> Think about it: if you were doing this manually, you would wait for the “OK” from one AT Command before sending the next - wouldn’t you?
> 
> Besides, doing stuff like this in a loop is never a good idea in Open-AT - you are very likely to end up triggering a watchdog reset!
> 
> (there was an entry about this in the FAQ/WIKI thread - but SiWi seem to have lost it: [Lots of missing topics!](https://forum.sierrawireless.com/t/lots-of-missing-topics/4726/1) )

I understand that i cannot do this from a loop…i already modify my application…i was not triggering any watchdog reset but i sends only the first sms… i assigned a variabile wich will retain the position where i have a valid number, and a counter…and now i`m sending sms based on this variables directly from SmsCtrl Handler…

I thought for a second that maybe there is a posibility that i don’t know about…that’s why i posted this message…i was more confortable if this was possible…because now my application will be more laborious since i need to send messages from different parts of application with different messages to different numbers…

Thanks for replies…

---

<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 9, 2010, 9:40am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/9 "2010-12-09T09:40:32Z")

</div>

> [@capitanui](#):
>
> I understand that i cannot do this from a loop

So why did you post code that did send it from a loop?! 😒

> [@](#):
>
> i was not triggering any watchdog reset

The watchdog timeout is quite long: so you can be “lucky” and get away with it for a short loop - but the basic design is still faulty, and is likely to catch you out in the future…

> [@](#):
>
> I thought for a second that maybe there is a posibility that i don’t know about

You could divide your application into separate tasks; it is OK, for example, to have an adl\_eventWait within a loop - because the Event Wait does allow other tasks to run…

This was mentioned in the FAQ/Wiki thread that SiWi have lost… 😠

---

<div class="post-metadata">

**Author:** ![capitanui](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capitanui](https://forum.sierrawireless.com/u/capitanui)\
**Post date:** [December 9, 2010, 10:13am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/10 "2010-12-09T10:13:05Z")

</div>

> [@](#):
>
> I thought for a second that maybe there is a posibility that i don’t know about

You could divide your application into separate tasks; it is OK, for example, to have an adl\_eventWait within a loop - because the Event Wait does allow other tasks to run…

This was mentioned in the FAQ/Wiki thread that SiWi have lost… 😠  
[/quote]  
I didn’t knew about adl\_eventWait function…i haven’t got the time yet to go trough all ADL user guide informations…i posted an example code with a for loop to see if there is a posibility…because i tried to find one in documentation and other posts on the forum and nothing…and then i concluded that i need to change the way i was doing it but still save the code with the for loop because it’s more practical and maybe someone knew a solution…

Thanks again for replies…it’s so unfortunate that the FAQ/Wiki threads are lost…

---

<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 9, 2010, 11:14am UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/11 "2010-12-09T11:14:50Z")

</div>

> [@capitanui](#):
>
> i haven’t got the time yet to go trough all ADL user guide informations

If you wanted to learn to swim, would you simply jump off a ship in the middle of the ocean?

It really is not wise to start developing without having studied the ADL User Guide!

> [@](#):
>
> it’s so unfortunate that the FAQ/Wiki threads are lost…

I’ve found it again: [FAQ forum/wiki?](https://forum.sierrawireless.com/t/faq-forum-wiki/3491/1)😃

---

<div class="post-metadata">

**Author:** ![capitanui](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capitanui](https://forum.sierrawireless.com/u/capitanui)\
**Post date:** [December 9, 2010, 12:03pm UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/12 "2010-12-09T12:03:16Z")

</div>

> [@awneil](#):
>
> > [@capitanui](#):
> >
> > i haven’t got the time yet to go trough all ADL user guide informations

If you wanted to learn to swim, would you simply jump off a ship in the middle of the ocean?

It really is not wise to start developing without having studied the ADL User Guide!

I only said i didn’t studied it completely…There are services that i didn’t used yet…and only by reading it i cannot believe that a user will have the complete knowledge of all APIs involved…

I first had contact with Open AT …one month and a half ago…once i will have more experience i suppose that i will not come with questions that maybe for other people seems to be very easy…I use this forum to learn because i don’t have near me an experienced person…and that’s why when i cannot understand something and things doesn’t go as i expect i try to get a response from an experienced user here.

I take in consideration all you are saying and try to learn from it…

---

<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 10, 2010, 12:35pm UTC](https://forum.sierrawireless.com/t/sending-multiple-sms/1267/13 "2010-12-10T12:35:02Z")

</div>

Open-AT is Event-Driven, and State Machines (or Finite State Machines, FSM) are often a good way to implement Event-Driven systems.

Therefore, you might do well to take a look at the materials referenced here about Event-Driven Systems and State Machines:  
[viewtopic.php?f=34&t=4208&start=0](https://forum.sierrawireless.com/viewtopic.php?f=34&t=4208&start=0)
