Sending multiple SMS

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

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

Hi daimoniro,

I think the answer is here:

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

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…?

Is this the thread in question?

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…

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 ?

No, you are not!

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

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! )

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…

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

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…

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… :angry:

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… :angry:
[/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…

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’ve found it again: FAQ forum/wiki? :smiley:

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…

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