Solved

Checking for extensions in use in Asterisk

Posted on 2011-02-12
10
821 Views
Last Modified: 2013-11-12
Hello experts,

In an Asterisk 1.6.2 environment, I want to check for an extension if it's busy before paging it. I have found this code in extensions.conf sample, but it didn't work. When I page an extension while it's in a call, the other call becomes on hold and page is auto answered immediately.


[page]

exten => _*71XX,1,Macro(page,SIP/${EXTEN:2})

[macro-page]
;
; Paging macro:
;
;       Check to see if SIP device is in use and DO NOT PAGE if they are
;
;   ${ARG1} - Device to page

exten => s,1,ChanIsAvail(${ARG1},s)                     ; s is for ANY call
exten => s,n,GoToIf($[${AVAILORIGCHAN} = ""]?fail:autoanswer)
exten => s,n(autoanswer),Set(_ALERT_INFO="RA")                  ; This is for the PolyComs
exten => s,n,SIPAddHeader(Call-Info: Answer-After=0)    ; This is for the Grandstream, Snoms, and Others
exten => s,n,NoOp()                                     ; Add others here and Post on the Wiki!!!!
exten => s,n,Dial(${ARG1})
exten => s,n(fail),Hangup

Any help?

0
Comment
Question by:Muhajreen
  • 5
  • 3
  • 2
10 Comments
 
LVL 11

Expert Comment

by:jfaubiontx
Comment Utility
The problem is that call waiting is available. When the code checks to see if the channel is available, the reponse is sure I have more lines available. The the auto answer on message happily puts the call on hold and auto answers the incoming line. One way two fix it is to disable the call waiting feature. This way the phone reports the channel as unavailable. Depending on the model of phone there may be more ways to do this. What phones are you using?
0
 
LVL 7

Accepted Solution

by:
nauliv earned 500 total points
Comment Utility
Hello Muhajreen,


In order to achieve what you are looking for, since you are using 1.6, you can use the DEVICE_STATE function.
In your macro, you can check the value of the following variable ${DEVICE_STATE(${ARG1})}
The possible return values are:
UNKNOWN
NOT_INUSE
INUSE
BUSY
INVALID
UNAVAILABLE
RINGING
RINGINUSE
ONHOLD

I'd suggest you start by adding the following command in your dialplan to experiment and see if the values are indeed changing based on the phone status:

NoOp(The status of ${ARG1} is ${DEVICE_STATE(${ARG1})})


Wish you have a lot of fun with Asterisk, and let us know if you need further help!

Nauliv
0
 

Author Comment

by:Muhajreen
Comment Utility
Thank you for the great new feature of Asterisk 1.6 ! And sorry for the delay.

Actually I have tried the following:

exten => _1[012]X,1,NoOp(The status of ${EXTEN} is ${DEVICE_STATE(SIP/${EXTEN})})
same => n,Dial(SIP/${EXTEN},60)

But always when an extension (ie. 118) is in a call, and on other extension dials 118, I get that:

The status of 118 is NOT_INUSE

So what is the problem?
0
 
LVL 11

Expert Comment

by:jfaubiontx
Comment Utility
I'll ask again, what phone are you using?
0
 
LVL 7

Expert Comment

by:nauliv
Comment Utility
Can you post the sip.conf for this extension?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 7

Expert Comment

by:nauliv
Comment Utility
Can you post the sip.conf for this extension?
0
 

Author Comment

by:Muhajreen
Comment Utility
I am using Linksys SPA942.

[118]
context=full
callerid="Muhajreen" <118>
type=friend
secret=xxxxx
host=dynamic
mailbox=118@default
qualify=yes
deny=0.0.0.0/0.0.0.0
permit=192.168.99.118/255.255.255.255
allow=ulaw
canreinvite=no
callgroup=1
pickupgroup=1
0
 
LVL 7

Assisted Solution

by:nauliv
nauliv earned 500 total points
Comment Utility
Muhajreen: here is what you need to do:

1) Add this line in the [general] section of your sip.conf:

callcounter=yes

2) Test, and if it still doesn't work, add this line for your 118 entry as well:

call-limit=20  (doesn't matter what the value is, it's just to make asterisk keep track of calls)

It should work fine after that.

Good Luck !
0
 
LVL 7

Expert Comment

by:nauliv
Comment Utility
PS: don't forget to do a "sip reload" at the console after the changes :)
0
 

Author Closing Comment

by:Muhajreen
Comment Utility
Great ! callcounter=yes has solved it ! Thank you.

I will post another question soon regarding paging only NOT_INUSE multiple extensions.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Shoretel Voice Networks. 6 47
simple redial program 3 84
Which Cisco Switch is right for us, 10 46
eFax -- porting # out fails ? 1 42
There are no good configuration guides for HP-H3C router to LYNC on the web. :( Big statement, but we havent been able to find one yet. We did find the following document useful, but the information was not enough to use H3C router for use as a L…
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now