Hi
For testing i have to configure two test account using sip protocol with my 127.0.0.1. What is happening when i call to account1 to account2 then the call information is generating but i cannot store it in mysql db . So here is my configuration what i made in below:
1.create 2 account in regfile.conf
2.in register.conf changes are
[general]
expires=30
stoperror=busy
user.auth=on
user.register=on
user.unregister=on
engine.timer=on
call.preroute=on
call.route=on
call.cdr=om
[default]
priority=50
account=yate
[call.cdr]
-- Usage of the function in register.conf, only difference in cdr_insert/update and cdr_finalize is the last value for "ended"
cdr_insert=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', false);
cdr_update=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', false);
cdr_finalize=SELECT cdr_upsert(${time}, '${billid}', '${chan}', '${address}', '${caller}', '${callername}', '${called}', ${billtime}, ${ringtime}, ${duration}, '${direction}', '${status}', '${reason}', true);
also create mysql table using below way
CREATE TABLE IF NOT EXISTS `cdr` (
`idcdr` BIGINT NULL AUTO_INCREMENT,
`sqltime` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`yatetime` INT(11) NULL,
`billid` VARCHAR(55) NOT NULL,
`chan` VARCHAR(20) NULL,
`address` CHAR(15) NULL,
`addressport` CHAR(5) NULL,
`caller` VARCHAR(55) NULL,
`callername` VARCHAR(255) NULL,
`called` VARCHAR(55) NULL,
`billtime` FLOAT NULL,
`ringtime` FLOAT NULL,
`duration` FLOAT NULL,
`direction` ENUM('incoming','outgoing') NULL,
`status` VARCHAR(11) NULL,
`reason` VARCHAR(55) NULL,
`ended` TINYINT(1) NULL,
PRIMARY KEY (`idcdr`),
INDEX `ix_cdr_sqltime` (`sqltime` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
-- A primary key to prevent duplicates on billid and chan
CREATE UNIQUE INDEX uq_cdr_billid_chan ON cdr (billid, chan);
-- A function to use for CDR operations
delimiter $$
CREATE FUNCTION cdr_upsert (p_yatetime INT(11), p_billid varchar(20), p_chan varchar(20), p_address varchar(21), p_caller varchar(55), p_callername varchar(255), p_called varchar(55), p_billtime float, p_ringtime float,
p_duration float, p_direction enum('incoming','outgoing'), p_status varchar(11), p_reason varchar(55), p_ended tinyint(1)) RETURNS SMALLINT(1)
BEGIN
DECLARE i_ended TINYINT(1);
DECLARE i_address_port VARCHAR(5);
-- extracting IP and Port
SET i_address_port = (SUBSTRING(p_address, POSITION(':' IN p_address) + 1));
SET p_address = (SUBSTRING(p_address, 1, POSITION(':' IN p_address) - 1));
-- Checking current CDR state, when ended is true, then no update should be done, because cdr_finalize was already called
SELECT ended INTO i_ended FROM cdr WHERE billid = p_billid AND chan = p_chan FOR UPDATE;
IF i_ended IS NULL OR i_ended = 0 THEN
-- perform an UPSERT meaning: try to INSERT the data, if there is a DUPLICATE KEY (uq_cdr_billid_chan which we created ealiert) then do an update on that record instead
INSERT INTO cdr (sqltime, yatetime, billid, chan, address, addressport, caller, callername, called, billtime, ringtime, duration, direction, status ,reason, ended)
VALUES (FROM_UNIXTIME(p_yatetime), p_yatetime, p_billid, p_chan, p_address, i_address_port, p_caller, p_callername, p_called, p_billtime, p_ringtime, p_duration,
p_direction, p_status, p_reason, p_ended) ON DUPLICATE KEY UPDATE sqltime = VALUES(sqltime), yatetime = VALUES(yatetime), address = VALUES(address), addressport = VALUES(addressport),
caller = VALUES(caller), callername = VALUES(callername), called = VALUES(called), billtime = VALUES(billtime), ringtime = VALUES(ringtime), duration = VALUES(duration),
direction = VALUES(direction), status = VALUES(status), reason = VALUES(reason),
ended = VALUES(ended);
END IF;
RETURN 1;
END;
$$
delimiter ;
------------
3. in mysqldb.conf changes are
[yate]
host=localhost
database=test
user=root
password=
port=87
4. in yate.conf changes
[module]
mysqldb.yate=true
register.yate=true
so here is my configuration . Please help me .if done any mistake.
THANKS