Merge pull request #2 from Schrolli91/develop

merge for new release
This commit is contained in:
Schrolli91 2015-04-04 19:24:51 +02:00
commit 37e26e9f72
10 changed files with 230 additions and 122 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.psd

View file

@ -1,33 +1,35 @@
# BOSWatch
Python Script to Recive and Decode German BOS Information with rtl_fm ans multimon-NG
![# BOSWatch](/www/gfx/logo.png)
Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG
**Please** only use Code from **master-Branch** - thats the only stable!
### Features
#####Implementeted Features:
#####Implemented Features:
- FMS and ZVEI decoding and Displaying
- Filtering double alarms with adjustable time
- FMS and ZVEI validation (plausibility test)
- MySQL Database Support for FMS and ZVEI
- All configurations in seperate File "config.ini"
- simple Web Frontend
- simple Web Frontend with Data Parsing
#####Features for the Future:
- extensive filtering options
- POCSAG 512,1200,2400 support
- POCSAG 512,1200,2400 support (need RAW data from multimon-ng)
- automatic Audio recording at alarm
- Web Frontend with configuration
- Web Frontend with Overview and configuration
### Configuration
##### boswatch.py
You can set the ignore time for double alarms in seconds.
To use the script with MySQL Support, you must edit the "config.ini".
Now set "useMySQL = 1" and the Userdata to your local MySQL Database.
The configuration for the Script you can find in config.ini
- You can set the ignore time for double alarms in seconds.
- To use the script with MySQL Support set "useMySQL = 1" and the Userdata to your local MySQL Database.
For the other Functions see "Usage" below.
##### Web Frontend
Put the Files in Folder /wwww/ into your local Webserver Folder (/var/www/).
Now you must edit the "config.php" with your Userdata to yout local Database.
Now you must edit the "config.php" with your Userdata to your local Database.
### Usage
`sudo python boswatch.py -f 85.235M -a FMS ZVEI -s 50`
@ -61,5 +63,24 @@ optional arguments:
More Options you can find in the extern config.ini File in this Folder
```
### Installation
You can easy install BOSWatch with the install.sh Script.
- Download the install.sh in any Folder you want.
- Make it executeable `sudo chmod +x install.sh`
- And use the script `sudo sh install.sh`
Now the script downloads and compile all needed data.
At the end you can find the Programm in `/home/pi/bos/BOSWatch`
### Requirements
- RTL_SDR (rtl_fm)
- Multimon-NG
- MySQL Connector for Python
##### optional
- Webserver with PHP
- MySQL Database Server
Thanks to smith_fms and McBo from [Funkmeldesystem.de - Forum](http://www.funkmeldesystem.de/) for Inspiration and Groundwork!
Greetz Schrolli
######Greetz Schrolli

View file

@ -3,7 +3,8 @@
##### Info #####
# BOSWatch
# Python Script to Recive and Decode BOS Information with rtl_fm and multimon-NG
# Autor: Bastian Schroll
# Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG
# For more Information see the README.md
##### Info #####
@ -40,7 +41,7 @@ def stop_script(err):
#With -h or --help you get the Args help
#ArgsParser
parser = argparse.ArgumentParser(prog="boswatch.py", description="BOSWatch is a Python Script to Recive and Decode German BOS Information with rtl_fm ans multimon-NG", epilog="More Options you can find in the extern config.ini File in this Folder")
parser = argparse.ArgumentParser(prog="boswatch.py", description="BOSWatch is a Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG", epilog="More Options you can find in the extern config.ini File in this Folder")
#parser.add_argument("-c", "--channel", help="BOS Channel you want to listen")
parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True)
parser.add_argument("-d", "--device", help="Device you want to use (Check with rtl_test)", type=int, default=0)
@ -50,13 +51,20 @@ parser.add_argument("-s", "--squelch", help="Level of Squelch", type=int, defaul
parser.add_argument("-v", "--verbose", help="Shows more Information", action="store_true")
args = parser.parse_args()
#Read Data from Args, Put it into working Variables and Display them
print("#########################")
print("# #")
print("# BOSWatch beta #")
print("# #")
print("#########################")
print(" ____ ____ ______ __ __ __ ")
print(" / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ b")
print(" / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ e")
print(" / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / t")
print(" /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ a")
print(" German BOS Information Script ")
print(" by Bastian Schroll ")
print("")
freq = args.freq
@ -107,7 +115,7 @@ try:
zvei_double_ignore_time = int(config.get("ZVEI", "double_ignore_time"))
#MySQL config
useMySQL = int(config.get("MySQL", "useMySQL")) #use MySQL support?
useMySQL = int(config.get("Module", "useMySQL")) #use MySQL support?
if useMySQL: #only if MySQL is active
dbserver = config.get("MySQL", "dbserver")
dbuser = config.get("MySQL", "dbuser")
@ -194,7 +202,7 @@ try:
if "CRC correct" in decoded: #check CRC is correct
fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction #build FMS id
if re.search("[0-9]{8}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid
if re.search("[0-9a-f]{2}[0-9]{6}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid
if fms_id == fms_id_old and timestamp < fms_time_old + fms_double_ignore_time: #check for double alarm
if args.verbose: print "FMS double alarm: "+fms_id_old
fms_time_old = timestamp #in case of double alarm, fms_double_ignore_time set new

View file

@ -2,23 +2,27 @@
# BOSWatch Config File #
########################
#Data for MySQL connection
#useMySQL = (0|1)
[MySQL]
useMySQL = 0
dbserver = localhost
dbuser = root
dbpassword = root
database = boswatch
tableFMS = bos_fms
tableZVEI = bos_zvei
tablePOC = bos_pocsag
[FMS]
#time to ignore same alarm in a row in seconds
double_ignore_time = 10
[ZVEI]
#time to ignore same alarm in a row in seconds
double_ignore_time = 5
double_ignore_time = 5
#can take on or off the modules (0|1)
[Module]
useMySQL = 0
#useAudiorecord = 0
#useHTTPrequest = 0
#Data for MySQL connection
[MySQL]
dbserver = localhost
dbuser = root
dbpassword = root
database = boswatch
tableFMS = bos_fms
tableZVEI = bos_zvei
tablePOC = bos_pocsag

69
install.sh Normal file
View file

@ -0,0 +1,69 @@
#!/bin/sh
clear
echo ""
echo " ##########################"
echo " # #"
echo " # BOSWatch Installer #"
echo " # #"
echo " ##########################"
echo ""
echo "This may take a several minutes... Don't panic!"
echo ""
echo "Caution, script don't installed a Webserver with PHP and MySQL"
echo "So you have to make up manually if you want to use MySQL support"
echo ""
mkdir -p /home/pi/bos/install
echo "[ 1/10] [#---------] make a apt-get update..."
apt-get update > /home/pi/bos/install/setup_log.txt 2>&1
echo "[ 2/10] [##--------] download GIT an other stuff..."
apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake libpulse-dev libx11-dev sox >> /home/pi/bos/install/setup_log.txt 2>&1
echo "[ 3/10] [###-------] download rtl_fm..."
cd /home/pi/bos/install
git clone git://git.osmocom.org/rtl-sdr.git >> /home/pi/bos/install/setup_log.txt 2>&1
cd rtl-sdr/
echo "[ 4/10] [####------] compile rtl_fm..."
mkdir -p build && cd build
cmake ../ -DINSTALL_UDEV_RULES=ON >> /home/pi/bos/install/setup_log.txt 2>&1
make >> /home/pi/bos/install/setup_log.txt 2>&1
make install >> /home/pi/bos/install/setup_log.txt 2>&1
ldconfig >> /home/pi/bos/install/setup_log.txt 2>&1
echo "[ 5/10] [#####-----] download multimon-ng..."
cd /home/pi/bos/install
git clone https://github.com/EliasOenal/multimonNG.git >> /home/pi/bos/install/setup_log.txt 2>&1
cd multimonNG/
echo "[ 6/10] [######----] compile multimon-ng..."
mkdir -p build
cd build
qmake ../multimon-ng.pro >> /home/pi/bos/install/setup_log.txt 2>&1
make >> /home/pi/bos/install/setup_log.txt 2>&1
make install >> /home/pi/bos/install/setup_log.txt 2>&1
echo "[ 7/10] [#######---] download MySQL Connector for Python..."
cd /home/pi/bos/install
wget "http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.9.tar.gz/from/http://cdn.mysql.com/" -O mysql-connector.tar >> /home/pi/bos/install/setup_log.txt 2>&1
tar xfv mysql-connector.tar >> /home/pi/bos/install/setup_log.txt 2>&1
cd mysql-connector-python*
echo "[ 8/10] [########--] install MySQL Connector for Python..."
chmod +x ./setup.py
./setup.py install >> /home/pi/bos/install/setup_log.txt 2>&1
echo "[ 9/10] [#########-] download BOSWatch..."
cd /home/pi/bos
git clone https://github.com/Schrolli91/BOSWatch >> /home/pi/bos/install/setup_log.txt 2>&1
echo "[10/10] [##########] configure..."
cd BOSWatch
chmod +x *
echo "# blacklist the DVB drivers to avoid conflict with the SDR driver\n blacklist dvb_usb_rtl28xxu \n blacklist rtl2830\n blacklist dvb_usb_v2\n blacklist dvb_core" >> /etc/modprobe.d/boswatch_blacklist_sdr.conf
echo ""
echo "BOSWatch are now in /home/pi/bos/BOSWatch/"
echo "Install ready!"

View file

@ -1,72 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 3.4.11.1deb2+deb7u1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 03. Apr 2015 um 11:16
-- Server Version: 5.5.41
-- PHP-Version: 5.4.39-0+deb7u1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Datenbank: `raspoc`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `ras_fms_hist`
--
CREATE TABLE IF NOT EXISTS `ras_fms_hist` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`time` datetime NOT NULL,
`service` varchar(1) NOT NULL,
`country` varchar(2) NOT NULL,
`location` varchar(2) NOT NULL,
`vehicle` varchar(4) NOT NULL,
`status` varchar(1) NOT NULL,
`direction` varchar(1) NOT NULL,
`tsi` varchar(3) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `ras_pocsag_hist`
--
CREATE TABLE IF NOT EXISTS `ras_pocsag_hist` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`time` datetime NOT NULL,
`ric` varchar(7) NOT NULL DEFAULT '0',
`funktion` int(1) NOT NULL,
`text` text NOT NULL,
KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `ras_zvei_hist`
--
CREATE TABLE IF NOT EXISTS `ras_zvei_hist` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`time` datetime NOT NULL,
`zvei` varchar(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View file

@ -2,7 +2,7 @@
$dbhost = "localhost";
$dbuser = "root";
$dbpassword = "root";
$dbpassword = "";
$database = "boswatch";
$tableFMS = "bos_fms";

BIN
www/gfx/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
require_once ("config.php");
require_once ("parser.php");
$db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database);
?>
@ -9,34 +9,39 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database);
<html>
<head>
<title>BOSWatch</title>
<link rel="stylesheet" type="text/css" href="tooltip.css">
</head>
<body>
<div style="text-align: center; width: 1050px; margin: 0px auto;">
<div style="text-align: center; width: 1250px; margin: 0px auto;">
<h1>BOSWatch</h1>
<img src="gfx/logo.png" alt="BOSWatch"><br>
Last alarms for FMS and ZVEI (max. 50)<br><br>
<div style="float: left; width: 600px;">
<div style="float: left; width: 800px;">
<b>Last FMS alarms</b>
<?php
$sql = "SELECT id, time, service, country, location, vehicle, status, direction, tsi FROM ".$tableFMS." ORDER BY id DESC LIMIT 50";
$db_erg = mysqli_query( $db_link, $sql );
echo '<table border="1" style="width: 600px;">';
echo '<table border="1" style="width: 800px;">';
while ($data = mysqli_fetch_array( $db_erg, MYSQL_ASSOC))
{
$time = strtotime($data['time']);
$time = date("d.m.Y H:i:s", $time);
$fms_id = $data['service'].$data['country'].$data['location'].$data['vehicle'].$data['status'].$data['direction'];
echo "<tr>";
echo "<td>". $data['id'] . "</td>";
echo "<td>". $data['time'] . "</td>";
echo "<td>". $data['service'] . "</td>";
echo "<td>". $data['country'] . "</td>";
echo "<td>". $time . "</td>";
echo "<td>". parse("service",$fms_id) . "</td>";
echo "<td>". parse("country",$fms_id) . "</td>";
echo "<td>". $data['location'] . "</td>";
echo "<td>". $data['vehicle'] . "</td>";
echo "<td>". $data['status'] . "</td>";
echo "<td>". $data['direction'] . "</td>";
echo "<td>". parse("direction",$fms_id) . "</td>";
echo "<td>". $data['tsi'] . "</td>";
echo "</tr>";
}
@ -49,14 +54,17 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database);
<?php
$sql = "SELECT id, time, zvei FROM ".$tableZVEI." ORDER BY id DESC LIMIT 50";
$db_erg = mysqli_query( $db_link, $sql );
echo '<table border="1" style="width: 400px;">';
while ($data = mysqli_fetch_array( $db_erg, MYSQL_ASSOC))
{
echo "<tr>";
$time = strtotime($data['time']);
$time = date("d.m.Y H:i:s", $time);
echo "<tr>";
echo "<td>". $data['id'] . "</td>";
echo "<td>". $data['time'] . "</td>";
echo "<td>". $time . "</td>";
echo "<td>". $data['zvei'] . "</td>";
echo "</tr>";
}

69
www/parser.php Normal file
View file

@ -0,0 +1,69 @@
<?php
//Data from TRBOS-FMS http://www.lfs-bw.de/Fachthemen/Digitalfunk-Funk/Documents/Pruefstelle/TRBOS-FMS.pdf
function parse($mode, $fms)
{
//Data for Service Parsing
$service = array(
"0" => "Unbekannt",
"1" => "Polizei",
"2" => "Bundesgrenzschutz",
"3" => "Bundeskriminalamt",
"4" => "Katastrophenschutz",
"5" => "Zoll",
"6" => "Feuerwehr",
"7" => "Technisches Hilfswerk",
"8" => "Arbeiter-Samariter-Bund",
"9" => "Deutsches Rotes Kreuz",
"a" => "Johanniter-Unfall-Hilfe",
"b" => "Malteser-Hilfsdienst",
"c" => "Deutsche Lebensrettungsgesellschaft",
"d" => "Rettungsdienst",
"e" => "Zivilschutz",
"f" => "Fernwirktelegramm",
);
//Data for Country Parsing
$country = array(
"0" => "Sachsen",
"1" => "Bund",
"2" => "Baden-Württemberg",
"3" => "Bayern I",
"4" => "Berlin",
"5" => "Bremen",
"6" => "Hamburg",
"7" => "Hessen",
"8" => "Niedersachsen",
"9" => "Nordrhein-Westfalen",
"a" => "Rheinland-Pflaz",
"b" => "Schleswig-Holstein",
"c" => "Saarland",
"d" => "Bayern II",
"e" => "Meck-Pom/Sachsen-Anhalt",
"f" => "Brandenburg/Thüringen",
);
switch ($mode) {
case "service":
return $service[substr($fms,0,1)];
break;
case "country":
return $country[substr($fms,1,1)];
break;
case "direction":
if(substr($fms,9,1) == 1){
return "L->F";
}elseif(substr($fms,9,1) == 0){
return "F->L";
}
break;
default:
return "Parser: mode error!";
}
}
?>