How-to Read / Set Gain from SkyView and Gmap

Jessie%20and%20Stretch%20Mutab

For Raspbian Jessie/Stretch + dump1090-mutability v1.15~dev install

Only Step-1 is different for Jessie and Stretch, rest is same.

STEP-1 (JESSIE): Install necessary php packages and enable module

sudo apt-get update   
sudo apt-get install php5-cgi   
sudo lighty-enable-mod fastcgi-php   
sudo /etc/init.d/lighttpd force-reload   

.

STEP-1 (STRETCH): Install necessary php packages and enable module

sudo apt-get update   
sudo apt-get install php7.0-cgi   
sudo lighty-enable-mod fastcgi-php   
sudo /etc/init.d/lighttpd force-reload   

STEP-2: Set up existing user www-data

2.1 - Assign strong password to existing user www-data, and add it to sudoer’s group

sudo passwd www-data   
sudo adduser www-data sudo   
groups www-data   
  

2.2 - REBOOT for sudo permission of user www-data to be implemented.

sudo reboot

.

STEP-3: Create new directory and files

3.1 - Create new directory

sudo mkdir /var/www/html/setgain   

.
3.2 - Move inside the new directory

cd /var/www/html/setgain/   

.
3.3 - Inside directory /var/www/html/setgain, create a new blank file setgain.sh, make it executable

sudo touch setgain.sh   
sudo chmod +x setgain.sh   

.
3.4 - Open newly created file in nano editor

sudo nano setgain.sh   

.
3.5 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

#!/bin/bash   
echo 'xxxxxxxxxx' | sudo -S sed -i '/GAIN=.*/c\GAIN='$1 /etc/default/dump1090-mutability  

echo 'xxxxxxxxxx' | sudo -S systemctl restart dump1090-mutability  

Save (Ctrl+o) and Close (Ctrl+x) the file.

.
3.6 - Inside directory /var/www/html/setgain, create a new blank file findgain.sh, make it executable

sudo touch findgain.sh   
sudo chmod +x findgain.sh   

.
3.7 - Open newly created file in nano editor

sudo nano findgain.sh   

.
3.8 - Add code to the new file
(In code below, replace xxxxxxxxx by the actual password you have set for user www-data)

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

#!/bin/bash
echo 'xxxxxxxxxx' | sudo -S sed -n 's/\GAIN=//p' /etc/default/dump1090-mutability  

Save (Ctrl+o) and Close (Ctrl+x) the file.

.

STEP-4

4.1 - Create a new file gain.php in folder /usr/share/dump1090-mutability/html

cd /usr/share/dump1090-mutability/html/
sudo nano gain.php   

.
4.2 - Copy-paste following code in newly created blank file gain.php

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

<html>
 <form id="myform" action="gain.php" method="post" />
  <input type="text" name="gain" id="gain" maxlength="5" size="4" value="<?php system('/var/www/html/setgain/findgain.sh');?>" />
  <input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
 </form>
</html>

<?php
function setgain(){
$gain="{$_POST['gain']}";
system("/var/www/html/setgain/setgain.sh $gain  >> /tmp/gain.log 2>&1");
header("Refresh:0");
}

if ("{$_POST['gain']}"){
setgain();
}
?>


Save (Ctrl+o) and Close (Ctrl+x)

STEP-5

5.1 - Next step is to edit file gmap.html in folder `/usr/share/dump1090-mutability/html.
BEFORE EDITING, make its backup copy. This will enable you to revert in case something goes wrong.

cd /usr/share/dump1090-mutability/html/
sudo cp gmap.html gmap.bak.html

#Check to ensure back-up copy has been created by giving ls command

ls

#The output should contain both gmap.html and gmap.bak.html

config.js    formatter.js   markers.js        style.css
coolclock    gain.php       ol3               test
db           gmap.bak.html  planeObject.js    upintheair.json
dbloader.js  gmap.html      registrations.js
flags.js     jquery         script.js
flags-tiny   layers.js      spinny.gif

.
5.2 - Open the file gmap.html for editing

cd /usr/share/dump1090-mutability/html/  
sudo nano gmap.html  

.
5.3 - Press Ctrl+w then type sudo_buttons then press Enter key.
The cursor will jump to line <div id="sudo_buttons">, as shown below

                                </div> <!-- timestamps -->

                                <div id="sudo_buttons">
                                        <table style="width: 100%">
                                                <tr>
                                                        <td style="width: 150px; text-align: center;" class="pointer">
                                                                [ <span onclick="resetMap();">Reset Map</span> ]
                                                        </td>
                                                </tr>
                                        </table>

                                </div> <!-- sudo_buttons -->

.
5.4 - Just above line <div id="sudo_buttons">, insert following 3 lines

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   

.

After insertion of 3 lines, the code will be like shown below:

                                </div> <!-- timestamps -->

<div id="GAIN" style="text-align:center;width:175px;height:65px;">   
<iframe src=gain.php style="border:0;width:175px;height:65px;"></iframe>   
</div> <!----- GAIN --->   


                                <div id="sudo_buttons">
                                        <table style="width: 100%">
                                                <tr>
                                                        <td style="width: 150px; text-align: center;" class="pointer">
                                                                [ <span onclick="resetMap();">Reset Map</span> ]
                                                        </td>
                                                </tr>
                                        </table>

                                </div> <!-- sudo_buttons -->

Save (Ctrl+o) and Close (Ctrl+x)
.

5.5 - Go to page IP-of-PI/dump1090/ and check gain setting add-on appears as shown in screenshot below.

The value shown at browser load or re-load is your current gain value.

If you want to change it, replace the value displayed by value desired and click “Set Gain” button. The value in gain box will briefly show your previous setting, then show your current (changed) setting.

Check the gain value by following command.

sudo systemctl status dump1090-mutability -l    

.
Following line of output of this command will show the actual value of gain used.

NOTE: Some of code lines are very long. Scroll Right to see these in full
.

CGroup: /system.slice/dump1090-mutability.service
           └─6531 /usr/bin/dump1090-mutability --net --gain 36 --ppm 0 --fix --lat xx.xx --lon yy.yy --max-range 300 --net-ri-port 30001

4 Likes