Provisioning grandstream phones

razametal

Joined
Jul 9, 2007
Messages
33
Likes
0
Points
0
#1
Hi,

I'm deploying some GXP280 phones with Elastix with the endpoint configurator module.

First, I need to download the firmware for the pones, the same firmware is used by GXP2000, GXP2020, BT200 and GXP280 phones.

To download the firmware and language pack:
Code:
cd /tftpboot
wget [url]http://www.grandstream.com/DOWNLOAD/FIRMWARE/BT200_GXP/Release_BT200_GXP_1.2.2.26.zip[/url]
unzip Release_BT200_GXP_1.2.2.26.zip
wget [url]http://www.grandstream.com/DOWNLOAD/FIRMWARE/BT200_GXP/GXP_Language_Pack.zip[/url]
unzip GXP_Language_Pack.zip
unzip Spanish.zip
wget [url]http://www.grandstream.com/DOWNLOAD/FIRMWARE/BT200_GXP/RingTone.zip[/url]
unzip RingTone.zip
Add the phone model (in my case GXP280) into the sqlite3 database:
Code:
sqlite3 /var/www/db/endpoint.db
sqlite> insert into model values(50,'GXP280','GXP280',3);
sqlite> insert into model values(51,'BT200','BT200',3);
sqlite> .exit
Now, we have to edit the template to adjust some configurations, the file is located at /var/www/html/modules/endpoint_configuration/libs/vendors/Grandstream.cfg.php :
Code:
<?php
/*
    PrincipalFileGrandstream nos retorna el contenido del archivo de configuracion de los EndPoint
    Grandstream, para ello es necesario enviarle el DisplayName, id_device, secret, ipAdressServer
*/
function PrincipalFileGrandstream($DisplayName, $id_device, $secret, $ipAdressServer)
{
    $content="
# Admin password for web interface
P2 = verysecurepassword

# Account Name
P270 = $id_device

# SIP Server
P47 = $ipAdressServer

# Outbound Proxy
P48 = $ipAdressServer

# SIP User ID
P35 = $id_device

# Authenticate ID
P36 = $id_device

# Authenticate password
P34 = $secret

# Display Name (John Doe)
P3 = $DisplayName

# DHCP support. 0 - yes, 1 - no
P8 = 0

# Specific tone settings for Ecuador
# Dial Tone
P343 = f1=425,f2=425;

# Busy Tone
P348 = f1=425,f2=425,c=33/33;

# Send DTMF. 8 - in audio, 1 - via RTP, 2 - via SIP INFO
# 11 - In Audio & RTP & SIP INFO, 9 - In Audio & RTP
# 10 - IN Audio & SIP INFO, 3 - RTP & SIP INFO
P73 = 1

# Ringtone 1
P105 = ring1.bin

# Display Language. 0 - English, 3 - Secondary Language, 2 - Chinese
P342 = 3

# language file postfix
P399 = Spanish

# NTP Server
P30 = $ipAdressServer

# Enable Call Features.  0 - no, 1 - yes
P191 = 0

# Account Ring Tone. 0 - system ring tone, 1 - custom ring tone 1, 2 - custom ring tone 2
# 3 - custom ring tone 3.
P104 = 3

# Display CID instead of Name. 0 - no, 1 - yes
# GXP280 only
P1344 = 0

# SIP User ID is phone number. 0 - no, 1 - yes
P63 = 1

# SIP Registration. 0 - no, 1 - yes
P31 = 1

# Unregister On Reboot. 0 - no, 1 - yes
P81 = 1

# Register Expiration (in minutes. default 1 hour, max 45 days)
P1812 = 5

# Lock Keypad Update. 0 - no, 1 - yes
P88 = 1

# Firmware Upgrade. 0 - TFTP Upgrade,  1 - HTTP Upgrade.
P212 = 0

# Firmware Server Path
P192 = $ipAdressServer

# Config Server Path
P237 = $ipAdressServer

# Automatic Upgrade. 0 - No, 1 - Yes. Default is No.
P194 = 0

# Check for new firmware every () minutes, unit is in minute, minimnu 60 minutes, default is 7 days.
P193 = 10080

# Use firmware pre/postfix to determine if f/w is required
# 0 = Always Check for New Firmware
# 1 = Check New Firmware only when F/W pre/suffix changes
# 2 = Always Skip the Firmware Check
P238 = 1

#----------------------------------------
# XML Phonebook
#----------------------------------------
# Enable Phonebook XML Download
# 0 = No
# 1 = YES, HTTP
# 2 = YES, TFTP
P330 = 2

# Phonebook XML Server Path
P331 = $ipAdressServer

# Phonebook Download Interval
# This is an integer variable in hours.
# Valid value range is 0-720 (default 0), and greater values will default to 720
P332 = 12

# Remove Manually-edited entries on Download
# 0 - No, 1 - Yes, other values ignored
P333 = 0";

    return $content;
}

function templatesFileGrandstream($ipAdressServer)
{
    $content= <<<TEMP
# SIP Server
P47 = $ipAdressServer

# Outbound Proxy
P48 = $ipAdressServer

# SIP User ID
P35 = 8000

# Authenticate ID
P36 = 8000

# Authenticate password
P34 = 0000

# Display Name (John Doe)
P3 =

# DHCP support. 0 - yes, 1 - no
P8 = 1
TEMP;
    return $content;
}
?>
If you want to enable the phonebook, create the following php file /tftpboot/gs_phonebook.php :
Code:
<?php

