📜 ⬆️ ⬇️

Auto provisioning for grandstream or take out and put the soul into the GXP1165

image
Until recently, we used Fanvil products as VoIP devices. And in general, everyone was happy. There is a management from a single point, the quality of communication 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 it 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 Fanvil. It has all the necessary functions and has a more intuitive notation on the buttons and ports of connection. In addition, for some time, one of the decisive factors when choosing an IP phone for me is the function of auto provisioning. This grandstream model promised it. This will be further discussed.

My experience with auto provisioning was based on the Chinese products already mentioned. And I naively thought that with Grandstream everything would look about the same. In general, it happened. But I did not expect how much everything will turn out. In order not to be unsubstantiated, I will bring two pieces of settings from one and another device. Settings are obtained by exporting a 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 

BUT! How do you ?! Impressed? In truth, I deceived you a little. The working configuration of the phone looks different. But then you can imagine my confusion when I saw the configuration I downloaded from the device.
Immediately visible are the pros and cons of one and the other fellow. The Chinese have made settings more close to human understanding. But Americans gaining a good amount of documentation. In the end, it helped me.
You can create a configuration file for grandstream in two ways. With the help of utilities on the manufacturer's website (there are tools for Windows and for Linux) and manually, via an XML file. With the first method I did not work out. Therefore, I will describe the second.
As you already understood, the names of the configuration fields are encrypted and finding their description is not that difficult, but I had to surf the Internet. Something took here , something here and in general it turned out such a file.
 <?xml version="1.0" encoding="UTF-8" ?> <gs_provision version="1"> <mac>000a91547c9c</mac> <config version="1"> <!-- Admin Password --> <P2>PasswordQWER</P2> <P3>Grandstream</P3> <!-- SIP Registration. 0-no,1-yes --> <P31>1</P31> <!-- Register Expiration (in minutes. default 1 hour, max 45 days) --> <P32>60</P32> <!-- Authenticate password --> <P34>SIPassword</P34> <!-- SIP User ID --> <P35>111</P35> <!-- Authenticate ID --> <P36>111</P36> <P40>5561</P40> <!-- SIP Server --> <P47>sip.address.ru:5561</P47> <!-- DNS Mode. 0-A Record, 1-SRV, 2-NAPTR/SRV, 3-Use Configured IP --> <P103>0</P103> <!-- Time Format 0-12, 1-24 --> <P122>1</P122> <P148>Grandstream Provisioning</P148> <P237>config.address.ru</P237> <!-- Account Name. Cannot be empty. --> <P270>TestConfig</P270> <!-- Account 1 --> <!-- Account Active (In Use). 0-no, 1-yes --> <P271>1</P271> <!-- Enable Phonebook. 0(Disabled)/1(HTTP)/2(TFTP)/3(HTTPS) --> <P330>1</P330> <!-- Phone Book XML Server Path --> <P331>config.address.ru</P331> <!-- Phone Book Download Interval (in minutes) --> <P332>5</P332> <!-- Remove Manually-edited entries on Download. Possible values: 0(No)/1(Yes) --> <P333>1</P333> <!-- XML FILE ENCRYPTION --> <P1349>password123</P1349> <P1362>ru</P1362> <!-- Degree Unit. auto - Automatic, f - Fahrenheit, c - Celsius. Default is auto --> <P1379>c</P1379> </config> </gs_provision> 

This config allows you to register the device on a SIP server running on a non-standard port 5561. Also included are minor features like weather display in Celsius and settings for the path to the address book. 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 of the form cfg [macaddress] .xml. We will distribute the file via HTTP, so we simply post it in / var / www / (Installing apache as apt-get install apache2, sorry, I will not describe :))
Further, by analogy with Fanvil-s, we automate this process.
Create a users file with the following contents:
 000a91547c9c 111 SIPassword User Grand 
Please note mac address should be written in small letters.

