Slava
Slava

Reputation: 44288

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.

Upvotes: 0

Views: 786

Answers (2)

Slava
Slava

Reputation: 44288

Just in case somebody needs similar solution here is what works for me:

[from-ooma]
exten => 1,1,Set(CALLERID(number)=O:9${CALLERID(number)})
        same => n,Set(GROUP()=ooma)
        same => n,GotoIf($[${GROUP_COUNT(ooma)}>${GROUP_COUNT(ooma-answer)} + 1]?hang)
        same => n,Goto(incoming,s,1)
        same => n(hang),Hangup()

[macro-resetG]
exten => s,1,Set(GROUP()=${IF($[ "${ARG1:0:8}" = "SIP/ooma" ]?ooma-answer)})
        same => n,MacroExit

[incoming]
exten => s,1,Verbose(1,Caller ${CALLERID(all)} incoming call)
        same => n,Dial(SIP/1&SIP/2,20,TtM(resetG^${CHANNEL}))
        same => n,Hangup()

so I use another group to count how many calls from ooma is answered (condition in macro is used because there could be other incoming calls)

Upvotes: 0

arheops
arheops

Reputation: 15259

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

Upvotes: 1

Related Questions