John,<br>Thanks.... <br>With the pointer that you gave me about sending Variables right at the end, I started tracing my socket communication with the asterisk.<br>I found that the "variables" were not the last parameters (although I was adding them last). I had to tweak opensource asterisk-java library code to handle the Variables separately and ensure that they come last.<br>
I put that change, and the things have started working. Also plan to raise this issue with Asterisk-Java and send fix. Below is the changed function in asterisk-java (posting it here as well, although asterisk-java will be the most appropriate mailing list for it. varValue and varName related changes are done by us.)<br>
<br>Thanks again,<br>Amol<br><br><br>@SuppressWarnings("unchecked")<br> private void appendGetters(StringBuffer sb, Object action, Set<String> membersToIgnore)<br> {<br> Map<String, Method> getters = ReflectionUtil.getGetters(action.getClass());<br>
Object varValue = null ;<br> Object varName = null;<br> <br> for (Map.Entry<String, Method> entry : getters.entrySet())<br> {<br> final String name = entry.getKey();<br>
final Method getter = entry.getValue();<br> final Object value;<br> <a href="http://logger.info">logger.info</a>("Inside appendGetters .... " + name ) ;<br> if (membersToIgnore.contains(name))<br>
{<br> continue;<br> }<br><br> try<br> {<br> value = getter.invoke(action);<br> }<br> catch (Exception ex)<br> {<br>
logger.error("Unable to retrieve property '" + name + "' of " + action.getClass(), ex);<br> continue;<br> }<br><br> if (value == null || value instanceof Class)<br>
{<br> continue;<br> }<br><br> final String mappedName = mapToAsterisk(getter);<br> <a href="http://logger.info">logger.info</a>("MWT Mapped Name is " + mappedName) ;<br>
if (value instanceof Map)<br> {<br> if(!name.equals("variables")) {<br> appendMap(sb, mappedName, (Map) value);<br> } else {<br> <a href="http://logger.info">logger.info</a>(" MWT Setting Var variables") ;<br>
varName = mappedName ;<br> varValue = value ;<br> }<br> }<br> else if (value instanceof String)<br> {<br> appendString(sb, mappedName, (String) value);<br>
}<br> else<br> {<br> appendString(sb, mappedName, value.toString());<br> }<br> }<br> <br> if(varValue != null && varName != null) {<br>
<a href="http://logger.info">logger.info</a>("MWT Appending map again") ;<br> <br> appendMap(sb, (String)varName, (Map) varValue);<br> }<br> }<br><div class="gmail_quote">
On Tue, Aug 16, 2011 at 7:39 PM, john Millican <span dir="ltr"><<a href="mailto:john@millican.us">john@millican.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#FFFFFF" text="#000000"><div><div></div><div class="h5">
<br>
<br>
<blockquote type="cite"><br>
<div class="gmail_quote">On Tue, Aug 16, 2011 at 4:42 AM, john
Millican <span dir="ltr"><<a href="mailto:john@millican.us" target="_blank">john@millican.us</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div>
<div>On 8/15/2011 5:48 PM, john Millican wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Hello,<br>
Asterisk 1.4.38<br>
Linux version 2.6.9-89.31.1.EL CentOS<br>
<br>
Trying to get variables into a dial plan from AMI. I
have tried all sorts of combinations,entering them after
making a connection to ami through telnet, of the many
available examples on <a href="http://voip-info.org" target="_blank">voip-info.org</a>
such as:<br>
Action: Originate<br>
Channel: sip/xxxxxxxxxx@xxxxxxx<br>
MaxRetries: 2<br>
RetryTime: 60<br>
WaitTime: 30<br>
Context: test1<br>
Exten: acs1<br>
Priority: 1<br>
CallerID: xxxxxxxxxx<br>
Account: MyTest<br>
Command: Set(var1=123456)<br>
Command: Set(var2=54321)<br>
<br>
also tried:<br>
Var:<br>
Variable:<br>
SetVar:<br>
<br>
Each individually for the two variables I need and both
on the same line separated by a | or a ,<br>
Always when I hit return twice to give the \r\n\r\n The
call is successful but where I have<br>
exten => acs1,n,NoOp(Vars = ${var1}, ${var2});<br>
in my dialplan what I get is:<br>
[2011-08-15 17:20:28] -- Executing [acs1@test1:2]
NoOp("SIP/xxxxxxx-00000451", "Vars = | ") in new stack<br>
Obviously not what I was hoping for.<br>
<br>
Any help would be greatly appreciated.<br>
<br>
TIA,<br>
JohnM<br>
<br>
<br>
</blockquote>
</div>
</div>
Ok so I figured it out, It was me being dumb!<br>
Proper format is indeed:<br>
Variable: var1=23456|var2=246810<br>
which I would have sworn I tried and it failed but, I started
at the beginning again and voila!
<div>
<div><br>
<br>
JohnM<br>
<br>
</div>
</div>
</blockquote>
</div>
</blockquote></div></div>
Un top posting for readability<div class="im"><br>
On 8/16/2011 8:33 AM, Amol Vedak wrote:
<blockquote type="cite">Hi John,<br>
<br>
I kind of facing the same problem that you were facing.<br>
I am using similar configuration as you are for asterisk.<br>
I am using java-asterisk library to communicate with asterisk.<br>
In my code I am setting two variables (PIN, MREQID) and trying to
access them in dialplan (dialplan shown below).<br>
When I send command to Asterisk to orginate, I get following
result (result shown below). I am wondering how should get access
to individual variable data. I was wondering if I should use
Set(var,x,y) method to pull out the part which is necessary for
me. But wasnt sure if thats the right way.<br>
<br>
RESULT<br>
-- Executing [login@authcheckrohan:5]
Set("SIP/softphonerohan-00000060", "PIN=3408|MREQID=1") in new
stack<br>
[Aug 16 17:53:06] WARNING[15739]: pbx.c:1344 pbx_exec: The
application delimiter is now the comma, not the pipe. Did you
forget to convert your dialplan? (Set(PIN=3408|MREQID=1))<br>
-- Executing [login@authcheckrohan:6]
Set("SIP/softphonerohan-00000060", "MREQID=") in new stack<br>
<br>
<br>
DIALPLAN<br>
exten => login,1,NoOp();<br>
;exten => login,n,SayNumber(${PIN})<br>
exten => login,n,Set(E=${PIN})<br>
exten => login,n,Verbose(${${E}_PIN})<br>
exten => login,n,Verbose(${E})<br>
exten => login,n,Set(PIN=${PIN})<br>
exten => login,n,Set(MREQID=${MREQID})<br>
exten => login,n,SayNumber(${MREQID})<br>
<br>
Have you done it differently?<br>
<br>
Thanks & Regards,<br>
Amol</blockquote>
<br></div>
I am connecting to the AMI from a C# app that was built by others
but I am using the same information and format as is used for a
standard telnet connection. What eneded up working is sending
Variable: var1=xxxx|var2=xxxxx|var3=xxxx as the last element(I do
not think it is important that it be last though). This is how it
ended up in C# after having established the connection:<br>
//Tell asterisk who to call and to connect them to the IVR<br>
clientSocket.Send(Encoding.ASCII.GetBytes("Action:
Originate\r\nChannel: sip/" + phoneNum1 +
"@<provider>\r\nMaxRetries: 2\r\nRetryTime: 60\r\nWaitTime:
30\r\nContext: <the context>l\r\nExten: <the
exten>\r\nPriority: 1\r\nCallerid: XXXXXXXXXX\r\nAccount: <CDR
Accountcode>\r\nVariable: var1=" + memberNum +"|var2=" +
phoneNum1 + "|var3=" + phoneNum2 + "\r\n\r\n"));<br>
<br>
Then in my Dialplan I just use ${var1} ,${var2} , and ${var3} where
I need them.<br>
<br>
Hope this helps.<br>
JohnM<br>
</div>
<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><br></blockquote></div><br>