On Thu, Apr 18, 2013 at 4:45 PM, Pat Collins <drdialt...@optonline.net>wrote:
> All,**** > > Thank you in advance for any help.**** > > 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.**** > > So, I put the list of users, PINs bridges into a MYSQL DB and used an ODBC > connector to parse the table.**** > > 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.**** > > Please have a look and tell me where I went so wrong.**** > > Func_odbc.conf looks like this:**** > > [PIN]**** > > dsn=BRIDGE**** > > mode=multirow**** > > readsql=SELECT pin from users WHERE confid='${SQL_ESC(${CONF_ID})}'**** > > ** ** > > extensions.conf section:**** > > [infromhost] ;Host dials 8888 over SIP trunk exten=8888,1,Answer**** > > exten=8888,n,Background(conf-getconfno)**** > > exten=8888,n,WaitExten(10)**** > > exten=8888,n,Hangup**** > > exten=_XXXXXX,1,Set(GLOBAL(CONF_ID)=${EXTEN})**** > > exten=_XXXXXX,n,GoTo(rooms,${EXTEN},1)**** > > ;**** > > [rooms]**** > > exten=_XXXXXX,1,Set(CONF_ID=${EXTEN})**** > > exten=_XXXXXX,n,Background(conf-getpin)**** > > exten=_XXXXXX,n,WaitExten(5)**** > > exten=_XXXXXX,n,Hangup**** > > exten=_1XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_2XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_3XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_4XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_5XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_6XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_7XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_8XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=_9XXXXX,1,Goto(getpin,${EXTEN},1)**** > > exten=i,1,Goto(getpin,${CONF_PIN},1)**** > > ;**** > > [getpin]**** > > exten=_XXXXXX,1,Set(GLOBAL(CONF_PIN)=${EXTEN})**** > > exten=_XXXXXX,n,Set(ODBC_ID=${ODBC_PIN(1)})**** > > exten=_XXXXXX,n(loop_start),NoOp()**** > > exten=_XXXXXX,n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})})**** > > exten=_XXXXXX,n,GotoIf($["${ODBC_FETCH}" = "FAILURE"]?cleanup,1) **** > > exten=_XXXXXX,n,GotoIf($["${ROW_RESULT}" = "${CONF_PIN}"]?good_exten,1)*** > * > > exten=_XXXXXX,n,Goto(loop_start)**** > > ;**** > > exten=cleanup,1,Verbose(1,Finish up)**** > > same=n,Verbose(1,PIN not found)**** > > same=n,ODBCFinish(${ODBC_ID})**** > > same=n,playback(conf-invalidpin)**** > > same=n,Goto(rooms,${CONF_ID}1)**** > > same=n,Hangup()**** > > ;**** > > 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()**** > > > > ** > > Thank you!!**** > > Pat Collins...**** > > > ** > > ** > Change you [getpin] as below exten=>_XXXXXX,1,Set(GLOBAL(CONF_PIN)=${EXTEN}) exten=>_XXXXXX,n,Set(ODBC_ID=${ODBC_PIN(1)}) exten=>_XXXXXX,GotoIf($[${ODBCROWS} < 1]?cleanup,1) exten=>_XXXXXX,,Set(COUNTER=1) exten=>_XXXXXX,While($[${COUNTER} <= ${ODBCROWS}]) exten=>_XXXXXX,n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})}) exten=>_XXXXXX,n,GotoIf($["${ODBC_FETCH}" = "FAILURE"]?cleanup,1) exten=>_XXXXXX,n,GotoIf($["${ROW_RESULT}" = "${CONF_PIN}"]?good_exten,1) exten=>_XXXXXX,n,Set(COUNTER=$[${COUNTER + 1]) exten=>_XXXXXX,n,EndWhile() exten=>_XXXXXX,n,ODBCFinish() exten=>_XXXXXX,n,Goto(cleanup,1) exten=>cleanup,1,Verbose(1,Finish up) same=>n,Verbose(1,PIN not found) same=>n,ODBCFinish(${ODBC_ID}) same=>n,playback(conf-invalidpin) same=>n,Goto(rooms,${CONF_ID}1) 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() Further your readsql should be like this. readsql=SELECT pin from users WHERE confid='${SQL_ESC(${ARG1})}' You should have ${ARG1} instead of ${CONF_ID} Hope this helps --Satish Barot Ahmedabad, India
-- _____________________________________________________________________ -- 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