# Execution of handler function

**URL:** <https://forum.sierrawireless.com/t/execution-of-handler-function/3154>\
**Category:** Open AT\
**Created:** [April 23, 2009, 12:04pm UTC](https://forum.sierrawireless.com/t/execution-of-handler-function/3154 "2009-04-23T12:04:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mag\_knu](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mag\_knu](https://forum.sierrawireless.com/u/mag_knu)\
**Post date:** [April 23, 2009, 12:04pm UTC](https://forum.sierrawireless.com/t/execution-of-handler-function/3154/1 "2009-04-23T12:04:14Z")

</div>

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.

```auto
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!

---

<div class="post-metadata">

**Author:** ![fer.caballero](https://avatars.discourse-cdn.com/v4/letter/f/ba9def/32.png) [@fer.caballero](https://forum.sierrawireless.com/u/fer.caballero)\
**Post date:** [April 23, 2009, 12:14pm UTC](https://forum.sierrawireless.com/t/execution-of-handler-function/3154/2 "2009-04-23T12:14:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mag\_knu](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mag\_knu](https://forum.sierrawireless.com/u/mag_knu)\
**Post date:** [April 24, 2009, 8:59am UTC](https://forum.sierrawireless.com/t/execution-of-handler-function/3154/3 "2009-04-24T08:59:31Z")

</div>

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
