Auto provisioning for grandstream or take out and put our soul into the GXP1165
Until recently, we used Fanvil products as VoIP devices. And in general, everyone was happy. There is control from a single point, the communication quality is satisfactory, but there was a feeling of some kind of incompleteness or even understatement (understand how you want :))) In general, the search for the “ideal phone” in the background, but continued all the time. And then Grandstream GXP1165 fell into my hands. Having a more eminent manufacturer, this model is in the same price category as the Chinese Fanvils. It has all the necessary functions and has a more intuitive designation on the buttons and connection ports. In addition, for some time now, one of the decisive factors when choosing an IP phone for me is the auto provisioning function. This grandstream model promised him. This will be discussed further.
My experience with auto provisioning was based on the Chinese products already mentioned. And I naively thought that with Grandstream everything would look something like this. In general, it happened. But I did not expect how much everything would turn out. In order not to be unfounded I will bring two pieces of settings from one and the other device. Settings are obtained by exporting the file.
Fanvil:
Static IP :192.168.1.179
Static NetMask :255.255.255.0
Static GateWay :192.168.1.1
Default Protocol :2
Primary DNS :202.96.134.133
Alter DNS :202.96.128.68
DHCP Mode :1
DHCP Dns :1
Domain Name :
Host Name :VOIP
Pppoe Mode :0
HTL Start Port :10000
HTL Port Number :200
SNTP Server :209.81.9.7
Now hold on. A piece of settings from the grandstream config :
P335=2
P90=0
P91=0
P212=1
P92=0
P93=0
P338=0
P1339=0
P94=0
P2340=0
P95=0
P2341=0
P2342=0
P96=97
P2343=0
P97=1
P99=0
P10=168
P11=0
P2346=0
P2347=0
P12=160
P13=255
P2348=0
P14=255
A! How do you like that ?! Are you impressed? In truth, I deceived you a little. The phone’s working config looks different. But then you can imagine my confusion when I saw the configuration that I downloaded from the device.
The pros and cons of one and the other fellow are immediately visible. The Chinese made the settings more close to human understanding. But the Americans help out a good amount of documentation. In the end, it helped me out.
There are two ways to create a configuration file for grandstream. Using utilities on the manufacturer’s website (there are tools for Windows and Linux) and manually, through an XML file. The first method did not work out for me. Therefore, I will describe the second.
As you already understood, the names of the configuration fields are encrypted and it is not so difficult to find their description, but I had to dig the Internet. I took something here , something here and as a whole I got such a file.
000a91547c9c PasswordQWER Grandstream 1 60 SIPassword 111 111 5561 sip.address.ru:5561 0 1 Grandstream Provisioning config.address.ru TestConfig 1 1 config.address.ru 5 1 password123 ru c
This config allows you to register the device on a SIP server running on a non-standard port 5561. Minor features such as displaying weather in Celsius and setting the path to the address book are also included. Parameters that are not specified will be set by default.
The finished file must be encrypted.
openssl enc -e -aes-256-cbc -k password123 -in basefile.xml -out cfg000d91447b9b.xml
The file name should be cfg [macaddress] .xml. We will distribute the file via HTTP, so we just upload it to / var / www / (Installing apache as apt-get install apache2, sorry, I won’t describe :))
Next, by analogy with Fanvil, we will automate this process.
Create a users file with the following contents:
000a91547c9c 111 SIPassword User Grand
Please note the mac address must be written in small letters. ... and a bash file that will take settings from users
#!/bin/bash
uspath=/opt/neoflex/gxp1165
usfile=(`cat $uspath/users`)
macdir=/var/www/
a=0 #macaddrr
b=1 #number
c=2 #pass
d=3 #2name
e=4 #1name
while [ ${usfile[$a]} ]
do
dfile=$macdir'cfg'${usfile[$a]}
cat <>$dfile
${usfile[$a]} PasswordQWER DisplayTest 1 60 ${usfile[$c]} ${usfile[$b]} ${usfile[$b]} 5561 sip.server.ru:5561 0 1 Grandstream Provisioning config.server.ru config.server.ru ${usfile[$d]} ${usfile[$e]} 1 1 sip.server.ru 60 1 password ru 60 c
EOF
openssl enc -e -aes-256-cbc -k password -in $dfile -out $dfile.xml
rm $dfile
a=`expr $a + 5`
b=`expr $b + 5`
c=`expr $c + 5`
d=`expr $d + 5`
e=`expr $e + 5`
done
All. At the output of / var / www / we get the encrypted XML nickname cfg000a91547c9c.xml
In the settings of the device itself, it is enough to write the path to the configuration server and password to decrypt the config file.
At the bottom, click the "Save and Apply" button and send it to reboot with the "Reboot" button in the upper right corner of the screen.
But on this I did not calm down. In the process of digging in the documentation, I came across a description of the address book settings for the phone. And without hesitation, I started to boggle the script that generates phonebook.xml collecting it from sip configs.
Important! My callerid parameter looks like SecondName FirsName <111>. That is, all extensions must have a callerid field and with exactly three values.
#!/bin/bash
a=0
b=1
c=2
book=phonebook.xml
echo | sed -n '/callerid\=/p' /etc/asterisk/sip*.conf| sed s'/callerid\=//'g | sed s'///'g | sed s'/;//'g >> tmp.file
spisok=(`cat tmp.file`)
echo '' >> $book
echo "" >> $book
while [ ${spisok[a]} ];do
cat <>$book
${spisok[a]} ${spisok[b]} ${spisok[c]} 1 0 2
EOF
a=`expr $a + 3`
b=`expr $b + 3`
c=`expr $c + 3`
done
echo " " >>$book
cp phonebook.xml /var/www/
rm tmp.file
If the path to the address book is spelled correctly, then after the reboot the directory will be pulled up to the device. You can verify this by pressing the button with the phone book on the phone or in the settings via the web interface.
But this was not enough for me. So. The final chord.
Perhaps the only drawback of the device is the meager selection of ringtones. Only three and even some ugly ones. But! Ringtones you can upload your own!
The method for Linux is described. Windows utility is here .
Download and unpack the utility
wget http://www.grandstream.com/sites/default/files/Resources/linux_music_ring_tone_gen.zip
unzip linux_music_ring_tone_gen.zip
Rename sox.linux to just sox and assign rights
mv sox.linux sox
chmod 755 sox
We read readme.
./sox sound.wav ring1.ring
It's simple. At the input of wav, the file at the output of ring1.ring. Files can be no more than three - ring1.ring, ring2.ring and ring3.ring respectively. The size is no more than 100 Kb, the authors themselves recommend no more than 70Kb for each file. The resulting rings need to change the extension to .bin and fill in, for example, the same place where the config files are.
To fill ringtones in the config file, use the
. Оно описывает путь к файлам обновления.
All field . We put the phone into reboot and use the tail -f /var/log/apache/access.log command to see what happens. It will look something like this.
192.168.0.16 -- [05/Nov/2013:17:15:52 +0400] "GET /language.txt HTTP/1.1" 404 480 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:10 +0400] "GET /cfg000a91547c9c HTTP/1.0" 200 1787 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:14 +0400] "GET /cfg000a91547c9c.xml HTTP/1.0" 200 1849 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:32 +0400] "GET /gxp1160fw.bin HTTP/1.0" 404 537 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:36 +0400] "GET /gxp1160fw.bin HTTP/1.0" 404 537 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:38 +0400] "GET /ring1.bin HTTP/1.0" 200 65847 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:39 +0400] "GET /ring2.bin HTTP/1.0" 200 39388 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"
192.168.0.16 -- [05/Nov/2013:17:16:42 +0400] "GET /ring3.bin HTTP/1.0" 404 533 "-" "Grandstream Model HW GXP1165 SW 1.0.5.26 DevId 000a91547c9c"