Tuesday, March 2, 2010

Getting AOC-E to work in Asterisk 1.6

This is my approach to get AOC-E to work under asterisk.

The problem is when then non AOC receiving channel hangs up first. The call is destroyed, thus when AOC-E is received it cannot be saved.

A fast solution is to use the manager API and generate events for these situations.

This is the diff for chan dahdi



Make sure you save the AOC in your cdr in the cases that is retrieved when call is still there, in your outgoing context you should have something like:
Set(CDR(units)=${AOCE_UNITS});

Now for the other scenario you should have a manager listening to CDR AOC events (user events really). Using the span/logical/offset you can associate the AOC info to a call on your CDR. I am doing this manually having associations in the database like channel DAHDI/100 is at 5/0/1. Then simply finding the last outgoing call which involved that channel and updating the AOC does the trick.

Lastly note that this can be as precise as it looks. When matching the AOC information to a call's cdr outside asterisk there is always a chance of failing to find the correct one. In my manager app I am taking extra steps to avoid miss-associations using a rate estimator and the disposition of the call. Although it is working perfectly until now, I will need to work a bit more on it before releasing it..

Finally... If you are using B410P make absolutely sure you apply this patch otherwise you will loose calls and the changes will not have any effect under certain circumstances.