... and 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 <<EOF >>$dfile <?xml version="1.0" encoding="UTF-8" ?> <gs_provision version="1"> <mac>${usfile[$a]}</mac> <config version="1"> <!-- Admin Password --> <P2>PasswordQWER</P2> <P3>DisplayTest</P3> <!-- SIP Registration. 0 - no, 1 - yes --> <P31>1</P31> <!-- Register Expiration (in minutes. default 1 hour, max 45 days) --> <P32>60</P32> <!-- Authenticate password --> <P34>${usfile[$c]}</P34> <!-- SIP User ID --> <P35>${usfile[$b]}</P35> <!-- Authenticate ID --> <P36>${usfile[$b]}</P36> <P40>5561</P40> <!-- SIP Server --> <P47>sip.server.ru:5561</P47> <!-- DNS Mode. 0 - A Record, 1 - SRV, 2 - NAPTR/SRV, 3 - Use Configured IP. Default is 0 --> <P103>0</P103> <!-- Time Format --> <P122>1</P122> <P148>Grandstream Provisioning</P148> <!-- HTTP Firmware Update Server --> <P192>config.server.ru</P192> <P237>config.server.ru</P237> <!-- Account Name. Cannot be empty. --> <P270>${usfile[$d]} ${usfile[$e]}</P270> <!-- Account 1 --> <!-- Account Active (In Use). 0 - no, 1 - yes --> <P271>1</P271> <!-- Enable Phonebook0(Disabled)/1(HTTP)/2(TFTP)/3(HTTPS) --> <P330>1</P330> <!-- Phone Book XML Server Path --> <P331>sip.server.ru</P331> <!-- Phone Book Download Interval (in minutes) --> <P332>60</P332> <!-- Remove Manually-edited entries on Download. Possible values: 0 (No) / 1 (Yes) --> <P333>1</P333> <!-- XML FILE ENCRYPTION --> <P1349>password</P1349> <P1362>ru</P1362> <!-- Update Interval.Default is 15 --> <P1378>60</P1378> <!-- Degree Unit. auto - Automatic, f - Fahrenheit, c - Celsius. Default is auto --> <P1379>c</P1379> </config> </gs_provision> 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 

Everything. 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 set the path to the configuration server and password to decrypt the config file.

image
At the bottom, press the "Save and apply" button and send it to the reboot using the "Restart" 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 I, without hesitation, zababahal a 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 exactly with 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 | sed s'/;//'g >> tmp.file spisok=(`cat tmp.file`) echo '<?xml version="1.0" encoding="UTF-8"?>' >> $book echo "<AddressBook>" >> $book while [ ${spisok[a]} ];do cat <<EOF >>$book <Contact> <LastName>${spisok[a]}</LastName> <FirstName>${spisok[b]}</FirstName> <Phone> <phonenumber>${spisok[c]}</phonenumber> <accountindex>1</accountindex> <downloaded>0</downloaded> </Phone> <Groups> <groupid>2</groupid> </Groups> </Contact> EOF a=`expr $a + 3` b=`expr $b + 3` c=`expr $c + 3` done echo "</AddressBook>" >>$book cp phonebook.xml /var/www/ rm tmp.file 

If the path to the address book is registered correctly, then after the reboot the directory will be pulled up on the device. You can verify this by pressing the button with the phone book on the phone case or in the settings via the web interface.
')
image

But that 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 those ugly ones. But! Ringtones can pour their own!
A method for Linux is described. Wilita for Windows 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 

Read the readme.
./sox sound.wav ring1.ring
It's simple. At the entrance to the wav file at the output ring1.ring. Files can be no more than three - ring1.ring, ring2.ring and ring3.ring respectively. Size no more than 100 Kb, the authors themselves recommend no more than 70 Kb for each file. The resulting ring-s need to change the extension to .bin and fill for example the same place where the config files are.
To fill ringtones in the config file is a field . . . .
Everything. We start up the phone in reboot and use the command tail -f /var/log/apache/access.log 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" 

Source: https://habr.com/ru/post/200982/


All Articles