hi all,
Here is the code i have written for sending sms daily at 12 O’clock
but there is some problem after downloading the program to the module module is getting corrupted but whil debugging till the stage of print hour and minute is working after that not working can anyone pls go through the code and tell me what is the problem?
#include “adl_global.h”
/***********************************************************************/
/ Mandatory variables /
/-------------------------------------------------------------------------/
/ wm_apmCustomStack /
/ wm_apmCustomStackSize /
/-------------------------------------------------------------------------/
/***************************************************************************/
u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );
ascii buffer[100],time[10],hr[5],min[5];
u16 len,i=0,c=0;
bool flag=0;
ascii h[5],mn[5];
s8 SMSHandle;
/**************************************************************************/
/ Local variables /
/**************************************************************************/
bool rsphdl(adl_atResponse_t paras);
void Sim_Handler(u8 Event);
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText );
void SmsCtrlHandler( u8 Event, u16 Nb );
/*************************************************************************/
/ Local functions /
/**************************************************************************/
bool rsphdl(adl_atResponse_t *paras)
{
TRACE (( 1, “Embedded Application : rsphdl handler” ));
wm_strcpy(buffer, paras->StrData );
len= paras->StrLength;
/* for(i=0;i<len;i++)
{
if(buffer[i]!=’\’)
a[i]=buffer[i];
c++;
}
for(i=0;i<c;i++)
{
adl_atSendResponse(ADL_AT_RSP, a[i]);
adl_atSendResponse(ADL_AT_RSP,"\r\t");
}*/
//adl_atSendResponse(ADL_AT_RSP,""");
for(i=len/2+4;i<len-2;i++)
{
time[c++]=buffer[i];
}
time[--c]='\0';
i=0;
hr[0]=time[0];
hr[1]=time[1];
min[0]=time[3];
min[1]=time[4];
adl_atSendResponse(ADL_AT_RSP, buffer);
adl_atSendResponse(ADL_AT_RSP,"\r\n");
adl_atSendResponse(ADL_AT_RSP, time);
adl_atSendResponse(ADL_AT_RSP,"\r\n");
/*adl_atSendResponse(ADL_AT_RSP, hr);
adl_atSendResponse(ADL_AT_RSP,"\r\n");
adl_atSendResponse(ADL_AT_RSP, min);
adl_atSendResponse(ADL_AT_RSP,"\r\n");*/
h[0]='1';h[1]='1';
mn[0]='0';mn[1]='0';
if(hr[0]==h[0]&&hr[1]==h[1]&&mn[0]==0&&mn[1]==0)
flag=1;
//send sms
/* if(flag)
{
adl_atSendResponse(ADL_AT_RSP, time);
flag=0;
}*/
return TRUE;
}
void Sim_Handler(u8 Event)
{
TRACE (( 1, “Embedded Application : Sim_Handler” ));
switch(Event)
{
case ADL_SIM_STATE_INIT:
break;
case ADL_SIM_STATE_REMOVED:
break;
case ADL_SIM_STATE_INSERTED:
break;
case ADL_SIM_STATE_FULL_INIT:// event for SIM full init( SIM is fully regestered with network)
TRACE (( 1, “Embedded Application : ADL_SIM_STATE_FULL_INIT” ));
// SMS Subscribing
adl_smsSubscribe( (adl_smsHdlr_f)SmsHandler, (adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT );
// Sending SMS
if(flag)
{
adl_smsSend(SMSHandle, “xxxxxxxx”, “iAMR-GSM SMS testing”, ADL_SMS_MODE_TEXT );// you have give your phone number.
flag=0;
}
break;
case ADL_SIM_STATE_PIN_ERROR:
break;
case ADL_SIM_STATE_PIN_OK:
break;
case ADL_SIM_STATE_PIN_WAIT:
break;
}
}
// SMS handler(It takes care about receiving SMS)
bool SmsHandler( ascii * SmsTel, ascii * SmsTimeOrLength, ascii * SmsText )
{
TRACE (( 1, “Embedded Application : SmsHandler” ));
adl_atSendResponse(ADL_AT_RSP, SmsTel);
adl_atSendResponse(ADL_AT_RSP, “\r\n”);
adl_atSendResponse(ADL_AT_RSP, SmsTimeOrLength);
adl_atSendResponse(ADL_AT_RSP, “\r\n”);
adl_atSendResponse(ADL_AT_RSP, SmsText);
return TRUE;
}
// SMS control handler( It takes care about sending SMS)
void SmsCtrlHandler( u8 Event, u16 Nb )
{
TRACE (( 1, “Embedded Application : SmsCtrlHandler” ));
switch(Event)
{
case ADL_SMS_EVENT_SENDING_OK:
TRACE (( 1, “Embedded Application : ADL_SMS_EVENT_SENDING_OK” ));
adl_atSendResponse(ADL_AT_RSP, “\r\n SMS EVENT SENDING OK \r\n”);
break;
case ADL_SMS_EVENT_SENDING_ERROR:
TRACE (( 1, “Embedded Application : ADL_SMS_EVENT_SENDING_ERROR” ));
adl_atSendResponse(ADL_AT_RSP, “\r\n SMS EVENT SENDING ERROR \r\n”);
break;
}
}
/*******************************************************************/
/ 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
// API For Creating Standard AT Command.
adl_atCmdCreate("AT+CCLK?", TRUE, (adl_atRspHandler_t)rsphdl,"*", NULL);
adl_simSubscribe((adl_simHdlr_f)Sim_Handler, NULL );
}