Provisioning Grandstream phones

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#1
Hi.

I would like make some provisioning with my grandstream phone, but nothing!

I put the TFTP IP adresse in each fields as (firmware and config).
Firmware works fine, but nothing for the config file.

We know that every file are like this!
gxp00B282000000.cfg

So now, question.
gxp is the prefix?
cfg what is it? the postfix, or it's '.cfg'?
Otherwise, I must leave it blank?

And into the config file there's this.

Code:
# SIP Server
P47 = 193.107.20.38

# Outbound Proxy
P48 = 193.107.20.38

# SIP User ID
P35 = 101

# Authenticate ID
P36 = 101

# Authenticate password
P34 = ****

# Display Name (John Doe)
P3 = Chambre Patou

# DHCP support. 0 - yes, 1 - no
P8 = 1
Problem, here, there's P8=1
So, the DHCP is not supported.!
For me, a function with 1 is enable, so dhcp support, no?

And if I look some example from the web, the file format is different!
It's something like that:

P47=193.107.20.38&P48=193.107.20.38&P35=101&P36=101&P34=****&P3=Chambre Patou&P8=1&
Today, I don't know which way I could take.

If somebody could help me.

Regards
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#2
Ok.. I discovered where come from the problem.

There was a bug into Elastix 1.6.1x., and why not 1.5 and 1.3!

Some explanations:

Firstly, every GrandStream phones need a specific file, and not a simple text file.
So, gxp_mac_adress.cfg is not in the good file format.

When you clic on the button "define", a file is created gxp_mac_adress.cfg, and another file also that's used like a template file. These file are used normally by a script shell (/tftpboot/GS_CFG_GEN/bin/encode.sh) , calling (/usr/java/j2sdk1.4.2_07/bin/java).

The problem that there isn't "/usr/java/j2sdk1.4.2_07/bin/java", so the shell can't working.
encode.sh is used to make the specific file like for example: cfg000b8203ce2b

I replaced encode.sh by encode with this code:

Code:
#!/usr/bin/perl -w
use strict;

# Posted on http://lists.digium.com/pipermail/asterisk-users/2004-September/063515.html [^]
# Bugfixes by Lionel Elie Mamane <lionel@mamane.lu>:
# - Properly url-encode values
# - Don't remove whitespace from values (only leading and trailing)

my $h_mac = shift ; # '000b8203ce2b' # hexadecimal mac address
my $f_in = shift ; # 'config.txt' # file body, configfile containing all parameters
my $f_out = shift ; # 'cfg.out' # the configfile that will be written to

my $h_crlf = '0d0a'; # hexadecimal crlf

# convert some things to binary
my $b_mac = pack("H12", $h_mac); # convert 12 hex numbers to bin
my $b_crlf = pack("H4", $h_crlf); # convert 4 hex numbers to bin

# open configfile and make body in ascii (a_body)
my $a_body;
open F,$f_in;
while (<F>) {
    chomp; # remove trailing lf
    s/\#.*$//; # remove comments
    s/^\s*//; # remove all leading whitespace
    s/\s*$//; # remove all trailing whitespace
    if ( $_ ) {
    my $val;
    s/\s*=\s*(.*)/=/; # separate key (in $_) and value (in $1), dropping whitespace around =
    $val = $1;
    $val =~ s/([^A-Za-z0-9._-])/sprintf("%%%02X", ord($1))/seg; #URL-encode value
    $_ .= $val;
    }
    $a_body .= $_.'&' if length > 0;
}
close F;
$a_body .='gnkey=0b82';

# add an extra byte to make the body even (bytewise)
$a_body .= "\0" if ((length($a_body) % 2) ne 0);

# add an extra word ( = two bytes) to make the body even (wordwise)
$a_body .= "\0\0" if ((length($a_body) % 4) ne 0);

# generate a d_length (length of the complete message, counting words, in dec)
# ( header is always 8 words lang ) + ( body in ascii (bytes) / 2 = in words )
my $d_length = 8 + (length($a_body)/2);

# make that a binary dword
my $b_length = pack("N", $d_length);

# generate a checksum
my $d_checksum;
foreach ($b_length,$b_mac,$b_crlf,$b_crlf,$a_body) {
        $d_checksum += unpack("%16n*", $_);
}
#$d_checksum %= 65536;

$d_checksum = 65536-$d_checksum;

# and make a binary word of that
my $b_checksum = pack("n", $d_checksum);

# and write the config back to disk, in a grandstream readable format
open F,">$f_out";
binmode F;
print F $b_length;
print F $b_checksum;
print F $b_mac;
print F $b_crlf;
print F $b_crlf;
print F $a_body;
close F;
Into the file: paloSantoFileEndPoint.class.php, put this line:

