3

I have a legacy Asterisk application in C which does authentication of users, routing and billing using MySQL. I have kept it with Asterisk 1.4.21 because none of the CDR data is returned in newer versions of Asterisk.

Apparently there have been some changes in 1.4.22 https://issues.asterisk.org/jira/browse/ASTERISK-13064 that have completely changed the way CDR-s are handled. Unfortunately no helpful information was given on how to properly migrate existing code.

They have changed the order of execution, the 'h' extension is called and the CDR data is reset.

My code:


ast_log(LOG_NOTICE,"Dialing string: '%s'\n", dialstr);

app = pbx_findapp("Dial");
if (app)
        res = pbx_exec(chan, app, dialstr);

ast_log(LOG_NOTICE,"Return from pbx_exec '%i', Disposition: '%s'\n", res, ast_cdr_disp2str(chan->cdr->disposition));

Other parts of the code handle chan->cdr->billsec etc, but it always gives 0 values.

After a successful call I always get this log from CLI:

Return from pbx_exec '-1', Disposition: 'NO ANSWER'
while the same code works fine on 1.4.21

One solution I heard is to use ast_reset() before Dial but I am not sure how to implement it. Any help on how to adapt this application?

Ed.C
  • 798
  • 1
  • 6
  • 17

1 Answers1

2

You can just get DIALSTATUS variable,that is enought for you application and will be supported in future releases.

pbx_builtin_getvar_helper(chan, "DIALSTATUS");
arheops
  • 15,544
  • 1
  • 21
  • 27
  • Thank you arheops! I was loosing hopes in this! DIALSTATUS actually does the job to get the call disposition, but I am interested in getting the CDR after returning from Dial(), that is what the 3000 other lines of C deal with... Any ideas on this matter? I know I can alter the call flow with 'Dial' and 'g' option, returning to code and getting CDR details (billsec the most important) before asterisk calls the 'h' extension. But can I trust that? Is there any cleaner way to do this? – Ed.C Dec 03 '12 at 10:58
  • I recomend you use "legacy" way. You always can ask variable CDR(billsec) or ANSWEREDTIME. I not think u have use low-level magic for something you can use variables. – arheops Dec 05 '12 at 22:34