// File: gs_phonebook.php
// version: 1.0
// Date: 07-17-2006
// Author: Shane Steinbeck http://www.steinbeckconsulting.com
// Description: Realtime XML phonebook from MySQL database for Grandstream GXP-2000 firmware 1.1.1.17
// Modified by Guillermo Salas <gsalas@mantareys.com> to use the FreePBX database to show the name and
// extension number.

header("Content-type: text/xml");

$host = "localhost";
$user = "root";
$pass = "eLaStIx.2oo7";
$database = "asterisk";

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");

$query = "SELECT user, description FROM devices ORDER BY description ASC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");

$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<AddressBook>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
 $row = mysql_fetch_assoc($resultID);
 $xml_output .= "\t<Contact>\n";
 $xml_output .= "\t\t<LastName>" . $row['description'] . "</LastName>\n";
 $xml_output .= "\t\t<FirstName></FirstName>\n";
 $xml_output .= "\t\t\t<Phone>\n\t\t\t\t<phonenumber>" . $row['user'] . "</phonenumber>\n";
 $xml_output .= "\t\t\t\t<accountindex>0</accountindex>\n";

 $xml_output .=  "\t\t\t</Phone>\n";
 $xml_output .= "\t</Contact>\n";
}

$xml_output .= "</AddressBook>";

/***************************************************************************************

    * Author: Mike
    * Date: 10/03/2006
    * This snipplet will save your xml file to the server for easier updating of your phone.
    * To facilitate automatic updates, add a cron job to run this file at your desired interval (i.e. hourly).
*/


$filename = "/tftpboot/gs_phonebook.xml";

$fp = fopen($filename, 'wb');
fwrite($fp, $xml_output);
fclose($fp);


/**************************************************************************************/

print($xml_output);
echo $xml_output;

?>

Create a cronjob to maintain the file updated:
Code:
vi /etc/cron.daily/gs_phonebook

/usr/bin/php /tftpboot/gs_phonebook.php
Finaly, on the device go to Config/Upgrade and change the tftp config server and tftp update server to the ip of your elastix box, change the parameter upgrade via to use tftp and not http as is used by default.

Connect your device to the network, use the module endpoint configuration and assing the model and extension to the phone, press configure and finally reboot the phone.

When the phone will be starting to download:
firmware
language
ringtone
phonebook
 

razametal

Joined
Jul 9, 2007
Messages
33
Likes
0
Points
0
#2
It is necessary to make the following changes into the module files to make the provision work.

1.- The provisioning application for grandstream resides into /tftboot path. The endpoint module uses a script called encode.sh, I've changed the contents of the file with the following data to make it working:

* Replace the content of /tftpboot/GS_CFG_GEN/bin/encode.sh with:

#!/bin/bash

JAVA_HOME=/opt/openfire/jre
GAPSLITE_HOME=/tftpboot/GS_CFG_GEN

# Do NOT modify below this line
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$GAPSLITE_HOME/lib/`uname -m`
export LD_LIBRARY_PATH

$JAVA_HOME/bin/java -classpath $GAPSLITE_HOME/lib/gapslite.jar:$GAPSLITE_HOME/lib/bcprov-jdk14-124.jar:$GAPSLITE_HOME/config com.grandstream.cmd.TextEncoder $*

2.- The endpoint module create the configuration file basen on the Grandstream template file, later execute the Grandstream provisioning binary to produce a valid configuration file but is adding the extension .cfg at the end of the filename making it inussable. The phone will be requesting a filename like cfgxxxxxxxxxxxx and not cfgxxxxxxxxxxxx.cfg file created by the module.

To fix this issue try the following:

* Search on /var/www/html/modules/endpoint_configuration/libs/paloSantoFileEndPoint.class.php :

exec("/tftpboot/GS_CFG_GEN/bin/encode.sh {$ArrayData['data']['filename']} /tftpboot/gxp{$ArrayData['data']['filename']}.cfg /tftpboot/cfg{$ArrayData['data']['filename']}.cfg",$arrConsole,$flagStatus);
And replace by:

Code:
exec("/tftpboot/GS_CFG_GEN/bin/encode.sh {$ArrayData['data']['filename']} /tftpboot/gxp{$ArrayData['data']['filename']}.cfg /tftpboot/cfg{$ArrayData['data']['filename']}",$arrConsole,$flagStatus);
Now the created configuration file will be created without the .cfg extension.

With this two small modifications the endpoint module works like a charm with grandstream phones. I'm using GXP280 and GXP2000 now.
 

razametal

Joined
Jul 9, 2007
Messages
33
Likes
0
Points
0
#3
La version en castellano la pueden mirar en este enlace.
 

otidh

Joined
Jun 7, 2010
Messages
1
Likes
0
Points
0
#4
Right now we're implementing personalized phonebook.
We use PHP to generate XML Phonebook.
We set XML Phonebook Server Path to something like
Code:
host:phonebook.php?id=xxx
If we call that path in browser it produce right XML Phonebook.
But when we use them it in device (model
Code:
GXP280
) the phonebook couldn't load.

Any solution about this?

Thanks.
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,887
Members
17,566
Latest member
Fpino
Top