ODBC func problem

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

ODBC func problem

Postby smutkovski » Thu Jan 21, 2016 3:08 am

Hello,
i got problem with getting asterisk send queries to db via odbc functions.

this is what i have done:
installed odbc packages(unixODBC,unixODBC-bin,unixODBC-dev,libmyodbc)
recompiled asterisk with these modules cdr_odbc, cdr_adaptive_odbc, func_odbc, func_realtime, pbx_realtime, res_config_odbc and res_odbc
Code: Select all
/etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

/etc/odbc.ini
[asterisk-connector]
Description= MySQL connection to asterisk database
Driver=MySQL
Database=asterisk
Server=localhost
UserName=root
Password=passwd123
Port=3306
Socket=/var/run/mysqld/mysqld.sock

/etc/asterisk/res_odbc.conf
[asterisk]
enabled => yes
dsn => asterisk-connector
username => root
password => passwd123
pooling => no
limit => 1
pre-connect => yes

this is my dial plan:
exten=> _XXXXX,1,NoOp()
same=>n,Set(E=${EXTEN})
same=>n,Set(USER=GET_USERDATA(${E}))
same=>n,Dial(SCCP/${E},120)
same=>n,Goto(s-${DIALSTATUS},1)

exten=>s-BUSY,1,NoOp(CALLS_MISSED(${USER},${E},'BUSY'))
same=>n,Hangup()

exten=>s-CANCEL,1,NoOp(CALLS_MISSED(${USER},${E},'CANCEL'))
same=>n,Hangup()

exten=>s-CHANUNAVAIL,1,NoOp(CALLS_MISSED(${USER},${E},'CHANNELUNAVAIL'))
same=>n,Hangup()

exten=>s-NOANSWER,1,NoOp(CALLS_MISSED(${USER},${E},'NOANSWER'))
same=>n,Hangup()

exten=>s-ANSWER,1,NoOp(CALLS_INCOMMING(${USER},${E}))
same=>n,Hangup()


and here are the function:
[MISSED]
prefix=CALLS
dsn=asterisk
writesql=INSERT INTO missedcalls (callername,callednumber,status) VALUES ('${ARG1}','${ARG2}','${ARG3}')

[INCOMMING]
prefix=CALLS
dsn=asterisk
writesql=INSERT INTO incomming (callername,callednumber) VALUES ('${ARG1}','${ARG2}')


Problem is nothing in db changes and i don't know if i missed something or not.
thanks for help
smutkovski
Newsterisk
 
Posts: 6
Joined: Sat Mar 07, 2015 4:34 am

Re: ODBC func problem

Postby smutkovski » Thu Jan 21, 2016 10:00 am

Oh i forgot to add:
Asterisk version 11.13.0
Debian 64bit
MySQL 5.5 (both mysql-server and mysql-client installed)

(phones register to asterisk correctly and i can dial bettwen them)
don't know if this info will help.
smutkovski
Newsterisk
 
Posts: 6
Joined: Sat Mar 07, 2015 4:34 am

Re: ODBC func problem

Postby smutkovski » Mon Jan 25, 2016 1:23 pm

Hi,
after long period of time, i find out that odbc function works (tried them in asterisk cli)
the problem was in dialplan , i left calling of the odbc functions in NoOp() which does nothing by itself :).
So here comes my new dialplan:
Code: Select all
exten=> _XXXXX,1,NoOp()
same=>n,Set(GLOBAL(E)=${EXTEN})
same=>n,Set(GLOBAL(USER)=${GET_USERDATA(${E})})
same=>n,Set(GLOBAL(MCALLER)=${CALLERID(name)})
same=>n,Set(CALLS_PLACEDCALLS()=${MCALLER},${E},BEFORECALL,${USER})
same=>n,Dial(SCCP/${E},60)
same=>n,Set(CALLS_PLACEDCALLS()=${MCALLER},${E},${DIALSTATUS},${USER})

Function PLACEDCALLS() looks:
Code: Select all
[PLACEDCALLS]
prefix=CALLS
dsn=asterisk
writesql=INSERT INTO missedcalls (callername,callednumber,status,calledname) VALUES ('${VAL1}','${VAL2}','${VAL3}')


My current problem is this, PLACEDCALLS() before Dial() is corectly called by asterisk and write corectly to database, but the PLACEDCALLS() after Dial() is not reached by asterisk at all. I don't know if it's SCCP-b channel thing, but it doesn't matter if call is answered or not, it allways ends in Dial.

So please if someone is more knowleable with dialplans with SCCP channel and point me to right way, i would be very happy. :)
smutkovski
Newsterisk
 
Posts: 6
Joined: Sat Mar 07, 2015 4:34 am

Re: ODBC func problem

Postby satish4asterisk » Tue Jan 26, 2016 3:11 am

You should have
Code: Select all
Set(CALLS_PLACEDCALLS()=${MCALLER},${E},${DIALSTATUS},${USER})
in your h extension

--Satish Barot
satish4asterisk
Oldsterisk
 
Posts: 210
Joined: Fri Dec 23, 2011 1:12 am

Re: ODBC func problem

Postby smutkovski » Tue Jan 26, 2016 3:18 am

satish4asterisk wrote:You should have
Code: Select all
Set(CALLS_PLACEDCALLS()=${MCALLER},${E},${DIALSTATUS},${USER})
in your h extension

--Satish Barot


You mean like extension.h, i never heard of it :( could you please point me to source from where you know it from.
Thanks
smutkovski
Newsterisk
 
Posts: 6
Joined: Sat Mar 07, 2015 4:34 am


Re: ODBC func problem

Postby smutkovski » Wed Jan 27, 2016 3:35 am

smutkovski
Newsterisk
 
Posts: 6
Joined: Sat Mar 07, 2015 4:34 am


Return to Asterisk Support

Who is online

Users browsing this forum: Google [Bot] and 1 guest