Send a SMS to multiple cellphones

Hello everybody,

Does anyone know how to send a sms to multiple cellphones?

I have found the next code from another person and actually it works great, but when I try to use it with multiple cellphones, it simply does not work…

Does anyone have an idea?

As you can see I have implemented a delay between the two instructions “adl_Smssend” but when I run the program it only works for the first cellphone and ignores the second one.

/********************************************************************************************/
/*  Appli.c   -  Copyright Wavecom S.A. (c) 2002					    */
/*										      	    */
/*											    */
/* DISCLAIMER OF WARRANTY								    */
/* ======================				 				    */
/* This Software is provided free of charge on an 'as is' basis. No warranty is given       */
/* by Wavecom S.A. in relation to the Software of the uses to which it may be put by you,   */
/* the user, or its merchantability, fitness or suitability for any particular purpose      */
/* or conditions; and/or that the use of the Software and all documentation relating        */
/* thereto by the Licensee will not infringe any third party copyright or other             */
/* intellectual property rights. Wavecom S.A. shall furthermore be under no obligation      */
/* to provide support of any nature for the Software and the Documentation.		    */
/*											    */
/* LIMIT OF LIABILITY									        */
/* ==================										*/
/* In no event shall Wavecom S.A. be liable for any loss or damages whatsoever or howsoever	*/
/* caused arising directly or indirectly in connection with this licence, the Software,		*/
/* its use or otherwise except to the extent that such liability may not be lawfully		*/
/* excluded. Notwithstanding the generality of the foregoing, Wavecom S.A. expressly		*/
/* excludes liability for indirect, special, incidental or consequential loss or damage		*/
/* which may arise in respect of the Software or its use, or in respect of other equipment	*/
/* or property, or for loss of profit, business, revenue, goodwill or anticipated savings.	*/
/*												*/
/********************************************************************************************/

/***************************************************************************/
/*  File       : Appli.c                                                   */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application                                      */
/*                                                                         */
/*  contents   : Customer main procedures                                  */
/*                                                                         */
/*  Change     :                                                           */
/***************************************************************************/
/*
    $LogWavecom: G:\projet\mmi\pvcsarch\archives\open-mmi\SAMPLES\adl\New_Project\src\appli.c-arc $
 * --------------------------------------------------------------------------
 *  Date     | Author | Revision       | Description
 * ----------+--------+----------------+-------------------------------------
 *  25.10.05 | DPO    | 1.1            | * New V4 interface
 * ----------+--------+----------------+-------------------------------------
 *  16.12.02 | dpo    | 1.0            | Initial revision.
 * ----------+--------+----------------+-------------------------------------
*/

#include "adl_global.h"


/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;

s8 handle;

/***************************************************************************/
/* Local variables */
/***************************************************************************/
void SimHandler(u8 Event);
void SmsCtrlHandler( u8 Event, u16 Nb );
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText );


/***************************************************************************/
/* Local functions */
/***************************************************************************/
void DELAY (u8 ID, void * Context){}
void SimHandler(u8 Event)
{
TRACE((1, " In Sim Handler"));
switch(Event)
{
case ADL_SIM_EVENT_REMOVED:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_REMOVED");
break;
case ADL_SIM_EVENT_INSERTED:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_INSERTED");
break;
case ADL_SIM_EVENT_FULL_INIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FULL_INIT");
adl_smsSend( handle, "8110673201" , "Ya lo logramos...", ADL_SMS_MODE_TEXT );
adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, DELAY);
adl_smsSend( handle, "8117937391" , "Ya lo logramos...", ADL_SMS_MODE_TEXT );
break;
case ADL_SIM_EVENT_PIN_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_ERROR");
break;
case ADL_SIM_EVENT_PIN_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_OK");
break;
case ADL_SIM_EVENT_PIN_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_WAIT");
break;
case ADL_SIM_EVENT_PUK_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_WAIT");
break;
case ADL_SIM_EVENT_PUK_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_ERROR");
break;
case ADL_SIM_EVENT_FAILURE:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FAILURE");
break;
case ADL_SIM_EVENT_NET_LOCK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_NET_LOCK");
break;
}
}
void SmsCtrlHandler( u8 Event, u16 Nb )
{
TRACE((1, " IN SMS Ctrl handler"));
switch(Event)
{
case ADL_SMS_EVENT_SENDING_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_OK");
break;
case ADL_SMS_EVENT_SENDING_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_ERROR");
break;
case ADL_SMS_EVENT_SENDING_MR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_MR");
break;
}

}
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText )
{
TRACE((1, " IN SMS data handler"));
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Phone Number: ");
adl_atSendResponse(ADL_AT_RSP, SmsTel);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Time: ");
adl_atSendResponse(ADL_AT_RSP, SmsTimeOrLength);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Text: ");
adl_atSendResponse(ADL_AT_RSP, SmsText);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
return TRUE;

}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, "Embedded Application : Main" ));

