ATD SIM900 response.?

I am designing an application where I am interfacing SIM900 with PIC18F2520. I am making a call to a number using ATD. Now if the receiver end do not answer the call, or if its busy, or the call cannot be made. So the current call needs to be diverted to another number. Following are the response of ATD

OK         Command Executed
ERROR      Invalid Command
BUSY       Receiving end is currently on other call
NO ANSWER  Connection failed upto time out
NO CARRIER Call failed to connect or disconnected
CONNECT    Connection set up(ATX=0)


So in my condition, I need to check if the receiver end is BUSY or NO ANSWER or NO CARRIER then make another call.

if(
(strstrrampgm(rxData,(const far rom char *)"NO CARRIER") != NULL) ||
(strstrrampgm(rxData,(const far rom char *)"BUSY") != NULL) ||
(strstrrampgm(rxData,(const far rom char *)"NO ANSWER") != NULL)
)
{
serialSendString("ATD91xxxxxx78;\r");
}


Now whats happening is when I didnt answer the current call NO ANSWER or BUSY or NO CARRIER so the if condition become true it makes another call. But if I accept the first call, GSM does not send CONNECT response instead while disconnecting the call it send NO CARRIER due to which, the if condition becomes true and second call is made (which is not required). I searched for it and found out the we need to enable ATX using ATX0, then it shows CONNECT response. I tried it but it didn't showed up the CONNECT.

Also I want to know that in which cases NO CARRIER is received. Whenever there is any network issue, it says NO CARRIER. If after connecting the call, we disconnect it, it again shows NO CARRIER. If I cut the call, sometimes it shows BUSY but sometimes (in another SIM) it shows NO CARRIER. What does NO CARRIER actually means. What conditions should I check for in my application. Please help.!

First

Use original manufacturer site as source of information about what happening and when and why. You can use SIM800 manuals, generally all GSM/GPRS modules are similar. And then try to do all possible variants of AT commands by hand to form your algorithm.

Second

There exist AT+CLCC command and it's unsolicited response +CLCC that can be enabled with command AT+CLCC=1\r\n. This response give full information about call state incoming or outgoing and incoming wait calls too. Response format as it described in SIM800 Series_AT Command Manual_V1.09

+CLCC: <id1>,<dir>,<stat>,<mode>,<mpty>[,<number>,<type>,<alphaID>]


where:

• id is call identification number 1..7
• dir is call cirection 0 - is outgoing, 1 - is incoming
• stat is current call state that can be: active (connected), held, dialing (for outgoing call), alert (after originated or terminated hangup), inconimg (while ring), wait (state of incoming call when another call already active), disconnected (call end)
• mode is voice or data call
• mpty is multiparty (conference) call or not

• number, type it is number of mobile terminated and alphaID it is related name from phone book if any found.