bool gms_register_handler (adl_atUnsolicited_t *param)
{
if (GSM_ini==1 && GSM_reg==0) //Se debe registrar una sola vez.
{
GSM_reg=1;
TRACE (( 1, “[gms_register_handler]:SIM_REGISTRADO” ));
}
return TRUE;
}
bool gms_unregister_handler (adl_atUnsolicited_t *param)
{
if (GSM_ini==1 && GSM_reg==1)
{
TRACE (( 1, “[gms_unregister_handler]:SIM NO REGISTRADO.REINTENTADO…” ));
GSM_reg=0;
}
else
{
TRACE (( 1, “[gms_unregister_handler]:SIM NO REGISTRADO” ));
}
TRACE (( 1, “[gms_unregister_handler]:SIM NO REGISTRADO” ));
return TRUE;
}
When i run the apllication, it never go inside those handlers. But if y enter “AT+CREG?” the answer is “+CREG: 0,1” so i assume its registered!.
Can anyone help me?. Thanks!.
Well, actually i didint, but when i posted for some reason it appeared like that.
The important code in the hole aplicattion is this:
adl_simSubscribe(SimHandler,NULL); //First of all, i suscribed here
....
....
....
//in SimHandler
case ADL_SIM_STATE_FULL_INIT: //I reached here without problems
...
...
...
//in an other part of the code
adl_atUnSoSubscribe("+CREG: 1",gms_register_handler) // I need the +CREG: 1 response.
...
...
...
//in the handler
bool gms_register_handler (adl_atUnsolicited_t *param) //It never reaches here.
{
if (GSM_ini==1 && GSM_reg==0) //Se debe registrar una sola vez.
{
GSM_reg=1;
TRACE (( 1, "[gms_register_handler]:SIM_REGISTRADO" ));
}
return TRUE;
}
So, i`ve said i cant manage to get inside “gms_register_manager”. I need the +CREG: 1 response to know the SIM registration. Thanks for advance
I think i solve it!, i change the orden of the code. I realized that the unsolicited response +CREG: 1 comes faster than the event ADL_SIM_STATE_FULL_INIT. So, now i check when both of conditions are true to know if im really registered.
As I understand it, the ADL_SIM_STATE_FULL_INIT indicates that everything including phonebook initialisations is complete;
Phonebook initialisations can take quite a long time, and are not required for GSM registration - hence registration may occur before ADL_SIM_STATE_FULL_INIT.
In practice, you just have to assume that the events could occur in either order.