diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac7b2b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.psd \ No newline at end of file diff --git a/README.md b/README.md index c82c505..813b208 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file + +######Greetz Schrolli diff --git a/boswatch.py b/boswatch.py index 91ccf77..824d95a 100644 --- a/boswatch.py +++ b/boswatch.py @@ -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 diff --git a/config.ini b/config.ini index 9cf5251..561ddf8 100644 --- a/config.ini +++ b/config.ini @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..ee392be --- /dev/null +++ b/install.sh @@ -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!" diff --git a/raspoc.sql b/raspoc.sql deleted file mode 100644 index a2d848d..0000000 --- a/raspoc.sql +++ /dev/null @@ -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 */; diff --git a/www/config.php b/www/config.php index f0b96e5..e78cee2 100644 --- a/www/config.php +++ b/www/config.php @@ -2,7 +2,7 @@ $dbhost = "localhost"; $dbuser = "root"; -$dbpassword = "root"; +$dbpassword = ""; $database = "boswatch"; $tableFMS = "bos_fms"; diff --git a/www/gfx/logo.png b/www/gfx/logo.png new file mode 100644 index 0000000..732f036 Binary files /dev/null and b/www/gfx/logo.png differ diff --git a/www/index.php b/www/index.php index 15a7573..b962b07 100644 --- a/www/index.php +++ b/www/index.php @@ -1,7 +1,7 @@ @@ -9,34 +9,39 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); BOSWatch + -
+
-

BOSWatch

+ BOSWatch
Last alarms for FMS and ZVEI (max. 50)

-
+
Last FMS alarms '; + echo ''; 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 ""; echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; } @@ -49,14 +54,17 @@ $db_link = mysqli_connect ($dbhost, $dbuser, $dbpassword, $database); '; while ($data = mysqli_fetch_array( $db_erg, MYSQL_ASSOC)) { - echo ""; + + $time = strtotime($data['time']); + $time = date("d.m.Y H:i:s", $time); + + echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; } diff --git a/www/parser.php b/www/parser.php new file mode 100644 index 0000000..e1242ad --- /dev/null +++ b/www/parser.php @@ -0,0 +1,69 @@ + "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!"; + } + } + +?> \ No newline at end of file
". $data['id'] . "". $data['time'] . "". $data['service'] . "". $data['country'] . "". $time . "". parse("service",$fms_id) . "". parse("country",$fms_id) . "". $data['location'] . "". $data['vehicle'] . "". $data['status'] . "". $data['direction'] . "". parse("direction",$fms_id) . "". $data['tsi'] . "
". $data['id'] . "". $data['time'] . "". $time . "". $data['zvei'] . "