Execution of handler function


#1

My application has to controll the sender number of incoming SMS, these numbers are controlled against the SIM phonebook.

If the number is NOT in the SIM phonebook, no commands is to be read from SMS.

bool number_check()
{

        valid_number=FALSE;
	ascii string[20];
                                                              //incoming number
	wm_sprintf(string,"AT+CPBP=\"%s\"",reply_number);
        
        //Search for number in SIM phonebook
	adl_atCmdCreate(string,ADL_AT_PORT_TYPE ( ADL_PORT_UART1, FALSE ), (adl_atRspHandler_t) number_check_Handler,"+CPBP", NULL);

	return valid_number;
}

bool number_check_Handler(adl_atResponse_t * response)
{
	valid_number=TRUE;
        return FALSE;
}

The problem is that the number_check_handler does not change the “valid_number=TRUE” fast enough. So the function never returns TRUE. Is there some way of suspending the code execution until the number_check_handler has RUN?

Or maybe a more clever solution to my problem?

Thanks!


#2

Hi mag_knu,
If I’m wrigth you would never TRUE on number check. You sent the AT command and you never would have the call back of it until you get the control back to the OS.
This means that every service of the OS that gives you a response using a function pointer, needs you to end all your executing functions.
An easy solution is use a global variable as semaphore (or use the implemented adl library).

Any way I think is better if you use flh functions to store the telephone numbers. It’s the way I do it


#3

Ok, thanks. Flash solution sounds like a good option. For now i’ll just run the add_number function for the number_check_handler. Not very good solution… I know.

Thanks