// TO DO : Add your initialization code here
adl_simSubscribe ((adl_simHdlr_f)SimHandler, NULL);
handle = adl_smsSubscribe((adl_smsHdlr_f)SmsHandler, (adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT );
}

}

I think you should wait for the event that confirms that one send operation has completed before you attempt another…

Ok Now I know were was the mistake. I was not waiting for the event SMS_SENDING_OK…but know with this code I can simply send a different message to three different cellphones. I just simply added a counter and check in the SMS_SENDING_OK event the number of that counter and depending on that I send a message to that particular cellphone.

Obviously the messages are sent in a secuential mode and not at the mean time…Because I have read that this action is impossible, I mean, someone cannot send multiply messages at the mean time with this kind of modems. Correct me if I am wrong…

well here is my new code…

/********************************************************************************************/
/*  Appli.c   -  Copyright Wavecom S.A. (c) 2002										    */
/*																							*/
/*																							*/
/* DISCLAIMER OF WARRANTY																    */
/* ======================																    */
/* This Software is provided free of charge on an 'as is' basis. No warranty is given       */
/* by Wavecom S.A. in relation to the Software of the uses to which it may be put by you,   */
/* the user, or its merchantability, fitness or suitability for any particular purpose      */
/* or conditions; and/or that the use of the Software and all documentation relating        */
/* thereto by the Licensee will not infringe any third party copyright or other             */
/* intellectual property rights. Wavecom S.A. shall furthermore be under no obligation      */
/* to provide support of any nature for the Software and the Documentation.				    */
/*																						    */
/* LIMIT OF LIABILITY																	    */
/* ==================																		*/
/* In no event shall Wavecom S.A. be liable for any loss or damages whatsoever or howsoever	*/
/* caused arising directly or indirectly in connection with this licence, the Software,		*/
/* its use or otherwise except to the extent that such liability may not be lawfully		*/
/* excluded. Notwithstanding the generality of the foregoing, Wavecom S.A. expressly		*/
/* excludes liability for indirect, special, incidental or consequential loss or damage		*/
/* which may arise in respect of the Software or its use, or in respect of other equipment	*/
/* or property, or for loss of profit, business, revenue, goodwill or anticipated savings.	*/
/*																						    */
/********************************************************************************************/

/***************************************************************************/
/*  File       : Appli.c                                                   */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application                                      */
/*                                                                         */
/*  contents   : Customer main procedures                                  */
/*                                                                         */
/*  Change     :                                                           */
/***************************************************************************/
/*
    $LogWavecom: G:\projet\mmi\pvcsarch\archives\open-mmi\SAMPLES\adl\New_Project\src\appli.c-arc $
 * --------------------------------------------------------------------------
 *  Date     | Author | Revision       | Description
 * ----------+--------+----------------+-------------------------------------
 *  25.10.05 | DPO    | 1.1            | * New V4 interface
 * ----------+--------+----------------+-------------------------------------
 *  16.12.02 | dpo    | 1.0            | Initial revision.
 * ----------+--------+----------------+-------------------------------------
*/

#include "adl_global.h"


/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;

s8 handle;

/***************************************************************************/
/* Local variables */
/***************************************************************************/
void SimHandler(u8 Event);
void SmsCtrlHandler( u8 Event, u16 Nb );
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText );
int counter;

