Thomas Winter
2008-Aug-05 15:47 UTC
[asterisk-users] vars in Macros called by DIAL with option M
Hi all, Iam using an DIAL Command wird Macro if callee is answer the call. exten => 123,n,DIAL(SIP/123 at provider,180,gM(test_connect)) exten => 123,n,NoOp( ${var_from_macro}) In Macro test_connect Iam generating an new variable var_from_macro and would like to use this var in the original dialplan. I tried also __var_from_macro but didnt work. How can I set vars in macros called by DIAL so that I can use these vars in the Dialplan or in the h extention. best regards Thomas
Ruddy Gbaguidi
2008-Aug-05 16:02 UTC
[asterisk-users] vars in Macros called by DIAL with option M
I don't think you can do that because, asterisk, in the caller thread will only read MACRO_RESULT to know if he has to connect the call or not. A workaround will be to : 1. before the dial, add a row in a database table and retrieve an id 2. pass the id to test_connect and test_connect will then write his variable value into the database 3. after the dial,. use the id to retrieve the needed variable. Hope this will help. Thomas Winter wrote:> Hi all, > > Iam using an DIAL Command wird Macro if callee is answer the call. > > exten => 123,n,DIAL(SIP/123 at provider,180,gM(test_connect)) > exten => 123,n,NoOp( ${var_from_macro}) > > > In Macro test_connect Iam generating an new variable var_from_macro and would > like to use this var in the original dialplan. > I tried also __var_from_macro but didnt work. How can I set vars in macros > called by DIAL so that I can use these vars in the Dialplan or in the h > extention. > > best regards > Thomas > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > AstriCon 2008 - September 22 - 25 Phoenix, Arizona > Register Now: http://www.astricon.net > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > > ------------------------------------------------------------------------ > > > Internal Virus Database is out of date. > Checked by AVG. > Version: 8.0.100 / Virus Database: 269.23.16/1448 - Release Date: 5/16/2008 7:42 PM >
Tilghman Lesher
2008-Aug-05 16:04 UTC
[asterisk-users] vars in Macros called by DIAL with option M
On Tuesday 05 August 2008 10:47:34 Thomas Winter wrote:> Hi all, > > Iam using an DIAL Command wird Macro if callee is answer the call. > > exten => 123,n,DIAL(SIP/123 at provider,180,gM(test_connect)) > exten => 123,n,NoOp( ${var_from_macro}) > > > In Macro test_connect Iam generating an new variable var_from_macro and > would like to use this var in the original dialplan. > I tried also __var_from_macro but didnt work. How can I set vars in macros > called by DIAL so that I can use these vars in the Dialplan or in the h > extention.There isn't any good way to do that, period. When it comes to inheritance, variables are only inherited from a master channel to a slave channel. In the case of the Macro operating within the Dial, that Macro is occurring exclusively on the slave channel. You cannot directly set variables on other channels (for obvious race-condition reasons). However, you could do this in a roundabout way, either by using a database or by using shared variables in trunk. You'd need to first set (in the master channel, before the Dial) an inherited variable containing the name of the master channel, i.e. Set(_masterchan=${CHANNEL(name)}), then use that inherited variable to set the shared variable in the master channel from the slave channel, i.e. Set(SHARED(foo,${masterchan})=...). Finally, you would be able to access the shared variable in the master channel with ${SHARED(foo)}. Again, the SHARED function is only available in trunk at this time, although you could probably backport it to 1.4 with minimal trouble. -- Tilghman
Ruddy Gbaguidi
2008-Aug-05 16:21 UTC
[asterisk-users] vars in Macros called by DIAL with option M
And if you use DIALSTATUS and ANSWERTIME to check the last dial status, you need to take care of the following bug http://bugs.digium.com/view.php?id=13216 Thomas Winter wrote:> Hi all, > > Iam using an DIAL Command wird Macro if callee is answer the call. > > exten => 123,n,DIAL(SIP/123 at provider,180,gM(test_connect)) > exten => 123,n,NoOp( ${var_from_macro}) > > > In Macro test_connect Iam generating an new variable var_from_macro and would > like to use this var in the original dialplan. > I tried also __var_from_macro but didnt work. How can I set vars in macros > called by DIAL so that I can use these vars in the Dialplan or in the h > extention. > > best regards > Thomas > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > AstriCon 2008 - September 22 - 25 Phoenix, Arizona > Register Now: http://www.astricon.net > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > > ------------------------------------------------------------------------ > > > Internal Virus Database is out of date. > Checked by AVG. > Version: 8.0.100 / Virus Database: 269.23.16/1448 - Release Date: 5/16/2008 7:42 PM >
Al Baker
2008-Aug-05 16:33 UTC
[asterisk-users] vars in Macros called by DIAL with option M
I would suggest putting a NOOP In the MACRO to ensure the variable IS actually getting SET. As I understand it VARIABLES are GLOBAL and what you are doing is correct, BUT, This could be a learning opportunity for me too. Be advised, there seems to be push by DIGIUM for folks to use the "subroutine" rather than MACROS now.... Hmmmm, Can the Dial command CALL a SUBROTINE as it does a MACRO ??? Ruddy Gbaguidi wrote:> And if you use DIALSTATUS and ANSWERTIME to check the last dial status, > you need to take care of the following bug > > http://bugs.digium.com/view.php?id=13216 > > Thomas Winter wrote: > >> Hi all, >> >> Iam using an DIAL Command wird Macro if callee is answer the call. >> >> exten => 123,n,DIAL(SIP/123 at provider,180,gM(test_connect)) >> exten => 123,n,NoOp( ${var_from_macro}) >> >> >> In Macro test_connect Iam generating an new variable var_from_macro and would >> like to use this var in the original dialplan. >> I tried also __var_from_macro but didnt work. How can I set vars in macros >> called by DIAL so that I can use these vars in the Dialplan or in the h >> extention. >> >> best regards >> Thomas >> >> _______________________________________________ >> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >> >> AstriCon 2008 - September 22 - 25 Phoenix, Arizona >> Register Now: http://www.astricon.net >> >> asterisk-users mailing list >> To UNSUBSCRIBE or update options visit: >> http://lists.digium.com/mailman/listinfo/asterisk-users >> >> ------------------------------------------------------------------------ >> >> >> Internal Virus Database is out of date. >> Checked by AVG. >> Version: 8.0.100 / Virus Database: 269.23.16/1448 - Release Date: 5/16/2008 7:42 PM >> >> > > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > AstriCon 2008 - September 22 - 25 Phoenix, Arizona > Register Now: http://www.astricon.net > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > >