Value from callback

I need SN of SIM card. So I call this

adl_atCmdSend("AT+CCID", (adl_atRspHandler_t)CCID_Handler, "*", NULL);

in function getSIMSN().
In handler I save SIM SN to global variable and then wait in getSIMSN() for variable to be filled.

As I learned from searching throught forum, this is not the right way and application will wait forever.
What is the right way?
Semaphores? Id documentation is mentioned semaphores work only on high level. I’m guessing AT command is not high level. So I cannot use semaphores!?!?

What can I do?

PS: I’m new to event driven OS, so be gentle with me. :wink:

If event-driven programming is new to you, maybe start from beginning is the best way?:

[url]https://forum.sierrawireless.com/t/good-paper-on-event-driven-programming/3848/2]

You can find some more links on this forum.