911 calls - SoftHangup any non-emergency calls

Hi all,

I’m looking to improve the robustness of my 911 extension at home (asterisk 1.4b3 on a debian box with a SPA-3102 connected to 2 standard phones and 2 IP phones on the network). There are 4 teenage females in the the house and the outgoing PSTN line is in constant use.

What I would like to do is hangup any current PSTN unless they are already connected to 911. The basic idea is given here but I’m not sure I follow everything.

In extensions.conf I have:

; Emergency calls

;exten => s,1,SetVar(SET_EMERG_FLAG=0)
exten => s,1,Set(SET_EMERG_FLAG=0)
exten => s,n(checkavail),ChanIsAvail(${EMERGENCY_TRUNK})
;exten => s,n,SetGlobalVar(EMERGENCY=1)
exten => s,n,Set(GLOBAL(EMERGENCY)=1)
;exten => s,n,SetVar(SET_EMERG_FLAG=1)
exten => s,n,Set(SET_EMERG_FLAG=1)
exten => s,n(dial),Dial(${EMERGENCY_TRUNK}/${EMERGENCY_NUM})
exten => s,n+1(trunkbusy),GotoIf($[${EMERGENCY} = 1]?inprogress)
exten => s,n,SoftHangup(${EMERGENCY_TRUNK}-1)
exten => s,n,Wait(12)
exten => s,n,Goto(checkavail)
exten => s,n+1(inprogress),Congestion
exten => s,checkavail+101(notavail),Goto(trunkbusy)
exten => h,1,GotoIf($[${SET_EMERG_FLAG} = 1]?3)
;exten => h,3,SetGlobalVar(EMERGENCY=0) 
exten => h,3,Set(GLOBAL(EMERGENCY)=0)

; Emergency calls
exten => 911,1,Goto(nineoneone,s,1)

As it stands, existing calls are not terminated by SoftHangup. On the console I get:

-- Executing [xxxxxxx@localsip:1] Macro("SIP/OfficePhone-081f3878", "dial-pstn|xxxxxxx|70") in new stack
    -- Executing [s@macro-dial-pstn:1] SetGlobalVar("SIP/OfficePhone-081f3878", "FOUNDME=ANSWER") in new stack
  == Setting global variable 'FOUNDME' to 'ANSWER'
    -- Executing [s@macro-dial-pstn:2] Dial("SIP/OfficePhone-081f3878", "SIP/spa3102PSTN/xxxxxxx|70") in new stack
    -- Called spa3102PSTN/xxxxxxx
    -- SIP/spa3102PSTN-081fabd8 is ringing
    -- SIP/spa3102PSTN-081fabd8 answered SIP/OfficePhone-081f3878
    -- Executing [911@localsip:1] Goto("SIP/spa3102Line1-08215628", "nineoneone|s|1") in new stack
    -- Goto (nineoneone,s,1)
    -- Executing [s@nineoneone:1] Set("SIP/spa3102Line1-08215628", "SET_EMERG_FLAG=0") in new stack
    -- Executing [s@nineoneone:2] ChanIsAvail("SIP/spa3102Line1-08215628", "SIP/spa3102PSTN") in new stack
    -- Executing [s@nineoneone:3] Set("SIP/spa3102Line1-08215628", "GLOBAL(EMERGENCY)=1") in new stack
  == Setting global variable 'EMERGENCY' to '1'
    -- Executing [s@nineoneone:4] Set("SIP/spa3102Line1-08215628", "SET_EMERG_FLAG=1") in new stack
    -- Executing [s@nineoneone:5] Dial("SIP/spa3102Line1-08215628", "SIP/spa3102PSTN/119") in new stack
    -- Called spa3102PSTN/119
    -- Got SIP response 503 "Service Unavailable" back from
    -- SIP/spa3102PSTN-0821d4a8 is circuit-busy
  == Everyone is busy/congested at this time (1:0/1/0)
    -- Executing [h@nineoneone:1] GotoIf("SIP/spa3102Line1-08215628", "1?3") in new stack
    -- Goto (nineoneone,h,3)
    -- Executing [h@nineoneone:3] Set("SIP/spa3102Line1-08215628", "GLOBAL(EMERGENCY)=0") in new stack
  == Setting global variable 'EMERGENCY' to '0'

I must admit that I’m not sure I follow the logic of the 911 extension above… what is clear is that when another extension is in use, I am never getting to the SoftHangup() call.

Any ideas, suggestions, hints and advice are greatly appreciated.


EDIT - This won’t work for your Sip ATA. You will have to add some more steps to get the full channel name of the call that is currently using the line on that ATA instead of hardcoding it as sip channels have an ID appended onto them. IE. “SIP/spa3102Line1-08215628”. The “-08215628” will pretty much be unique for every call.