ChanIsAvail & Polycom 650 phone

This is driving me crazy, my task is I have a Polycom 650’s that has two lines defined, 12&15 . What I want to do is only ring one of the two lines when a call comes in. So pretend that phone 12 is on a call, if a new call comes in I want to ring x15 if 12 is not on the phone then I want to ring ext x12

My TEST code I’m using to simulate this:

exten => 34,1,ChanIsAvail(SIP/12&SIP/15,s)
exten => 34,n,Set(aext=${CUT(AVAILCHAN||1)})
exten => 34,n,NoOp(${aext})
exten => 34,n,NoOp(${AVAILSTATUS})
exten => 34,n(fail),Dial(${aext},20,j)
exten => 34,n,Hangup
exten => 34,fail+101,NoOp(Dial Failed)
exten => 34,n,MusicOnHold()

Output is this:
– Executing [34@sipchan:1] ChanIsAvail(“SIP/12-b77116e0”, “SIP/12&SIP/15|s”) in new stack
– Executing [34@sipchan:2] Set(“SIP/12-b77116e0”, “aext=SIP/12”) in new stack
– Executing [34@sipchan:3] NoOp(“SIP/12-b77116e0”, “SIP/12”) in new stack
– Executing [34@sipchan:4] NoOp(“SIP/12-b77116e0”, “0”) in new stack
– Executing [34@sipchan:5] Dial(“SIP/12-b77116e0”, “SIP/12|20|j”) in new stack
– Called 12
– Got SIP response 486 “Busy Here” back from 192.168.2.120
– SIP/12-09aad960 is busy
== Everyone is busy/congested at this time (1:1/0/0)
– Executing [34@sipchan:106] NoOp(“SIP/12-b77116e0”, “Dial Failed”) in new stack
– Executing [34@sipchan:107] MusicOnHold(“SIP/12-b77116e0”, “”) in new stack
– Started music on hold, class ‘default’, on channel ‘SIP/12-b77116e0’
– Stopped music on hold on SIP/12-b77116e0
== Spawn extension (sipchan, 34, 107) exited non-zero on ‘SIP/12-b77116e0’


Its always telling me x12 is available. I have the sip.cfg file on the polycom set to only 1 call per line in my <call… reg.1.callsPerLineKey=“1” setting on the polycom.

How can I get ChanIsAvail to return the second line when I check both lines.

Thanks
/Andy

After thinking about this some more, I figured that Asterisk is going to try and do a native bridge. So if ext 11 calls an internal SIP phone say 22 asterisk will try to hand off the call, and not really know about it anymore. So even though ext 11 is still busy, asterisk doesn’t know that.

I guess if there was a way to query the sip phone that might work, but as for now I don’t think what I want to do can be done. There is no way to tell if a phone is currently in a call.