Search code examples
asterisksippbx

Disallow 2 line to pass inbound ringing at the same time


I trying to use ooma with asterisk for my home setup, so I have 2 lines assigned to the same number forwarded through FXO gateways into asterisk. Outbound calls seem to work fine, but on inbound I have issue - both lines ring at the same time so on my IP phone I see multiple inbound calls from the same number. What is the simplest way to make that 2 incoming look like 1 call?

I tried to use DEVICE_STATE() function:

[from-ooma1]
exten => s, 1, GotoIf($["${DEVICE_STATE(SIP/ooma2)}"="RINGING"]?hang)
        same => n, Goto(incoming,s,1)
        same => n(hang),Hangup()

[from-ooma2]
exten => s, 1, GotoIf($["${DEVICE_STATE(SIP/ooma1)}"="RINGING"]?hang)
        same => n, Goto(incoming,s,1)
        same => n(hang),Hangup()

so on ring on one line if another one is already ringing to drop it. Unfortunately this does not work, as DEVICE_STATE has only 2 states NOT_INUSE and INUSE (or I do not know how to make it to report RINGING state), and I cannot drop on "IN_USE" state.

Note: my subject maybe misleading, to clarify - I need to prevent two lines ringing at the same time, but when first line answered and still in use, second one should allows to pass incoming call.


Solution

  • You can count calls to any single entity by using function GROUP

    [macro-stdvoip]
    ; ${ARG1} - full dial string
    ; Return ${DIALSTATUS} = CHANUNAVAIL if ${VOIPMAX} exceeded
    exten => s,1,Set(GROUP()=trunkgroup1) ;Set Group
    exten => s,2,GotoIf($[${GROUP_COUNT(trunkgroup1)} > ${VOIPMAX}]?103) ;Exceeded?
    exten => s,3,Dial(${ARG1}) ;dial it
    exten => s,103,SetVar(DIALSTATUS=CHANUNAVAIL) ;deny call
    

    https://www.voip-info.org/wiki/view/Asterisk+func+group