Problem with adl_smsSend()

I am trying to send sms to a particular number using adl.
I have subscribed to sms service using

adl_smsSubscribe( SmsHandler, SmsCtrlHandler, ADL_SMS_MODE_TEXT );

and I can receive SMS and its information(sender no,sms text etc) in the SmsHandler.
My problem is that when I am trying to send SMS by
adl_smsSend( (u8)SMSHDL, SmsTel, SmsText, ADL_SMS_MODE_TEXT );
(where SmsTel and SmsText are two string arrays)
it is alyays returning ADL_RET_ERR_BAD_STATE and SMS is not sent.
But When I tried to send SMS with AT+CMGS to a particular number it is fine then.
Please help me to send sms using ADL.

Does your ADL application wait and insure that the unit is fully ready before attempting to send the SMS; ie, SIM fully initialised; GSM fully registered, etc…?

See also: viewtopic.php?f=4&t=994&p=3515&hilit=ADL_RET_ERR_BAD_STATE#p3515

and: viewtopic.php?f=30&t=928&p=3234&hilit=ADL_RET_ERR_BAD_STATE#p3234

I have used the adl_simSubscribe() API.But the datahandler of this API is not even called as I am getting no responses from the datahandler as mensioned in the ADL user guide.Bt still I am getting responses from the datahandler of adl_smsSubscribe when some SMS is received and I can alsosend SMS with AT commands(AT+CMGS).
If the sim is not subscribed properly then how I am getting the later responses?
I am using NULL as the PIN in adl_simSubscribe() as I got no specific PIN for my airtel connection.But I am still getting
CPIN:OK when I am issuing AT+CPIN?
Please help.

Do you use A&D storage?
That seemed to be the cause of my “receives but won’t send” problem… :angry:

I havent used any A&D storage.

Hi DIP,

Error code -8 (ADL_RET_ERR_BAD_STATE) is returned by adl_smsSend API in the following cases.

• When the initialization of the Wireless CPU is not complete
• When another SMS is being sent at that time.

For the first case, it’s recommended to execute this API in application only after WIND:4 is received.

In case the application has subscribed for the SIM event then it should be sent after event “SIM state of 3” (Full initialization complete).

For the second case (which seems to be the one faced by you), you need to be sure that there is no SMS being sent at the same time. If you are planaing to send several SMS in a short time, it’s recommended to use AT+CMMS command.

The behaviour could also occur because when an SMS is being sent another command should not be sent from the external application. This case could be prevented after implementing the following steps :

  1.   After “adl_smsSend ()” API is called, block all AT commands by doing a CMD Subscribe. This can be done using the following statement:
    

“adl_atCmdSubscribe ( “AT”, AT_Cmd_Handler, ADL_CMD_TYPE_ACT | ADL_CMD_TYPE_ROOT)”.

  1.   If any AT command is received, in the “adl_atCmdSubscribe ()” API callback handler, return “+CME ERROR: 515”. This informs the external application that the Open AT® Library is busy processing a command
    
  2.   After “ADL_SMS_EVENT_SENDING_OK” or “ADL_SMS_EVENT_SENDING_ERROR” event is received in the callback handler, perform “adl_atCmdUnSubscribe()” to unblock AT command from the external application.
    

This procedure prevents the error -8 (ADL_RET_ERR_BAD_STATE). It must also be noted that no command should be created (using adl_atCmdCreate () API) until the Wireless CPU has received an event pertaining to the SMS which is being sent. In other words, between steps 1 and 3, no command should be created using adl_atCmdCreate () API. This API should be used only after you receive an ADL_SMS_EVENT_SENDING_OK” or “ADL_SMS_EVENT_SENDING_ERROR” event in the callback handler.

Hope it helps

There are other cases - i had one to do with problems in the A&D storage; maybe DIP has found another…?

Thanks Awneil for your quick answer. I’ve sent you a personal message only to be sure that you will read it as soon as possible. I will post this at the “Shareware -> Sample Applications -> Problem with adl_smsSend” topic.
I’m refering to the problem with the adl_smsSend function which keeps returning ADL_RET_ERR_BAD_STATE.
I’ve found out that my modem (Q24PL001, OpenAT V3.16) does not receive the ADL_SIM_EVENT_FULL_INIT event. Further more, it doesn’t receive any +WIND events after WOPEN=1, although I’m subscribing to them. Do you have any idea what might be wrong?

Hi all,

I’ve used adl_adRecompact function at the beginning of OpenAt application (after every reset/power on) and the WIND:4 indication and the full sim card init indication both came back. Now I can use adl_smsSend with no problem.