I want to add entries to the SIM phonebook by sending SMS to my Fasttrack supreme. I have created the functions…but they don’t do the trick. Has anyone done something similar before?
bool SMS_AUTO_Handler(ascii *SmsTel, ascii *SmsTimeOrLength, ascii *SmsText)
{
bool sms_tobe_fwd = FALSE;
//Keyword match, SETUP
//SETUP syntax: setup add <number> <name>
if(wm_strncmp( "setup",SmsText,5 ) == 0)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\n Keyword match\r\n" );
wm_strcpy( reply_number, SmsTel);
if(wm_strncmp( "add",SmsText+6,3 ) == 0)
{
adl_atSendResponse ( ADL_AT_UNS, "\r\n Command match\r\n" );
//entry_pos=atoi(SmsText+11)
wm_strncpy(new_number, SmsText+10,8 );
wm_strcpy(entry_name,SmsText+19);
add_number();
if(smsSend_flag)
{
//Send SMS
auto_sendSms(reply_number,setup_txt);
}
}
}
}
void add_number()
{
adl_atCmdCreate("AT+CPBS?",ADL_AT_PORT_TYPE ( ADL_PORT_UART1, FALSE ), (adl_atRspHandler_t) number_storage_Handler,"+CPBS", NULL);
}
bool number_storage_Handler(adl_atResponse_t * response) {
//Store number
ascii *pos;
ascii string[50];
int number_pos=200;
adl_atSendResponse ( ADL_AT_UNS, "\r\nStorage handler\r\n" );
// Find the first ","
pos=strchr(response->StrData,',');
// number_pos = number of phonebook entries.
number_pos=atoi(pos+1);
//Create command string
wm_sprintf(string,"AT+CPBW=%d,""%s"",""129"",""%s""",number_pos+1,new_number,entry_name);
//Write new entry
adl_atCmdCreate(string,ADL_AT_PORT_TYPE ( ADL_PORT_UART1, FALSE ), (adl_atRspHandler_t) number_add_Handler,"*", NULL);
return FALSE;
}