/***************************************************************************/
/* Local functions */
/***************************************************************************/
void DELAY (u8 ID, void * Context){}
void SimHandler(u8 Event)
{
TRACE((1, " In Sim Handler"));
switch(Event)
{
case ADL_SIM_EVENT_REMOVED:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_REMOVED");
break;
case ADL_SIM_EVENT_INSERTED:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_INSERTED");
break;
case ADL_SIM_EVENT_FULL_INIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FULL_INIT");
adl_smsSend( handle, "8110673201" , "Mensaje para Gera...", ADL_SMS_MODE_TEXT );
counter = 2;
break;
case ADL_SIM_EVENT_PIN_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_ERROR");
break;
case ADL_SIM_EVENT_PIN_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_OK");
break;
case ADL_SIM_EVENT_PIN_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_WAIT");
break;
case ADL_SIM_EVENT_PUK_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_WAIT");
break;
case ADL_SIM_EVENT_PUK_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_ERROR");
break;
case ADL_SIM_EVENT_FAILURE:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FAILURE");
break;
case ADL_SIM_EVENT_NET_LOCK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_NET_LOCK");
break;
}
}
void SmsCtrlHandler( u8 Event, u16 Nb )
{
TRACE((1, " IN SMS Ctrl handler"));
switch(Event)
{
case ADL_SMS_EVENT_SENDING_OK:
	if (counter == 2)
	{
		adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_OK");
		adl_smsSend( handle, "8117937391" , "Mensaje para Dany...", ADL_SMS_MODE_TEXT );
		counter ++;
		break;}
	if (counter == 3)
		{
		adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_OK");
		adl_smsSend( handle, "8115315698" , "Mensaje para Mike...", ADL_SMS_MODE_TEXT );
		counter ++;
		break;}
	else break;
case ADL_SMS_EVENT_SENDING_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_ERROR");
break;
case ADL_SMS_EVENT_SENDING_MR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_MR");
break;
}

}
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText )
{
TRACE((1, " IN SMS data handler"));
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Phone Number: ");
adl_atSendResponse(ADL_AT_RSP, SmsTel);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Time: ");
adl_atSendResponse(ADL_AT_RSP, SmsTimeOrLength);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Text: ");
adl_atSendResponse(ADL_AT_RSP, SmsText);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
return TRUE;

}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, "Embedded Application : Main" ));

// TO DO : Add your initialization code here
adl_simSubscribe ((adl_simHdlr_f)SimHandler, NULL);
handle = adl_smsSubscribe((adl_smsHdlr_f)SmsHandler, (adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT );

}
case ADL_SIM_EVENT_PIN_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_ERROR");
break;
case ADL_SIM_EVENT_PIN_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_OK");
break;
case ADL_SIM_EVENT_PIN_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PIN_WAIT");
break;
case ADL_SIM_EVENT_PUK_WAIT:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_WAIT");
break;
case ADL_SIM_EVENT_PUK_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_PUK_ERROR");
break;
case ADL_SIM_EVENT_FAILURE:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_FAILURE");
break;
case ADL_SIM_EVENT_NET_LOCK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SIM_EVENT_NET_LOCK");
break;
}
}
void SmsCtrlHandler( u8 Event, u16 Nb )
{
TRACE((1, " IN SMS Ctrl handler"));
switch(Event)
{
case ADL_SMS_EVENT_SENDING_OK:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_OK");
break;
case ADL_SMS_EVENT_SENDING_ERROR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_ERROR");
break;
case ADL_SMS_EVENT_SENDING_MR:
adl_atSendResponse(ADL_AT_RSP, "\r\nADL_SMS_EVENT_SENDING_MR");
break;
}

}
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText )
{
TRACE((1, " IN SMS data handler"));
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Phone Number: ");
adl_atSendResponse(ADL_AT_RSP, SmsTel);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Time: ");
adl_atSendResponse(ADL_AT_RSP, SmsTimeOrLength);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
adl_atSendResponse(ADL_AT_RSP, "\r\nSMS Text: ");
adl_atSendResponse(ADL_AT_RSP, SmsText);
adl_atSendResponse(ADL_AT_RSP, "\r\n");
return TRUE;

}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, "Embedded Application : Main" ));

// TO DO : Add your initialization code here
adl_simSubscribe ((adl_simHdlr_f)SimHandler, NULL);
handle = adl_smsSubscribe((adl_smsHdlr_f)SmsHandler, (adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT );
}

}

What happens if the send fails…?

Yes, that’s correct.

BTW: I think you mean “at the same time” rather than “at the mean time” ?