<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Thanks Noah.<br><br>I thought my dialplan did that: Check to see if the parking space is occupied, if so, pickup the call in the parking space, if not, park the call to that space.<br><br>This works fine for the first time around, but the second time the phone/asterisk behaves differently. Still not clear why it's failing. Device states are updated correctly btw. I assumed when you unpark a call, that space becomes available/free, and you can park the same call to the same parking space more than once; e.g. park it to 701, unpark/pick it up from 701, park it to 701 again, unpark it, etc.<br><br>I'm only using one phone (in the lab)  - the race condition is not an issue for now, but thanks for reminding that because my approach might not work the way I thought it would. I will look into your solution. In any case, it might be better to let Asterisk pick a random spot (4 lines, 4 parking spots). The good thing is, we don't need to know where it is (anyone can pick it up)  as long as BLF works properly and we know there is a call parked.<br><br>Matt<br><br><br><div><hr id="stopSpelling">From: nengelberth@team-meta.net<br>To: asterisk-users@lists.digium.com<br>Date: Mon, 14 Oct 2013 20:31:06 +0000<br>Subject: Re: [asterisk-users] parking - why doesn't this work?<br><br>



<style><!--
.ExternalClass p.ecxMsoNormal, .ExternalClass li.ecxMsoNormal, .ExternalClass div.ecxMsoNormal {
font-size:12.0pt;
font-family:"Times New Roman","serif";
}

.ExternalClass a:link, .ExternalClass span.ecxMsoHyperlink {
color:#0563C1;
text-decoration:underline;
}

.ExternalClass span.ecxMsoHyperlinkFollowed {
color:#954F72;
text-decoration:underline;
}

.ExternalClass p {
font-size:12.0pt;
font-family:"Times New Roman","serif";
}

.ExternalClass span.ecxEmailStyle18 {
font-family:"Calibri","sans-serif";
color:#1F497D;
}

.ExternalClass .ecxMsoChpDefault {
font-size:10.0pt;
}

.ExternalClass div.ecxWordSection1 {
}

--></style>


<div class="ecxWordSection1">
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">You can hack together a way with custom device states and manual use of the Park() and ParkPickup() functions, but it won’t be particularly pretty.  A rough
 dialplan might look like the following (adjust to match your requirements, especially if a park fails or something similar):</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">exten => _70[1234],1,Verbose(5,Park pickup or park call for slot ${EXTEN})</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,GotoIf($[${DEVICE_STATE(park:${EXTEN}@parkinglot)} = NOT_INUSE]?park,pickup)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">; Currently no call parked – park call</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n(park),Set(__PARKINGEXTEN=${EXTEN})</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Set(__RETURNTO=${CALLERID(num)})</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Dial(Local/s@park,)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">; Park failed, clear the device state and return</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Goto(parking-return,${RETURNTO},1)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">; Currently a call parked – pick up</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n(pickup),ParkedCall(${EXTEN}@parkinglot)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Hangup()</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">[park]</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">exten => s,1,Verbose(5,Park call)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Park(<timeout in ms>,parking-return,${RETURNTO},1,s,parkinglot)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">[parking-return]</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">exten => _X.,1,Verbose(5,Return parked call to internal phone)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Set(CALLERID(name)=PK:${CALLERID(name))</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => n,Dial(Local/${EXTEN}@users,)</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">same => ; some fallback for if the return user doesn’t answer</span></p>
<p class="ecxMsoNormal" style=""><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">Basically, the idea is, check to see if the parking space is occupied.  If it is occupied, someone is trying to pickup the parked call, so connect them with
 the ParkedCall() application.  If it is not occupied, someone is trying to park a call, so set up the PARKINGEXTEN variable with “where to park it” (e.g. 701), and set up the RETURNTO variable with “where to return if the park fails or times out” (in my example,
 based on the caller ID number of the parking channel – make sure it’s set to something that will return either via a local channel like I have in my example or a direct dial to a SIP/ or other channel). 
</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">By putting the double underscore (__) in front of the variable name when we set it, we tell Asterisk to automatically set that variable on any channel spawned
 as a descendant of this channel (necessary for parking via a Local channel).  
</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">I’m suggesting parking via local channel so that the RETURNTO variable survives on an attended transfer.  Also, the specific example I have above
<u>will not work properly<b> </b>with unattended (blind) transfers to the parking extension</u>.  If you want to support a blind transfer to the parking space, you need to find a way to use the BLINDTRANSFER and BLIND_XFER_PEER channel variables to set RETURNTO
 correctly.</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">There’re plenty of other ways to do it, but the core of what you’ll need to investigate for “SLA parking” is to use ${PARKINGEXTEN} to tell Asterisk where to
 park the call, and use the features.conf settings for the parking lot to prevent Asterisk from automatically hunting into additional spaces (if you allow Asterisk to hunt into a new slot, and two people try to park on 701 at the same time, one of the two calls
 will wind up on 702 and the ,s, option in the Park() application means Asterisk won’t be reading back parking slots to the Parker, so you won’t know which call lost the race.  Practically speaking, it’s not a huge problem, but the best practice would be to
 prevent the auto-hunting and avoid the race condition altogether).</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">Thank you,</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">Noah Engelberth</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;">MetaLINK Technologies</span></p>
<p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;"> </span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt;">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in;">
<p class="ecxMsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";"> asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com]
<b>On Behalf Of </b>Matt Hamilton<br>
<b>Sent:</b> Monday, October 14, 2013 10:28 AM<br>
<b>To:</b> Asterisk Users Mailing List - Non-Commercial Discussion<br>
<b>Subject:</b> Re: [asterisk-users] parking - why doesn't this work?</span></p>
</div>
</div>
<p class="ecxMsoNormal"> </p>
<div>
<p class="ecxMsoNormal"><span style="font-family:"Calibri","sans-serif";"><br>
Parking/unparking will be done from multiple phones so that someone else can pickup/unpark the call from their phone that I parked on mine. I'm just testing it on one phone now.<br>
<br>
I'm trying to simulate the SLA functionality (which Asterisk has, but it's not very scalable and they haven't really been doing much development/improvement on that lately). We have been using SLA for a while, but we are also looking at other options. Unfortunately,
 conventional parking (pressing #700 and announcing the parking space) is not suitable for our very fast paced environment.<br>
<br>
<br>
----------------------------------------<br>
> Date: Mon, 14 Oct 2013 16:15:22 +0200<br>
> From: <a href="mailto:webaccounts@jgoettgens.de">webaccounts@jgoettgens.de</a><br>
> To: <a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a><br>
> Subject: Re: [asterisk-users] parking - why doesn't this work?<br>
><br>
> Hmmm, do I understand you correctly that you park and unpark a call using the same phone?<br>
><br>
> If yes, why does simply "holding" the call does not work? The SPA504 has an extra large button<br>
> on the right for this and you don't need any support in the dialplan.<br>
><br>
> jg<br>
><br>
> --<br>
> _____________________________________________________________________<br>
> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
> New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
> <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
><br>
> asterisk-users mailing list<br>
> To UNSUBSCRIBE or update options visit:<br>
> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a>
</span></p>
</div>
</div>
</div>


<br>-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users</div>                                    </div></body>
</html>