ed_SendMail with ED_ERR_STACK_BUSY


#1

Hello,

I’m sorry my issue should be quite simple and I might have been able to find answers in the forum. But I am completely new in the Open AT world and I have an issue that I must solve rapidly.

I use the ed_SendMail function to send an email and systematicly get the ED_ERR_STACK_BUSY error.

my smtp parameters are correct and here is what I do when sending a mail :

scannerParams.email.Id = 1;
wm_strcpy(scannerParams.email.CcRec, "");
wm_strcpy(scannerParams.email.Subj, "");
wm_strcpy(scannerParams.email.Body, Rsp);
result = ed_EmailSetConfig(&scannerParams.email);
TRACE((8, "Scan (mail): ed_EmailSetConfig() == %d", result));
resultEmail = ed_SendMail(1, ResponseCbkScanner);
TRACE((8, "Scan (mail): ed_SendMail() == %d", resultEmail));
if ((result != 0) ||(resultEmail != 0))
	{
		if ((result == ED_ERR_PHY_NOT_ACTIVATED) ||(resultEmail == ED_ERR_PHY_NOT_ACTIVATED))
		{
			/* Attach to GPRS */
			adl_atCmdCreate("AT+CGATT=1", FALSE, adl_atRspHandler_t)Cgatt_handler,"*", NULL);
			TRACE ((8, "SendData: sent AT+CGATT=1"));
		}
...

I found the meaning of this error : “another IP connectivity librar application is already running” but this is not really helping me as I am new.

Could someone help me ?

thanks

Veranith


#2

Hi Veranith,
Please check out the following points to be able to send e-mail from your Open-AT application:

  1. Wait for ADL_SIM_EVENT_FULL_INIT. You can do this by subscribing to SIM service and when this event is received in the SIM handler function. Proceed to the next point 2.
  2. Attach to the GPRS network. THis can be done using adl_atCmdCreate () API and the command to give is AT+CGATT=1.
  3. If your GPRS attach is successful, then you set the GPRS parameters (i.e APN, username, password). You should use ed_GprsSetConfig () API to set these parameters.
  4. Use ed_DialupConnectionStart () API. When ED_INFO_GPRS_SESSION_SET is received in the handler function provided for ed_DialupConnectionStart (). Proceed next.
  5. Set the SMTP parameters (using ed_SMTPSetConfig () API). Make sure to provide all the parameters correctly.
  6. Set the email parameters (using ed_emailSetConfig () API). Make sure to provide all the parameters correctly (i.e. CCRec, Rec etc).
  7. Check out the return value of all the APIs that you use.
  8. Also make sure that there is no invalid pointer operation (i.e. all of your pointers have enough memory allocated for the values that you assign).
  9. Now you call ed_SendMail () function to send the mail.

Follow all the above points and still you are not able to send the mail (i.e. all the pointer operations are correct, parameters are correct.

In case, you are trying to execute the application in debug mode, please delete the contents of /project_workspace/rte/objects folder. Sometimes, incorrect contents of this folder (where all the flash parameters are stored by eDlib) lead to similar errors.
You should also try to execute the application in target mode and check out if the problem occurs.

Best Regards,
Open AT Fan.


#3

Hi OpenAT Fan,

Thank you for your answer.

I did all or your steps :
1/ wait for ADL_SIM_EVENT_FULL_INIT
2/ I am attached to the GPRS network with the right parameters (apn…)
3/ my smtp parameters are correct :
4/ all the API’s return 0.

Now I know a TCP socket is already opened when I try to send my email. can there be a conflict with it ?
should I close all TCP sockets before sending an email ? if so, How can I close a TCP Socket ?

thanks a lot.

Veranith


#4

Hello veranith,
You are correct in understanding that if your TCP socket is active, you will not be able to send mail. You can use only one service at a time (for example, you can use either TCP or UDP or SMTP or POP3). You cannot use any of the services simultaneously.

To close the established socket, you have to call ed_SendDataExt () API with the third parameter set to TRUE. This will indicate to eDLib that you want to close the active socket connection.

In case, you have opened a listening server which has not been connected with any client, you can use ed_SocketLTCPStop () API to close the listening server.

However, once the server is contacted by a client, you have to use ed_SendDataExt () with third parameter set to TRUE to close the socket. The same holds true for a client socket also. Hence you can use
ed_SendDataExt (NULL,0,TRUE,ED_ID_TCPSOCKET_1);
This will close the client/active server socket (i.e. server socket with which a client is connected).

After you receive an event in the TCP (ED_OK_TCP_CLOSED), you can start your SMTP session using ed_SendMail () or ed_PutMail () API.

You should follow the steps 5 to 9 as specified in my previous post after receiving this event.

Hope this helps.

Best Regards,
Open AT Fan.


#5

Hi Open AT Fan,

I did end all active services before sending an email with ed_SendDataExt as you told me. now the email has been correctly sent !!!
Your answers were really accurate and efficient !!! You saved me a lot of time .
Thanks again

Veranith