How to check account of SIM in Fastrack supreme 20

Hi, All

I have a problem when using adl_atCmdCreate to send AT+CUSD command and get Response. Followings is my code:

void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, “Embedded Application : Main” ));
adl_atSendResponse(ADL_AT_UNS,“IRQ Measure Application: Main\r\n”);
// TO DO : Add your initialization code here
adl_tmrSubscribe(FALSE,600,ADL_TMR_TYPE_100MS,Check_account);
}

void Check_account(void)
{

adl_atSendResponse(ADL_AT_UNS,"Vao ham AT command\r\n");
adl_atCmdCreate("AT+CUSD= 1,\"*101#\"", ADL_AT_PORT_TYPE ( ADL_PORT_OPEN_AT_VIRTUAL_BASE, FALSE ), (adl_atRspHandler_t) atRspHandler, NULL);

}

s32 atRspHandler(adl_atResponse_t *paras)
{
TRACE((1, “Reponse handled”));
adl_atSendResponse(ADL_AT_UNS,“Reponse handled”);
TRACE((1, paras->StrData));
adl_atSendResponse(ADL_AT_UNS,paras->StrData);
return FALSE;
}

And when I download the code into Fastrack. it gives out responses as follow:

IRQ Measure Application: Main
Vao ham AT command
+CUSD: 2,“QUY KHACH CO 50125 DONG TRONG TAI KHOAN CHINH VA 49486 DONG TRONG TAI
KHOAN THUONG. THOI HAN SU DUNG DEN 03/12/2009”,15

It seems not to invoke the s32 atRspHandler(adl_atResponse_t *paras) functions. Is there any thing wrong?
Please help me.

Because you must indicate which kind of AT responses you need when you “create” it. In your case, type:

adl_atCmdCreate("AT+CUSD= 1,\"*101#\"", ADL_AT_PORT_TYPE ( ADL_PORT_OPEN_AT_VIRTUAL_BASE, FALSE ), (adl_atRspHandler_t) atRspHandler, "+CUSD: " ,NULL);

This may work. I made the same mistake the first time I used adl_atCmdCreate… :smiley:

I think you’ll find that the +CUSD is an unsolicited response…

I replaced my code with
adl_atCmdCreate(“AT+CUSD= 1,”*101#"", ADL_AT_PORT_TYPE ( ADL_PORT_OPEN_AT_VIRTUAL_BASE, FALSE ), (adl_atRspHandler_t) atRspHandler, "+CUSD: " ,NULL);

but the result was the same. the atRspHandler function was not still invoked.

awneil was wrigth: +CUSD: is an unsolicited response. :blush:
Additionally you have to use:

adl_atUnSoSubscribe("+CUSD: ", atUnSoHandler);

Where atUnSoHandler has the same functionallity than atRspHandler in your original code.

Hi, I followed what you said: using adl_atUnSoSubscribe("+CUSD: ", atUnSoHandler) function and the result was great.
I did get the response string in the atUnSoHandler.

Thank you very much!!!

Excellent! :smiley:

Are you happy that you now understand the difference between an immediate repsonse to a command, and an unsolicited response?

Let me expand on that, lest it be taken the wrong way:

With AT commands (all AT commands - not just Wavecom and not just GSM), “response” is the general term for anything that comes from the modem when in command mode.

These responses can be either “solicited” or “un-solicited”

  • Solicited responses come as a direct reply to entering a command; eg, the OK or ERROR;
  • un-solicited responses are not in direct reply to entering a command; they are caused by effectively asynchronous events; eg +RING:

It is important to understand this distinction so that they can be appropriately handled; in particular, in Open-AT, they need different API calls in order to “catch” them.

Since this distinction was the key to phamduong537’s problem, the intention of my post was to confirm that he had fully understood the point - it wasn’t a sarcastic comment, and it wasn’t directed to fer.caballero
My apologies if it appeared otherwise.