Help sending SMS

Hello, I try this piece of code, it’s build, run but I never received any SMS…

#include "adl_global.h"

const u16 wm_apmCustomStackSize = 1024*3;

s32 sms_automaton_Handle_txt;

bool SMS_AUTO_Handler(u8 ID, void * Context){return TRUE;}
void SMS_AUTO_ctrl_Handler(u8 ID, void * Context){}

void adl_main ( adl_InitType_e  InitType ){
    adl_atSendResponse ( ADL_AT_UNS, "\r\nApp Begin\r\n" );
    sms_automaton_Handle_txt = adl_smsSubscribe(SMS_AUTO_Handler, SMS_AUTO_ctrl_Handler, ADL_SMS_MODE_TEXT);
    adl_smsSend(sms_automaton_Handle_txt, "0686160083", "Hello_World", ADL_SMS_MODE_TEXT);
    adl_atSendResponse ( ADL_AT_UNS, "\r\nSMS Send\r\n" );
}

Any idea or tips??

I finaly found the pb, I try to send sms to soon, the sms process is not yet ready (adl_smsSend return -8 == ADL_RET_ERR_BAD_STATE if service is not ready to send SMS)

with this piece of code:

#include "adl_global.h"

const u16 wm_apmCustomStackSize = 1024*3;

s32 sms_automaton_Handle_txt;

bool SMS_AUTO_Handler(ascii *SmsTel, ascii *SmsTimeLength, ascii *SmsText){return TRUE;}
void SMS_AUTO_ctrl_Handler(u8 Event, u16 nb){return ;}

void envoi_sms(u8 ID, void * Context){
	static int compte = 0;
	int a;
	ascii   Bufferdebug[ 200 ];
	ascii   Buffer[ 200 ];
	wm_sprintf ( Buffer, "Sms n°%d: \r\n", compte );
	a = adl_smsSend(sms_automaton_Handle_txt, "0686160084", Buffer, ADL_SMS_MODE_TEXT);
	wm_sprintf ( Bufferdebug, "smsSend = %d: \r\n", a );
	adl_atSendResponse ( ADL_AT_UNS, Bufferdebug );
}

void adl_main ( adl_InitType_e  InitType ){
    TRACE (( 1, "Embedded : Appli Init" ));
    adl_atSendResponse ( ADL_AT_UNS, "\r\nApp Begin\r\n" );
    sms_automaton_Handle_txt = adl_smsSubscribe(SMS_AUTO_Handler, SMS_AUTO_ctrl_Handler, ADL_SMS_MODE_TEXT);
    adl_tmrSubscribe ( TRUE, 600, ADL_TMR_TYPE_100MS, envoi_sms );
}

that works good

Hi Seb,
We are currently working on a project in which we must send an sms. We have a Fastrack Supreme 20 and your code interest us very much. Nevertheless, we have got a problem with Eclipse to compilate your program. Can you tell us more about the "#include “adl_global.h”? Have you included others headers files? We would like to know if you have used the “sms_automaton” sample…

We have the following errors :
00 [time=00] -> line 0
enter new zip file comment *00:00 -> line 0
enter new zip file comment *DiagnoseTips.ini(176bytes security)(deflated 87%)

Thank u very much

I think sebastien-2.sarrazin code needs improvement. Normally before sending SMS, the application needs to call adl_simSubscribe first, then to check and wait for ADL_SIM_EVENT_FULL_INIT event, finally to call adl_smsSubscribe.

Hi seb I am working on the same thing sending sms can u help what are steps i have to take sending sms receving sms.
sim subcrbition is necessary for sending sms…

To be precise, it needs to wait until the unit is ready to send SMS.

The first step to that, as you say, is the the SIM must be ready - you can test that either with the SIM events, or use WIND events.
(Please search the forum for issues regarding SIM_FULL_INIT - particularly in RTE mode)

After the SIM is ready, you then have to wait for the unit to gain GSM registration.

Only then is it actually ready to send (and receive) SMS…

HI i ATTACTHED FINAL WORKING CODE SENDING SMS AND RECEIVE SMS BY USING Q2686 .
IF ANY PROBLEMS PLESASE ASK …

//
/* Appli.c - Copyright Wavecom S.A. © 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;

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 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, “9844126494”, “SMS From OpenAT Application”, 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 );

}