{"id":779,"date":"2012-09-29T01:00:00","date_gmt":"2012-09-28T23:00:00","guid":{"rendered":"https:\/\/www.fussylogic.co.uk\/blog\/?p=779"},"modified":"2012-09-30T00:48:12","modified_gmt":"2012-09-29T23:48:12","slug":"asterisk-for-a-small-business-vii","status":"publish","type":"post","link":"https:\/\/www.fussylogic.co.uk\/blog\/?p=779","title":{"rendered":"Asterisk For a Small Business (VII)"},"content":{"rendered":"<p>As we left things last time, we had a nicely organised dial plan that had the minimum of duplicated code, and was essentially a set of tables that mapped endpoints to extensions or queues. Let\u00e2\u20ac\u2122s remind ourselves.<\/p>\n<pre><code>[internal-extensions]\n; Numeric aliases\nexten =&gt; 2100,1,Goto(andyp,1)\nexten =&gt; 2101,1,Goto(wife,1)\nexten =&gt; 2102,1,Goto(handytone1,1)\nexten =&gt; 2103,1,Goto(handytone2,1)\nexten =&gt; 2200,1,Goto(residential,1)\nexten =&gt; 2201,1,Goto(business,1)\n; Named extensions -- endpoints named after sip.conf sections\nexten =&gt; andyp,1,Gosub(stdexten,s,1(SIP\/${EXTEN},${EXTEN}))\nexten =&gt; andyp,hint,SIP\/${EXTEN}\nexten =&gt; wife,1,Gosub(stdexten,s,1(SIP\/${EXTEN},${EXTEN}))\nexten =&gt; wife,hint,SIP\/${EXTEN}\nexten =&gt; handytone1,1,Gosub(stdexten,s,1(SIP\/${EXTEN},${EXTEN}))\nexten =&gt; handytone1,hint,SIP\/${EXTEN}\nexten =&gt; handytone2,1,Gosub(stdexten,s,1(SIP\/${EXTEN},${EXTEN}))\nexten =&gt; handytone2,hint,SIP\/${EXTEN}\n; Named extensions -- ring groups\nexten =&gt; residential,1,Gosub(stdqueue,s,1(${EXTEN}))\nexten =&gt; business,1,Gosub(stdqueue,s,1(${EXTEN}))\n\n[internal-residential]\ninclude =&gt; internal-extensions\nexten =&gt; _0X.,1,Dial(SIP\/voiptalkRESIDENTIAL\/${EXTEN})\n\n[internal-business]\ninclude =&gt; internal-extensions\nexten =&gt; _0X.,1,Dial(SIP\/voiptalkOFFICE\/${EXTEN})\n\n[external]\nexten =&gt; voiptalkRESIDENTIAL,1,Goto(internal-residential,residential,1)\nexten =&gt; voiptalkOFFICE,1,Goto(internal-business,business,1)<\/code><\/pre>\n<p>We\u00e2\u20ac\u2122ll leave our endpoints behind now. I want to talk about adding facilities to our two virtual phone systems, <code>[internal-residential]<\/code> and <code>[internal-business]<\/code>. First, outgoing line selection. If I\u00e2\u20ac\u2122m sat in the lounge and want to make a business call, I shouldn\u00e2\u20ac\u2122t have to go into the office just because the business line is the outgoing line for the office extension. I want to be able to change line from the residential extension. The method uses techniques we\u00e2\u20ac\u2122ve already used extensively.<\/p>\n<pre><code>[internal-residential]\ninclude =&gt; internal-extensions\nexten =&gt; _#X.,1,Goto(internal-business,${EXTEN:1},1)\nexten =&gt; _0X.,1,Dial(SIP\/voiptalkRESIDENTIAL\/${EXTEN})\n\n[internal-business]\ninclude =&gt; internal-extensions\nexten =&gt; _#X.,1,Goto(internal-residential,${EXTEN:1},1)\nexten =&gt; _0X.,1,Dial(SIP\/voiptalkOFFICE\/${EXTEN})<\/code><\/pre>\n<p>When the extension dialled starts with a hash, these new dialplan entries simply call the same number in the other context. We\u00e2\u20ac\u2122ve used <code>${EXTEN:1}<\/code> as the target extension to call, which makes Asterisk automatically strip of the first digit (in this case the hash) when it goes to the other context. The \u00e2\u20ac\u0153other\u00e2\u20ac\u009d line is now easily accessible from any extension.<\/p>\n<p>Normally, when you have a standard analogue phone connected to an ATA, the ATA provides the dial tone. I prefer to have the dialtone provided by Asterisk, getting away from the control of the ATA as soon as possible \u00e2\u20ac\u201c I\u00e2\u20ac\u2122ve found the quality of their indication tones to be \u00e2\u20ac\u0153variable\u00e2\u20ac\u009d, and configuring the dial timeouts in different ways for different devices is a chore.<\/p>\n<p>Both the HandyTone and Linksys\/Sipura ATAs have this \u00e2\u20ac\u0153offhook auto-dial\u00e2\u20ac\u009d facility. On the HandyTone it\u00e2\u20ac\u2122s simply a field on the web page. On the Linksys device, you have to specify it using a special dialplan. For example, on the SPA3000 you switch to advanced mode, then on the \u00e2\u20ac\u0153Line 1\u00e2\u20ac\u009d tab, near the bottom you\u00e2\u20ac\u2122ll find \u00e2\u20ac\u0153Dial plan\u00e2\u20ac\u009d; set that to \u00e2\u20ac\u0153<code>(S0&lt;:disa&gt;)<\/code>\u00e2\u20ac\u009d and it will dial the \u00e2\u20ac\u0153disa\u00e2\u20ac\u009d extension instantly when you go off-hook. We need to provide this extension in Asterisk though.<\/p>\n<pre><code>[disa]\nexten =&gt; disa,1,Answer\nexten =&gt; disa,n,Disa(no-password,${CONTEXT})\n\n[internal-residential]\ninclude =&gt; internal-extensions\ninclude =&gt; disa\nexten =&gt; _#X.,1,Goto(internal-business,${EXTEN:1},1)\nexten =&gt; _0X.,1,Dial(SIP\/voiptalkRESIDENTIAL\/${EXTEN})\n\n[internal-business]\ninclude =&gt; internal-extensions\ninclude =&gt; disa\nexten =&gt; _#X.,1,Goto(internal-residential,${EXTEN:1},1)\nexten =&gt; _0X.,1,Dial(SIP\/voiptalkOFFICE\/${EXTEN})<\/code><\/pre>\n<p>I\u00e2\u20ac\u2122ve added it as an \u00e2\u20ac\u0153include\u00e2\u20ac\u009d so that, as usual, we can avoid duplicating code merely to change a couple of parameters. The \u00e2\u20ac\u0153disa\u00e2\u20ac\u009d extension simply calls the Asterisk function, <code>Disa()<\/code> with the current context as its parameter. Because the <code>[disa]<\/code> context is included in other contexts, <code>${CONTEXT}<\/code> actually <code>internal-residential<\/code> or <code>internal-business<\/code> when it\u00e2\u20ac\u2122s expanded.<\/p>\n<p>The <code>Disa()<\/code> function does exactly what we want: provides a dial tone. Our ATA can instantly call the \u00e2\u20ac\u02dcdisa\u00e2\u20ac\u2122 extension, and the user need never know the difference between an ATA-provided dialtone or Asterisk-provided dialtone.<\/p>\n<p><a href=\"?p=441\">asterisk1<\/a> <a href=\"?p=443\">asterisk2<\/a> <a href=\"?p=445\">asterisk3<\/a> <a href=\"?p=447\">asterisk4<\/a> <a href=\"?p=449\">asterisk5<\/a> <a href=\"?p=776\">asterisk6<\/a> <a href=\"?p=779\">asterisk7<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we left things last time, we had a nicely organised dial plan that had the minimum of duplicated code, and was essentially a set of tables that mapped endpoints to extensions or queues. Let\u00e2\u20ac\u2122s remind ourselves. [internal-extensions] ; Numeric aliases exten =&gt; 2100,1,Goto(andyp,1) exten =&gt; 2101,1,Goto(wife,1) exten =&gt; 2102,1,Goto(handytone1,1) exten =&gt; 2103,1,Goto(handytone2,1) exten =&gt;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.fussylogic.co.uk\/blog\/?p=779\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[31,42,6],"_links":{"self":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/779"}],"collection":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=779"}],"version-history":[{"count":8,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions"}],"predecessor-version":[{"id":790,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions\/790"}],"wp:attachment":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}