[solved] Get the real answered time

Hello,

I use AGI and AMI with Asterisk.
I create call with Dial and I need to manage time limitation. I know there is the “L(X:Y:Z)” parameters, but my problem is the time limit can change during the call.

ex: you have 1min credit in your wallet, you started a call but in the meantime a friend put 5min credit on your wallet, I have to extend the time limitation in realtime.

My first problem is to know the real answered time (without the ringing time) as quick as possible, I can’t wait the end of the call.
Any idea ?

Thank you.

When Dial jumps to the subroutine or macro, of the label from the G option.

Thank you for your help.
I 'm going to take a look at the G option.

Hi,

to be honest, I’m totally new to the Asterisk’s world.
I’ve checked the G option for the Dial command, but I don’t undestand how I can solve my problem with this.
Could you detail a little bit ?
thank you !

G causes dial plan to be run when part B answers. You can then use Bridge() to complete the call. You need to put a Wait(), etc., on the other channel to keep it open until the bridge. The subroutine and macro options also cause dialplan to be run, but only on the party B channel.

Hi!

I think you can not solve it with dial options. You should write a daemon what listen via AMI and check the credits.
If a call start the daemon note/save the start time and periodically check the phone number’s credits. If the nuber has no credit the daemon send a hangup via AMI.

[quote=“tomaszcool”]Hi!

I think you can not solve it with dial options. You should write a daemon what listen via AMI and check the credits.
If a call start the daemon note/save the start time and periodically check the phone number’s credits. If the nuber has no credit the daemon send a hangup via AMI.[/quote]

That was exaclty what i’ve tried to do, but no success.
I’ve tried a “GetVar” of “ANSWEREDTIME” to the desired channel, but it return no data.
I’ve read, that we can get the “ANSWEREDTIME” value only when the call is ended.

With AMI you will get an event when the call is answered.

Sing up some basic event: Newstate (listen to the ChannelState: X attribute) and maybe the Hangup. If a Newstate event arrive u can create a timestamp for your own.

Hi,

Finally got it working.
I first check the value of “CDR(DISPOSITION)” to check the aswered state of the channel.
If the state is “ANSWERED” then I check the value of “CDR(answer)” to get the asnwered time.
Thanks guy for your hints :wink: