Polycom BLF on Asterisk (and FreePBX)

There seems to be a lot of misinformation floating around on this subject, but after ignoring most of it and playing around I have a FreePBX system with BLF, remote caller ID, and directed pickup all working fine on my Polycom phone. Here’s how I did it, for the record.

Requirements

Here’s what I’m using:

  • Asterisk 1.8.7.2
  • FreePBX 2.10.1.9
  • Polycom SIP 3.3.5.0247

The phone is behind NAT, the PBX is an unpatched version of Asterisk with a fairly plain FreePBX setup. Originally was a PBX in a Flash system, but I just used that as a base as I’m not fond of PIAF’s update mechanisms.

Setup

  • In the Asterisk SIP settings module, under Other SIP Settings add notifycid = ignore-context
  • In the extension, set sendrpid to Send Remote-Party-ID header
  • On the phone, set the following configuration entries:
    <blf
      call.directedCallPickupMethod="native"
      attendant.resourceList.1.address="7999"
      attendant.resourceList.1.label="Joe"
    />

    <blf call.directedCallPickupMethod="native" attendant.resourceList.1.address="7999" attendant.resourceList.1.label="Joe" />

That’s it. No callgroup, no pickupgroup, no mucking around with features.conf or worrying about directed call pickup strings. The only drawback is an ugly SIP URI in the caller ID of the “To:” field. This patch may fix that. Still a work in progress…

--- channels/chan_sip.c	2011-07-14 16:13:06.000000000 -0400
+++ channels/chan_sip.c	2013-04-04 14:53:36.000000000 -0400
@@ -12158,6 +12158,7 @@
 		ast_str_append(tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">", p->dialogver, full ? "full" : "partial", mto);
 		if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
 			const char *local_display = exten;
+			const char *mto_display = exten;
 			char *local_target = ast_strdupa(mto);
 
 			/* There are some limitations to how this works.  The primary one is that the
@@ -12178,6 +12179,8 @@
 					snprintf(local_target, need, "sip:%s@%s", cid_num, p->fromdomain);
 					local_display = ast_strdupa(S_COR(caller->caller.id.name.valid,
 						caller->caller.id.name.str, ""));
+					mto_display = ast_strdupa(S_COR(caller->connected.id.name.valid,
+						caller->connected.id.name.str, ""));
 					ast_channel_unlock(caller);
 					caller = ast_channel_unref(caller);
 				}
@@ -12199,10 +12202,10 @@
 						"<target uri=\"%s\"/>\n"
 						"</remote>\n"
 						"<local>\n"
-						"<identity>%s</identity>\n"
+						"<identity display=\"%s\">%s</identity>\n"
 						"<target uri=\"%s\"/>\n"
 						"</local>\n",
-						local_display, local_target, local_target, mto, mto);
+						local_display, local_target, local_target, mto_display, mto, mto);
 			} else {
 				ast_str_append(tmp, 0, "<dialog id=\"%s\" direction=\"recipient\">\n", exten);
 			}

--- channels/chan_sip.c 2011-07-14 16:13:06.000000000 -0400 +++ channels/chan_sip.c 2013-04-04 14:53:36.000000000 -0400 @@ -12158,6 +12158,7 @@ ast_str_append(tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">", p->dialogver, full ? "full" : "partial", mto); if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) { const char *local_display = exten; + const char *mto_display = exten; char *local_target = ast_strdupa(mto); /* There are some limitations to how this works. The primary one is that the @@ -12178,6 +12179,8 @@ snprintf(local_target, need, "sip:%s@%s", cid_num, p->fromdomain); local_display = ast_strdupa(S_COR(caller->caller.id.name.valid, caller->caller.id.name.str, "")); + mto_display = ast_strdupa(S_COR(caller->connected.id.name.valid, + caller->connected.id.name.str, "")); ast_channel_unlock(caller); caller = ast_channel_unref(caller); } @@ -12199,10 +12202,10 @@ "<target uri=\"%s\"/>\n" "</remote>\n" "<local>\n" - "<identity>%s</identity>\n" + "<identity display=\"%s\">%s</identity>\n" "<target uri=\"%s\"/>\n" "</local>\n", - local_display, local_target, local_target, mto, mto); + local_display, local_target, local_target, mto_display, mto, mto); } else { ast_str_append(tmp, 0, "<dialog id=\"%s\" direction=\"recipient\">\n", exten); }

Comments are closed.