On Saturday 03 June 2006 14:06, Rick Smith wrote:> The call gets made, I leave a voicemail, or complete the call in some
> manner, and the other side hangs up. I hear a busy signal on the phone
> on my end.
I'll bet a donut it's not a busy signal but rather a "fast
busy" which is
known as a congestion signal.
Asterisk is giving that to you because it has nothing else to do in the
dialplan. This is what I do on all my installations to make it behave more
like the phone company:
exten => 19999999999,1,Answer()
exten => 19999999999,n,Dial(SIP/100,20,g)
exten => 19999999999,n,Macro(handle-hangup)
(the trick is to make sure that 'g' is in the Dial() options, as it
instructs
Dial() to continue on in the dialplan after the channel is hung up. An
alternative would be to trap the 'h' (hangup) extension and call the
macro as
well.
The macro is pretty straightforward. Don't be put off by its size. It
tries
to do the right thing, and can handle PRI hangup causes:
-----------8<----------------------8<--------------------------8<-------------------
; handle hangup macro
; this macro attempts to go though and do something intelligent with the
HANGUPCAUSE and DIALSTATUS
[macro-handle-hangup]
exten => s,1,NoOp(HANGUPCAUSE is ${HANGUPCAUSE} and DIALSTATUS is
${DIALSTATUS})
exten => s,n,GotoIf($[${HANGUPCAUSE} = 0]?s,nohc)
exten => s,n,Goto(hc-${HANGUPCAUSE},1)
exten => s,n(nohc),GotoIf($[${DIALSTATUS} = ANSWER]?hc-16,1)
exten => s,n,GotoIf($[${DIALSTATUS} = BUSY]?hc-17,1)
exten => s,n,GotoIf($[${DIALSTATUS} = NOANSWER]?hc-19,1)
exten => s,n,GotoIf($[${DIALSTATUS} = CONGESTION]?hc-42,1)
exten => s,n,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?hc-44,1)
exten => s,n,GotoIf($[${DIALSTATUS} = CANCEL]?hc-0,1)
exten => s,n,Goto(hc-0,n)
exten => hc-0,1,NoOp(${HANGUPCAUSE} - Not Defined)
exten => hc-0,n,Goto(ind-congestion,1)
exten => hc-1,1,NoOp(${HANGUPCAUSE} - Unallocated)
exten => hc-1,n,Goto(ind-outofservice,1)
exten => hc-2,1,NoOp(${HANGUPCAUSE} - No Route to Transit Network)
exten => hc-2,n,Goto(ind-congestion,1)
exten => hc-3,1,NoOp(${HANGUPCAUSE} - No Route to Destination)
exten => hc-3,n,Goto(ind-congestion,1)
exten => hc-6,1,NoOp(${HANGUPCAUSE} - Channel Unacceptable)
exten => hc-6,n,Goto(ind-congestion,1)
exten => hc-7,1,NoOp(${HANGUPCAUSE} - Call Awarded Delivered)
exten => hc-7,n,Goto(ind-hangup,1)
exten => hc-16,1,NoOp(${HANGUPCAUSE} - Normal Clearing)
exten => hc-16,n,Goto(ind-hangup,1)
exten => hc-17,1,NoOp(${HANGUPCAUSE} - User Busy)
exten => hc-17,n,Goto(ind-busy,1)
exten => hc-18,1,NoOp(${HANGUPCAUSE} - No User Response)
exten => hc-18,n,Goto(ind-hangup,1)
exten => hc-19,1,NoOp(${HANGUPCAUSE} - No Answer)
exten => hc-19,n,Goto(ind-hangup,1)
exten => hc-21,1,NoOp(${HANGUPCAUSE} - Call Rejected)
exten => hc-21,n,Goto(ind-outofservice,1)
exten => hc-22,1,NoOp(${HANGUPCAUSE} - Number Changed)
exten => hc-22,n,Goto(ind-outofservice,1)
exten => hc-27,1,NoOp(${HANGUPCAUSE} - Destination Out-of-Order)
exten => hc-27,n,Goto(ind-outofservice,1)
exten => hc-28,1,NoOp(${HANGUPCAUSE} - Invalid Number Format)
exten => hc-28,n,Goto(ind-congestion,1)
exten => hc-29,1,NoOp(${HANGUPCAUSE} - Facility Rejected)
exten => hc-29,n,Goto(ind-congestion,1)
exten => hc-30,1,NoOp(${HANGUPCAUSE} - Response to Status Enquiry)
exten => hc-30,n,Goto(ind-hangup,1)
exten => hc-31,1,NoOp(${HANGUPCAUSE} - Normal Unspecified)
exten => hc-31,n,Goto(ind-hangup,1)
exten => hc-34,1,NoOp(${HANGUPCAUSE} - Normal Circuit Congestion)
exten => hc-34,n,Goto(ind-congestion,1)
exten => hc-38,1,NoOp(${HANGUPCAUSE} - Network Out-of-Order)
exten => hc-38,n,Goto(ind-congestion,1)
exten => hc-41,1,NoOp(${HANGUPCAUSE} - Normal Temporary Failure)
exten => hc-41,n,Goto(ind-congestion,1)
exten => hc-42,1,NoOp(${HANGUPCAUSE} - Switch Congestion)
exten => hc-42,n,Goto(ind-congestion,1)
exten => hc-43,1,NoOp(${HANGUPCAUSE} - Access Information Discarded)
exten => hc-43,n,Goto(ind-hangup,1)
exten => hc-44,1,NoOp(${HANGUPCAUSE} - Requested Channel Unavailable)
exten => hc-44,n,Goto(ind-congestion,1)
exten => hc-45,1,NoOp(${HANGUPCAUSE} - Pre-Empted)
exten => hc-45,n,Goto(ind-congestion,1)
exten => hc-50,1,NoOp(${HANGUPCAUSE} - Facility Not Subscribed)
exten => hc-50,n,Goto(ind-congestion,1)
exten => hc-52,1,NoOp(${HANGUPCAUSE} - Outgoing Call Barred)
exten => hc-52,n,Goto(ind-congestion,1)
exten => hc-54,1,NoOp(${HANGUPCAUSE} - Incoming Call Barred)
exten => hc-54,n,Goto(ind-congestion,1)
exten => hc-57,1,NoOp(${HANGUPCAUSE} - Bearer Capability Not Authorized)
exten => hc-57,n,Goto(ind-congestion,1)
exten => hc-58,1,NoOp(${HANGUPCAUSE} - Bearer Capability Not Available)
exten => hc-58,n,Goto(ind-congestion,1)
exten => hc-65,1,NoOp(${HANGUPCAUSE} - Bearer Capability Not Implemented)
exten => hc-65,n,Goto(ind-congestion,1)
exten => hc-66,1,NoOp(${HANGUPCAUSE} - Channel Not Implemented)
exten => hc-66,n,Goto(ind-congestion,1)
exten => hc-69,1,NoOp(${HANGUPCAUSE} - Facility Not Implemented)
exten => hc-69,n,Goto(ind-congestion,1)
exten => hc-81,1,NoOp(${HANGUPCAUSE} - Invalid Call Reference)
exten => hc-81,n,Goto(ind-congestion,1)
exten => hc-88,1,NoOp(${HANGUPCAUSE} - Incompatible Destination)
exten => hc-88,n,Goto(ind-congestion,1)
exten => hc-95,1,NoOp(${HANGUPCAUSE} - Invalid Message - Unspecified)
exten => hc-95,n,Goto(ind-congestion,1)
exten => hc-96,1,NoOp(${HANGUPCAUSE} - Mandatory IE Missing)
exten => hc-96,n,Goto(ind-congestion,1)
exten => hc-97,1,NoOp(${HANGUPCAUSE} - Message Type Nonexistant)
exten => hc-97,n,Goto(ind-congestion,1)
exten => hc-98,1,NoOp(${HANGUPCAUSE} - Wrong Message)
exten => hc-98,n,Goto(ind-congestion,1)
exten => hc-99,1,NoOp(${HANGUPCAUSE} - IE Nonexistant)
exten => hc-99,n,Goto(ind-congestion,1)
exten => hc-100,1,NoOp(${HANGUPCAUSE} - Invalid IE Contents)
exten => hc-100,n,Goto(ind-congestion,1)
exten => hc-101,1,NoOp(${HANGUPCAUSE} - Wrong Call State)
exten => hc-101,n,Goto(ind-congestion,1)
exten => hc-102,1,NoOp(${HANGUPCAUSE} - Recovery on Timer Expire)
exten => hc-102,n,Goto(ind-congestion,1)
exten => hc-103,1,NoOp(${HANGUPCAUSE} - Mandatory IE Length Error)
exten => hc-103,n,Goto(ind-congestion,1)
exten => hc-111,1,NoOp(${HANGUPCAUSE} - Protocol Error)
exten => hc-111,n,Goto(ind-congestion,1)
exten => hc-127,1,NoOp(${HANGUPCAUSE} - Internetworking)
exten => hc-127,n,Goto(ind-congestion,1)
exten => ind-hangup,1,Wait(30)
exten => ind-hangup,n,Hangup
exten => ind-busy,1,Busy
exten => ind-congestion,1,Congestion
exten => ind-outofservice,1,Zapateller
-----------8<----------------------8<--------------------------8<-------------------
You can simplify that macro considerably if you want, but honestly it's not
going to hurt anything to leave it as is. As you can see, it first checks to
see if there is a specific hangupcause and tries to parse it. Failing that,
it will look at the ${DIALSTATUS} variable (which is what Dial() sets) and
does the right thing based on that, by mapping the dial status to the closest
PRI hangup cause. The hangup cause is then printed to the screen and the
correct action is taken: indicating busy, congestion, SIT or simply hanging
up. Hanging up waits 30 seconds to provide lots of "dead air" like
the
telephone company does.
For bonus marks you could change the ind-hangup to provide dialtone and read
the next extension to dial after 30 seconds, and after timing out to play
"please hang up and try your call again", and after saying that a few
times
to play some really loud and annoying tone to wake you up... just like the
telco.
I find this macro works very well.
-A.