Sangoma D65 + Digium phones module + freePBX contact manager

Since I wanted my Digium D65 phones, which work flawlessly with a freePBX 14 server, to use the freePBX contactmanager, I created a script, which generates a xml-file the Digiums can understand.

Unfortunately, the Endpoint Manager in freePBX was not reliable enough to set up the Digiums, therefore I decided to use the advanced DPMA configuration with the Digium phone module. This works great, except that you have to use the phonebook in the Digium phone module, which does not supply any names to freePBX (CDR-Reports, name in VisualVoicemail).

I put a php file in the directory etc/asterisk/digium_phones
which is pb-update.php. I just adapted a similar script for other phones, I found here in the forum, I think…yet, I cannot find it anymore. I am no programer, but the script works. You can either execute it, using the terminal etc/asterisk/digium_phones/ php pb-update.php
or create a cronjob.
Once the script created the xml-file, you have to reconfigure the phones using the button in the web GUI (Digium phones module).

The “Display name”-field in the freePBX contact manager is, what the phone is showing you, including the info CELL, WORK etc.

<?php
$mysql_conn = mysql_connect('localhost','freepbxuser','XXXX');
mysql_select_db('asterisk', $mysql_conn);
$query = "SELECT number AS id, title AS prefix, concat(displayname, ' ', UPPER(type)) AS first_name, \"\" AS second_name, \"\" AS last_name, \"\" AS suffix, company AS organizaton, \"\" AS job_title, concat(company, ' ', address) AS location, \"\" AS notes, \"sip\" AS contact_type, number AS account_id FROM contactmanager_group_entries, contactmanager_entry_numbers WHERE contactmanager_group_entries.id = contactmanager_entry_numbers.entryid AND type != \"internal\"
";

$result = mysql_query($query, $mysql_conn);
if (! $result){
echo mysql_error();
}

$Output = "<?xml version=\"1.0\"?>\n<contacts group_name=\"phonebook-1\" editable=\"0\" id=\"0\">";
while($data = mysql_fetch_assoc($result)){
    $results[] = $data;
    $Output .= "\n <contact\n";
    foreach($data as $key => $value){
    $value = mb_convert_encoding($value, 'UTF-8', 'HTML');
    $Output .= "  $key=\"$value\"\n";
    }
    $Output .= " >\n";
    $Output .= "<actions>\n";
    $Output .= " <action id=\"primary\" dial=\"$value\" label=\"CL_ACTN_SIP\" name=\"CN_ACTN_DIAL\" transfer_name=\"CN_ACTN_TRANSFER\"/>";
    $Output .= "\n";
    $Output .= "</actions>\n";
    $Output .= " </contact>\n";
}
$Output .= "</contacts>\n";
// echo $Output;

file_put_contents('/var/www/html/digium_phones/phonebook-1.xml',$Output);

?>

Replace “XXXX” with the password of your freepbxuser…

1 Like

Just realized that the Digium D series phones are now officially Sangoma phones. The new name is Sangoma D65! Great phone, great decision… :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.