Hangup and HANGUPCAUSE
From aa-asterisk.org.uk wiki
Newer versions of Asterisk are able to set the hangup cause code whilst hanging up. What effect this has varies depending on the type of channel used, but it works for IAX2, Zaptel/DHADI, SIP and most other channels that support cause codes. Asterisk stores hangup causes internally as ISUP cause codes.
To use Hangup, do:
exten => s,1,Hangup([<cause-code>])
Not supplying a <cause-code> will cause the default 16 to be sent.
To read the cause code back you can use the ${HANGUPCAUSE} variable. If you receive a hangup cause from a channel and wish to pass it down the chain to another device you can do:
exten => s,1,Hangup(${HANGUPCAUSE})
Older versions of Asterisk
In versions of Asterisk <= 1.2, the ${PRI_CAUSE} variable was used to set the cause code upon hangup since Hangup() did not accept a parameter until recently. In this case use:
exten => s,1,Set(PRI_CAUSE=21) exten => s,n,Hangup
This behaviour is now officially deprecated however.
