Execution of handler function

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()

	ascii string[20];
                                                              //incoming 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)
        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?


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

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.