Tuesday, 25 September 2012

Nortel BCM <-> Asterisk

Nortel BCM <-> Asterisk

I've recently been working on linking our Nortel BCM 400 and Nortel BCM 50s to an Asterisk server to allow SIP DIDs and SIP trunks.


When the BCM sends calls to Asterisk it specifies the context in the call.  This code will remove it.

Contents of /var/lib/asterisk/agi-bin/bcm-fix.pl


#!/usr/bin/perl
#
# Strip extra data out of BCM calls to allow them to work with Asterisk.
#
#

use Asterisk::AGI;
my $AGI = new Asterisk::AGI;

$SIG{HUP} = "IGNORE";

my $destination = $ARGV[0];
$destination =~ s/;phone-context.*//g;

$AGI->exec('Dial','Local/' . $destination . '@from-internal');
exit(0);




Custom context for inbound BCM calls:


[from-internal-bcm]
exten => _.phone-context.,1,AGI(bcm-fix.pl,${EXTEN})
include => from-internal







7 comments:

  1. This is exactly what I need. My BCM50 will drop the phone-context when I remove the CDP from URI settings, but the BCM400 will leave it there.
    I have problems though. I created the bcm-fix.pl and put the custom context in my extensions_custom.conf changed the name to match my system(from-trunk), but it doesn't look like it's running the script. If I just run the script I get a "Can't locate Asterisk/AGI.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at ./bcm-fix.pl line 7."
    When I do a "locate AGI.pm" nothing comes up. I am using FreePBX 2.10 with asterisk 1.8. Any ideas? Thanks

    ReplyDelete
    Replies
    1. Try installing the Asterisk::AGI module from CPAN. I'm typing this command from memory...

      perl -MCPAN -e shell

      Say no to autoconfiguration and then type

      install Asterisk::AGI

      That should get you the missing perl module

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I was missing a few things. Asterisk-perl 1.03, ExtUtils::MakeMaker and perl-devel. So now I just have to figure out more about custom extensions. I noticed in your script you had "from-internal" but in mine it all looks like it should be "from-trunk". I tried changing a few different things but still couldn't get it to work.

    Here is what I get in my "full" log. Should I be changing your script to match "from-trunk"?

    Executing [7799;phone-context=@from-trunk-sip-Moncton:1] Set("SIP/Moncton-00000000", "GROUP()=OUT_1") in new stack
    [2013-04-11 12:57:21] VERBOSE[1729] pbx.c: -- Executing [7799;phone-context=@from-trunk-sip-Moncton:2] Goto("SIP/Moncton-00000000", "from-trunk,7799;phone-context=,1") in new stack
    [2013-04-11 12:57:21] VERBOSE[1729] pbx.c: -- Goto (from-trunk,7799;phone-context=,1)
    [2013-04-11 12:57:21] VERBOSE[1729] pbx.c: -- Executing [7799;phone-context=@from-trunk:1] Set("SIP/Moncton-00000000", "__FROM_DID=7799;phone-context=") in new stack
    [2013-04-11 12:57:21] VERBOSE[1729] pbx.c: -- Executing [7799;phone-context=@from-trunk:2] NoOp("SIP/Moncton-00000000", "Received an unknown call with DID set to 7799;phone-context=") in new stack
    [2013-04-11 12:57:21] VERBOSE[1729] pbx.c: -- Executing [7799;phone-context=@from-trunk:3] Goto("SIP/Moncton-00000000", "s,a2") in new stack

    ReplyDelete
  4. I have it as from-internal as that's where calls from my BCM400 end up. Do you have a SIP trunk setup for your BCM? Here's my trunk settings:

    host=10.10.10.1
    type=peer
    insecure=very
    qualify=yes
    context=from-internal-bcm
    disallow=all
    allow=ulaw&alaw
    canreinvite=no

    Every call coming in from the BCM hits the script and then gets pushed into the from-internal so it's just like a typical SIP call coming in from an extension.

    ReplyDelete
  5. I did finally get it working. It was because of the context settings. Thanks for your help and the script.

    ReplyDelete
  6. Our BCM finally died. It made for an interesting week running with a 1/2 broken phone system. We're really happy with our new FreePBX based system.

    ReplyDelete