<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Crossed Wires &#187; freepbx</title>
	<atom:link href="http://veejoe.net/blog/tag/freepbx/feed/" rel="self" type="application/rss+xml" />
	<link>http://veejoe.net/blog</link>
	<description>Vic's Blog</description>
	<lastBuildDate>Mon, 26 Jul 2010 22:19:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>FreePBX device-and-user mode, part two</title>
		<link>http://veejoe.net/blog/2009/07/freepbx-device-and-user-mode-part-two/</link>
		<comments>http://veejoe.net/blog/2009/07/freepbx-device-and-user-mode-part-two/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 09:53:21 +0000</pubDate>
		<dc:creator>Vic</dc:creator>
				<category><![CDATA[Telephony]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[freepbx]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[phone]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://veejoe.net/blog/?p=5407</guid>
		<description><![CDATA[In part one, I described how I reconsidered device-and-user mode in FreePBX, and did the initial changeover.  Read on to find out how I overcame a major issue with the configuration! I have an ISDN phone line coming into my Asterisk system.  One of the indials is for our home number, the other is one [...]]]></description>
			<content:encoded><![CDATA[<address>In <a title="Revisiting device-and-user mode in FreePBX" href="http://veejoe.net/blog/2009/07/revisiting-device-and-user-mode-in-freepbx/" target="_self">part one</a>, I described how I reconsidered device-and-user mode in FreePBX, and did the initial changeover.  Read on to find out how I overcame a major issue with the configuration!</address>
<p>I have an ISDN phone line coming into my Asterisk system.  One of the indials is for our home number, the other is one I use for work.  Before I found FreePBX, I had manually worked the Asterisk dialplan to have calls made from my work phone(s) appear from the work phone number&#8211;useful not just for Caller-ID, but also required for the long-distance provider I use to bill calls for work.  With FreePBX I was able to use a custom context to pre-select a route that dialled the provider override prefix to send the calls through the other provider, but it was a bit of a hack using hand-written dialplan code and a bit of luck.</p>
<p>Before I changed to device-and-user, I naively assumed that FreePBX would allow a user to be associated with a context in the same way a device/extension can be.  This is not the case, and the context of the device is still used for routing.  This meant that I could not use a device for either work or personal calls without having to log onto FreePBX and change the device context (logging on as the work user was not enough).  I was back to square one&#8230;</p>
<p>I did a little research.  Firstly, I rediscovered how I was making the existing routing work.  The ISDN interface I use (driven by <strong>chan_capi</strong> in Asterisk) simply uses the outgoing caller-id of the call to select from available MSNs[1].  So I had one route that had the &#8220;normal&#8221; MSN set as the outbound caller-id, another route with the &#8220;work&#8221; MSN (plus the rewrites to add the long-distance override code at the front), and a custom context for the work devices that made only the route with the work MSN available.</p>
<p>Looking more closely at the user definition page, I saw that there is an &#8220;Outgoing Caller-ID&#8221; field.  By using this field, I was able to do away with the separate route and the custom context and set the work MSN there instead.  This gives me just what I need: a way to control my outbound MSN on a per-user basis!  This got me half-way there, as I still needed a way to set the long-distance override codes for work calls.  A bit more research turned up a predialling macro hook that the FreePBX folks made available.  With a bit of code to test the caller-id and the number dialled (the long distance company doesn&#8217;t handle free calls, for instance) I get just what I need.</p>
<p>Here&#8217;s the macro hook (this is added to extensions_custom.conf):</p>
<blockquote>
<pre>[macro-dialout-trunk-predial-hook]
exten =&gt; s,1,NoOp(Trunk is ${OUT_${DIAL_TRUNK}}, CallerID ${CALLERID(num)} calling ${OUTNUM} )
exten =&gt; s,n,GotoIf($["${CALLERID(num)}" != "xxxxxxxxx"]?endit)
exten =&gt; s,n,GotoIf($["${OUT_${DIAL_TRUNK}:4:11}" != "CAPI/contr1"]?endit)
exten =&gt; s,n,GotoIf($["${OUTNUM}:0:4}" = "1800"]?endit)
exten =&gt; s,n,Set(OUTNUM=1xxx${OUTNUM})
exten =&gt; s,n(endit),MacroExit()</pre>
</blockquote>
<p>So I&#8217;m now a happy device-and-user user!</p>
<address>[1] Actually I don&#8217;t know if that&#8217;s chan_capi doing it for me or whether it&#8217;s just the way the ISDN network works.</address>
]]></content:encoded>
			<wfw:commentRss>http://veejoe.net/blog/2009/07/freepbx-device-and-user-mode-part-two/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Revisiting device-and-user mode in FreePBX</title>
		<link>http://veejoe.net/blog/2009/07/revisiting-device-and-user-mode-in-freepbx/</link>
		<comments>http://veejoe.net/blog/2009/07/revisiting-device-and-user-mode-in-freepbx/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 09:49:09 +0000</pubDate>
		<dc:creator>Vic</dc:creator>
				<category><![CDATA[Telephony]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[freepbx]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[phone]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://veejoe.net/blog/?p=5405</guid>
		<description><![CDATA[Buoyed by the success of a colleague I introduced to Asterisk and FreePBX a little while ago, I decided to have another look at the extension configuration mode I use on our system. Check this post for a recap of the FreePBX configuration modes and my first thoughts. Last time I looked at this I [...]]]></description>
			<content:encoded><![CDATA[<p>Buoyed by the success of a colleague I introduced to Asterisk and FreePBX a little while ago, I decided to have another look at the extension configuration mode I use on our system.</p>
<address>Check <a title="FreePBX Modes" href="http://veejoe.net/blog/2007/10/freepbx-modes/" target="_blank">this post</a> for a recap of the FreePBX configuration modes and my first thoughts.</address>
<p>Last time I looked at this I thought there were some problems with the way it was implemented that meant it didn&#8217;t work for my installation, so I ended up hacking together a mess of fake extensions, ring groups and queues that more-or-less reimplemented the good parts of device-and-user mode and still letting me use things from extensions mode.  Doing this however meant that FreePBX always complained about what it called &#8220;invalid destinations&#8221;, and I had to use some custom logic for doing something simple like a common voicemail access number.</p>
<p>What won me over to device-and-user mode again though was the ability to log a device on and off from a number.  I have a couple of Nokia handsets that have SIP clients now, and it&#8217;s handy to just have one device that all my work calls (for example) arrive on.  After-hours though, I didn&#8217;t want that device to still be tied up to the work line; it made more sense to be able to use that device for home calls.  To do that with extensions mode and my ring-group hack would mean reprogramming the ring-group (and one other change, which I&#8217;ll talk about later) when I wanted to switch over.  Presumably I could write some script or AGI logic that I could tie to a feature code in FreePBX, but I&#8217;d simply be making more custom modifications for little real gain.</p>
<p>In the end, I realised that the main thing keeping me in extensions mode&#8211;the ability to call a device by it&#8217;s &#8220;extension&#8221; number regardless of who&#8217;s logged on to it&#8211;wasn&#8217;t something I used often enough to warrant all the work I&#8217;d have to do to make extensions mode do what I needed.  With that in mind, I edited <strong>amportal.conf</strong> and made the all-important change:</p>
<blockquote>
<pre>AMPEXTENSIONS=deviceanduser</pre>
</blockquote>
<p>I had to reload the FreePBX admin page a couple of times, but eventually the &#8220;Extensions&#8221; tab changed into two tabs, &#8220;Devices&#8221; and &#8220;Users&#8221;.  True to the description of extension and device-and-user modes given in the FreePBX doco, the Devices and Users tabs had the same number of entries.  All I needed to do was delete the users that were no longer required (i.e. almost all of them) and the devices that belonged to the voicemail extensions from my original setup.  I then ran through each of the device definitions and correctly assigned them as either &#8220;Fixed&#8221; (statically allocated to a user) or &#8220;Ad-Hoc&#8221; (able to be logged on to a user).</p>
<p>This was the point at which I worked out a solution to my original dial-a-device-directly problem.  I realised that the majority of times I need that functionality is when testing.  So, for those devices that I use for testing, I left the user definition in place and made it the &#8220;default&#8221; user for that device.  This means that when I log out of the real user from that device it is reachable by the default user number, and I can dial it directly for testing.  The other use for direct-connection to a device, the intercom, requires a separate SIP endpoint anyway (due to the Cisco phones not adhering to the SIP command for remote off-hook) so I need to keep those as separate users too.</p>
<p>I&#8217;m quite happy with how it&#8217;s turned out&#8211;at least, I was once I&#8217;d overcome the showstopper I found!  Read about that in <a title="FreePBX device-and-user mode part two" href="http://veejoe.net/blog/2009/07/freepbx-device-and-user-mode-part-two/" target="_self">part two</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://veejoe.net/blog/2009/07/revisiting-device-and-user-mode-in-freepbx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