Code:
exec("/tftpboot/GS_CFG_GEN/bin/encode {$ArrayData['data']['filename']} /tftpboot/gxp{$ArrayData['data']['filename']}.cfg /tftpboot/cfg{$ArrayData['data']['filename']}",$arrConsole,$flagStatus);
instead of:
Code:
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);
You must change some parameters into the file Grandstream.cfg.php!
Every P8 = 0 instead of P8 = 1.
The logic Granstream: 1 = disable, and 0 is enable for the DHCP. :silly:
So enable the DHCP.

Now, with these modifications, you can make some provisioning for your Grandstream phones. You must have 1 template file, (N) gxp000b8203ce2b.cfg, (N) cfg000b8203ce2b file. (N) is: one for one.

Regards
 

aig79

Joined
Feb 23, 2010
Messages
2
Likes
0
Points
0
#3
I just posted this to the bug report. And will but this here, since this is how I found the bug report.

There are no files at /usr/local/src/GS_CFG_GEN.
The location of GAPSLITE_HOME should be /tftpboot/GS_CFG_GEN because this is where Elastix installs this program.
I also linked the directory in /tftpboot/GS_CFG_GEN/lib/ from x86_64 (the output of `uname -m` to i86pc.
I also removed the .cfg from the gxpXXXXXXXXXXXX at the end of the line in paloSantoFileEndPoint.class.php.

If those three things do not resolve I do not know if the Grandstream phones will be able to use the configuration file, or if the file is correctly formated.

As for as the configuration of your own phones the Grandsteam.cfg.php file should be changed for your environment. I would like to be able to automate this process through a web page in the "Endpoint Manager". I only have one kind of Grandstream phone and I modified the file to get my phones set up.

I don't have the original source, and can't find where to get the right files, to send a diff.

Andrew Greene
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#4
It seems that each model of phone are the same fomat for the common config.
Like that, just add every model into the databasel as GXP3000, BT20x, ..etc
It's true, into the database, there's only 2 models.
 

aig79

Joined
Feb 23, 2010
Messages
2
Likes
0
Points
0
#5
I was not only thinking of different models of Grandstream phones. But if I did have different models it would help differentiate between phones if they where labeled as such. I agree as far as the configuration each device would only receive the settings that it is capable of, for model and firmware.

I was thinking of global config settings across different manufactures. Currently there are separate config files for each manufacture. Each file would need to be edited manually to customize the configuration for your environment. If you would prefer different options than the default or add additional options to each config file.

Andrew Greene
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#6
I agree with you, but I looked two or three model and every parameters seems the same.
I not said that all parameters are common.
The two models from Elastix (into the original database) and my two model (BT20x & GXP3140). So, total = 4 models.
But yes of course, maybe separate every models for a better provisioning (not very easy, but not impossible). You are right.
 

razametal

Joined
Jul 9, 2007
Messages
33
Likes
0
Points
0
#7
I'm using GXP280 and works selecting the model GXP 2000 or GXP 2020.

I've updated it with the firmware 1.2.26.
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#8
If you look at the file GransdStream.php there's only one model.
So you could select anything model, and that should be always the same parameters.
 

razametal

Joined
Jul 9, 2007
Messages
33
Likes
0
Points
0
#9
Yes, the settings of the firmware are fine for the following models:

GXP2000/GXP2020/GXP1200/GXP2010/GXP280 firmware version 1.2.2.26

This is the content of my GrandStream.php file for my 71 GXP280 phones, the /tftpboot path contains the latest firmaware files, the language file and one custom ringtone called ring1.bin:
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 = $secret

# 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 = 1

# 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

# 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

# Ringtone 1
P105 = ring1.bin

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

# 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

# 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";

    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;
}
?>
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#10
It's right;

Now , the good idea should be to get every language, and tones parameters, ..etc. to include it into the config file.
I'll try if have enough of time.

For the language, I think that there's no problem.
For every tones, maybe use the indications.conf file.

GS config:
  • # Dial Tone
    P343 = f1=425,f2=425;
    P348 = f1=425,f2=425,c=33/33;

indications.conf:
  • dial = 440
    busy = 440/500,0/500
..etc
 

razametal

Joined
Jul 9, 2007
Messages
33
Likes
0
Points
0
#11
The dial tone and busy tones of the file are for Ecuador PSTN.
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#12
Ok. :)
 

Members online

Latest posts

Forum statistics

Threads
30,898
Messages
130,879
Members
17,560
Latest member
manuelc
Top