<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 19, 2013 at 5:59 PM, Satish Barot <span dir="ltr"><<a href="mailto:satish4asterisk@gmail.com" target="_blank">satish4asterisk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">
<div class="im">On Thu, Apr 18, 2013 at 4:45 PM, Pat Collins <span dir="ltr"><<a href="mailto:drdialtone@optonline.net" target="_blank">drdialtone@optonline.net</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><div class="h5">
<p>All,<u></u><u></u></p>
<p>Thank you in advance for any help.<u></u><u></u></p><p>I have a customer in need of a conferencing system. A requirement is for users to each have their own PIN for the same bridge.<u></u><u></u></p><p>So, I put the list of users, PINs bridges into a MYSQL DB and used an ODBC connector to parse the table.<u></u><u></u></p>
<p>Asterisk is connected and reads the rows as expected. The problem is that if a user enters a PIN that is NOT in the table, asterisk goes crazy and continues to loop forever.<u></u><u></u></p><p>Please have a look and tell me where I went so wrong.<u></u><u></u></p>
<p>Func_odbc.conf looks like this:<u></u><u></u></p><p>[PIN]<u></u><u></u></p><p>dsn=BRIDGE<u></u><u></u></p><p>mode=multirow<u></u><u></u></p><p>readsql=SELECT pin from users WHERE confid='${SQL_ESC(${CONF_ID})}'<u></u><u></u></p>
<p><u></u> <u></u></p><p>extensions.conf section:<u></u><u></u></p><p>[infromhost] ;Host dials 8888 over SIP trunk exten=8888,1,Answer<u></u><u></u></p><p>exten=8888,n,Background(conf-getconfno)<u></u><u></u></p><p>exten=8888,n,WaitExten(10)<u></u><u></u></p>
<p>exten=8888,n,Hangup<u></u><u></u></p><p>exten=_XXXXXX,1,Set(GLOBAL(CONF_ID)=${EXTEN})<u></u><u></u></p><p>exten=_XXXXXX,n,GoTo(rooms,${EXTEN},1)<u></u><u></u></p><p>;<u></u><u></u></p><p>[rooms]<u></u><u></u></p><p>exten=_XXXXXX,1,Set(CONF_ID=${EXTEN})<u></u><u></u></p>
<p>exten=_XXXXXX,n,Background(conf-getpin)<u></u><u></u></p><p>exten=_XXXXXX,n,WaitExten(5)<u></u><u></u></p><p>exten=_XXXXXX,n,Hangup<u></u><u></u></p><p>exten=_1XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=_2XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p>
<p>exten=_3XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=_4XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=_5XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=_6XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p>
<p>exten=_7XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=_8XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=_9XXXXX,1,Goto(getpin,${EXTEN},1)<u></u><u></u></p><p>exten=i,1,Goto(getpin,${CONF_PIN},1)<u></u><u></u></p>
<p>;<u></u><u></u></p><p>[getpin]<u></u><u></u></p><p>exten=_XXXXXX,1,Set(GLOBAL(CONF_PIN)=${EXTEN})<u></u><u></u></p><p>exten=_XXXXXX,n,Set(ODBC_ID=${ODBC_PIN(1)})<u></u><u></u></p><p>exten=_XXXXXX,n(loop_start),NoOp()<u></u><u></u></p>
<p>exten=_XXXXXX,n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})})<u></u><u></u></p><p>exten=_XXXXXX,n,GotoIf($["${ODBC_FETCH}" = "FAILURE"]?cleanup,1) <u></u><u></u></p><p>exten=_XXXXXX,n,GotoIf($["${ROW_RESULT}" = "${CONF_PIN}"]?good_exten,1)<u></u><u></u></p>
<p>exten=_XXXXXX,n,Goto(loop_start)<u></u><u></u></p><p>;<u></u><u></u></p><p>exten=cleanup,1,Verbose(1,Finish up)<u></u><u></u></p><p>same=n,Verbose(1,PIN not found)<u></u><u></u></p><p>same=n,ODBCFinish(${ODBC_ID})<u></u><u></u></p>
<p>same=n,playback(conf-invalidpin)<u></u><u></u></p><p>same=n,Goto(rooms,${CONF_ID}1)<u></u><u></u></p><p>same=n,Hangup()<u></u><u></u></p><p>;<u></u><u></u></p><p>exten=good_exten,1,Verbose(1,The PIN is available)<u></u><u></u></p>
<p>same=n,ODBCFinish(${ODBC_ID})<u></u><u></u></p><p>same=n,Verbose(1,Drop Caller into the bridge)<u></u><u></u></p><p>same=n,Set(CONFBRIDGE(user,template)=default_user)<u></u><u></u></p><p>same=n,ConfBridge(${CONF_ID},default_bridge,,sample_user_menu)<u></u><u></u></p>
<p>same=n,Hangup()<u></u><u></u></p><p> <br></p><p><u></u></p></div></div><p>Thank you!!<span><font color="#888888"><u></u><u></u></font></span></p><span><font color="#888888"><p>Pat Collins...<u></u><u></u></p><p>
<br><u></u></p><p><u></u></p></font></span></div></blockquote></div><br></div><div class="gmail_extra">Change you <span style="color:rgb(51,51,51);font-size:13.142857551574707px;white-space:pre-wrap">[getpin] as below</span></div>
<div class="gmail_extra"><div class="gmail_extra">exten=>_XXXXXX,1,Set(GLOBAL(CONF_PIN)=${EXTEN})</div><div class="gmail_extra">exten=>_XXXXXX,n,Set(ODBC_ID=${ODBC_PIN(1)})</div><div class="gmail_extra">exten=>_XXXXXX,GotoIf($[${ODBCROWS} < 1]?cleanup,1)</div>
<div class="gmail_extra">exten=>_XXXXXX,,Set(COUNTER=1)</div><div class="gmail_extra">exten=>_XXXXXX,While($[${COUNTER} <= ${ODBCROWS}])</div><div class="gmail_extra">exten=>_XXXXXX,n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})})</div>
<div class="gmail_extra">exten=>_XXXXXX,n,GotoIf($["${ODBC_FETCH}" = "FAILURE"]?cleanup,1) </div><div class="gmail_extra">exten=>_XXXXXX,n,GotoIf($["${ROW_RESULT}" = "${CONF_PIN}"]?good_exten,1)</div>
<div class="gmail_extra">exten=>_XXXXXX,n,Set(COUNTER=$[${COUNTER + 1])</div><div class="gmail_extra">exten=>_XXXXXX,n,EndWhile()</div><div class="gmail_extra">exten=>_XXXXXX,n,ODBCFinish()</div><div class="gmail_extra">
exten=>_XXXXXX,n,Goto(cleanup,1)</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">exten=>cleanup,1,Verbose(1,Finish up)</div><div class="gmail_extra">same=>n,Verbose(1,PIN not found)</div>
<div class="gmail_extra">same=>n,ODBCFinish(${ODBC_ID})</div><div class="gmail_extra">same=>n,playback(conf-invalidpin)</div><div class="gmail_extra">same=>n,Goto(rooms,${CONF_ID}1)</div><div class="gmail_extra">
<br></div><div class="gmail_extra"><pre style="white-space:pre-wrap;word-wrap:break-word;overflow:hidden;margin:0em;color:rgb(51,51,51);font-size:13.142857551574707px">exten=>good_exten,1,Verbose(1,The PIN is available)
same=>n,ODBCFinish(${ODBC_ID})
same=>n,Verbose(1,Drop Caller into the bridge)
same=>n,Set(CONFBRIDGE(user,template)=default_user)
same=>n,ConfBridge(${CONF_ID},default_bridge,,sample_user_menu)
same=>n,Hangup()</pre></div></div><div><br></div><div>Further your readsql should be like this. </div>readsql=SELECT pin from users WHERE confid='${SQL_ESC(${ARG1})}' <div><br></div><div>You should have ${ARG1} instead of ${CONF_ID}<br>
<br>Hope this helps</div><span class=""><font color="#888888"><div><br>--Satish Barot<br>Ahmedabad, India</div></font></span></div>
</blockquote></div>:) I know I am not good at copy paste...</div><div class="gmail_extra"><div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px">Change you <span style="color:rgb(51,51,51);font-size:13.142857551574707px;white-space:pre-wrap">[getpin] as below</span></div>
<div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px"><div class="gmail_extra">exten=>_XXXXXX,1,Set(GLOBAL(CONF_PIN)=${EXTEN})</div><div class="gmail_extra">exten=>_XXXXXX,n,Set(ODBC_ID=${ODBC_PIN(1)})</div>
<div class="gmail_extra">exten=>_XXXXXX,n,GotoIf($[${ODBCROWS} < 1]?cleanup,1)</div><div class="gmail_extra">exten=>_XXXXXX,n,Set(COUNTER=1)</div><div class="gmail_extra">exten=>_XXXXXX,n,While($[${COUNTER} <= ${ODBCROWS}])</div>
<div class="gmail_extra">exten=>_XXXXXX,n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})})</div><div class="gmail_extra">exten=>_XXXXXX,n,GotoIf($["${ODBC_FETCH}" = "FAILURE"]?cleanup,1) </div><div class="gmail_extra">
exten=>_XXXXXX,n,GotoIf($["${ROW_RESULT}" = "${CONF_PIN}"]?good_exten,1)</div><div class="gmail_extra">exten=>_XXXXXX,n,Set(COUNTER=$[${COUNTER + 1])</div><div class="gmail_extra">exten=>_XXXXXX,n,EndWhile()</div>
<div class="gmail_extra">exten=>_XXXXXX,n,ODBCFinish()</div><div class="gmail_extra">exten=>_XXXXXX,n,Goto(cleanup,1)</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">
exten=>cleanup,1,Verbose(1,Finish up)</div><div class="gmail_extra">same=>n,Verbose(1,PIN not found)</div><div class="gmail_extra">same=>n,ODBCFinish(${ODBC_ID})</div><div class="gmail_extra">same=>n,playback(conf-invalidpin)</div>
<div class="gmail_extra">same=>n,Goto(rooms,${CONF_ID}1)</div><div class="gmail_extra"><br></div><div class="gmail_extra"><pre style="white-space:pre-wrap;word-wrap:break-word;overflow:hidden;margin:0em;color:rgb(51,51,51);font-size:13.142857551574707px">
exten=>good_exten,1,Verbose(1,The PIN is available)
same=>n,ODBCFinish(${ODBC_ID})
same=>n,Verbose(1,Drop Caller into the bridge)
same=>n,Set(CONFBRIDGE(user,template)=default_user)
same=>n,ConfBridge(${CONF_ID},default_bridge,,sample_user_menu)
same=>n,Hangup()</pre></div></div></div></div>