I don’t know how to solve this problem because it seems rather difficult
And I have red some posts related to this problem but i still haven’t got a solution
i checked the program and i found that when i send a SMS using adl_smsSend(),it always returns ADL_RET_ERR_BAD_STATE.
And my sim-card seems never finishes initing work. AT commands is ok.
Here is my code,can somebody do me a fovor?
Please use the CODE button to format your code - it makes it a lot easier for everyone else to read…
After a quick look over your code, it looks like you are not testing for the SIM to have finished initialization (and the modem to have registered to the network) before trying to send the SMS (i.e. checking the result of adl_simGetState()after attempting to send the sms using adl_smsSend()).
Try something like this (pseudo code):
Set up SMSHandler function
Set up SMS_Send_Function (i.e. calls adl_smsSend())
Set up pollCreg() function to wait for network registration after SIM has initialized
set timer and repoll at+creg?
Set up SIM_Handler_function:
Set up initial_Timeout_Handler() (i.e. delay for a few seconds after application starts)
mySimState = adl_simGetState();
// need to wait for SIM to initialize
// and subscribe to SIM handler
// test if SIM required in simHandler
adl_simSubscribe( gprs_simHandler, (ascii *)NULL);
if( mySimState == ADL_SIM_EVENT_FULL_INIT ) // SIM already OK, go straight to AT+CREG?
pollCreg( 0 ); /* argument 0 is dummy, see poll_reg() "Object" comment */
if ( mySimState == ADL_SIM_EVENT_PIN_WAIT ) // waiting for SIM PIN
set up one-shot timer to start rest of application.
To see exactly the steps required to check the SIM state and network registration, have a look at the WIP library samples - especially anything do to with GPRS setup as this process also has to wait for SIM init and network registration.
Thanks for your reply.I’ve tried using adl_simGetState,but it always returns ADL_SIM_STATE_PIN_OK
,and never changes.
The main problem is i don’t konw whether i need to finish the initing work with some function?
It seems like that when it runs the embedded program,it’s never switches to the ADL_SIM_STATE_FULL_INIT state.
I’m probably don’t know the meaning of “wait”,when should i wait?
I found that everytime when i start the program,the sim initialization begins too.
So does that means i should use some delay function at the beginning of the program? If it does,how long should I wait for?
I don’t think i’m in RTE mode,I download the program into the module,then use AT+cfun=1,at+wopen=1 to run it
Now the module responses +wind 32767 when i use AT+wind? command,i don’t know if it means that i have enabled the WIND indication.
And i also changed some other values like creg,atq,atv as the ADL GUIDER.PDF says
I’m sorry maybe my statement is a little foolish,but i’m a rookie indeed