From 9d73be593f035f18ad7be1898f5f4ad04cb0fbe4 Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Tue, 16 Feb 2021 01:09:04 +0100 Subject: [PATCH 01/21] implement basic mysql functionality --- boswatch/router/routerManager.py | 6 +- plugin/mysql.py | 175 +++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 plugin/mysql.py diff --git a/boswatch/router/routerManager.py b/boswatch/router/routerManager.py index cf26d5f..28a1788 100644 --- a/boswatch/router/routerManager.py +++ b/boswatch/router/routerManager.py @@ -28,6 +28,7 @@ logging.debug("- %s loaded", __name__) class RouterManager: """!Class to manage all routers""" + def __init__(self): """!Create new router""" self._routerDict = {} @@ -92,9 +93,8 @@ class RouterManager: logging.error("unknown type '%s' in %s", routeType, route) return False - # except ModuleNotFoundError: # only since Py3.6 - except ImportError: - logging.error("%s not found: %s", route.get("type"), route.get("res")) + except ModuleNotFoundError as e: + logging.error("%s not found: %s (%s)", route.get("type"), route.get("res"), str(e)) return False logging.debug("finished building routers") diff --git a/plugin/mysql.py b/plugin/mysql.py new file mode 100644 index 0000000..e4c153e --- /dev/null +++ b/plugin/mysql.py @@ -0,0 +1,175 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +"""! + ____ ____ ______ __ __ __ _____ + / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / + / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < + / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / +/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ + German BOS Information Script + by Bastian Schroll + +@file: mysql.py +@date: 15.02.2021 +@author: Jan Speller +@description: Mysql Plugin +""" +import logging +from plugin.pluginBase import PluginBase + +# ###################### # +# Custom plugin includes # +import mysql.connector +from datetime import datetime + +# ###################### # + +logging.debug("- %s loaded", __name__) + + +class BoswatchPlugin(PluginBase): + """!Description of the Plugin""" + + def __init__(self, config): + """!Do not change anything here!""" + super().__init__(__name__, config) # you can access the config class on 'self.config' + + def onLoad(self): + """!Called by import of the plugin + Remove if not implemented""" + self.connection = mysql.connector.connect( + host=self.config.get("host"), + user=self.config.get("user"), + password=self.config.get("password"), + database=self.config.get("database"), + ) + self.sqlInserts = { + "pocsag": "INSERT INTO boswatch (packetTimestamp, packetMode, pocsag_ric, pocsag_subric, pocsag_subricText, pocsag_message, pocsag_bitrate, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + "zvei": "INSERT INTO boswatch (packetTimestamp, packetMode, zvei_tone, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + "fms": "INSERT INTO boswatch (packetTimestamp, packetMode, fms_fms, fms_service, fms_country, fms_location, fms_vehicle, fms_status, fms_direction, fms_directionText, fms_tacticalInfo, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUE (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + "msg": "INSERT INTO boswatch (packetTimestamp, packetMode, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUE (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" + } + + def setup(self): + """!Called before alarm + Remove if not implemented""" + try: + self.connection.ping(reconnect=True, attempts=3, delay=2) + except mysql.connector.Error as err: + logging.warning("Connection was down, trying to reconnect...") + self.onLoad() + + self.cursor = self.connection.cursor() + + def fms(self, bwPacket): + """!Called on FMS alarm + + @param bwPacket: bwPacket instance + Remove if not implemented""" + val = ( + datetime.fromtimestamp(float(bwPacket.get("timestamp"))), + bwPacket.get("mode"), + bwPacket.get("fms"), + bwPacket.get("service"), + bwPacket.get("country"), + bwPacket.get("location"), + bwPacket.get("vehicle"), + bwPacket.get("status"), + bwPacket.get("direction"), + bwPacket.get("directionText"), + bwPacket.get("tacticalInfo"), + bwPacket.get("serverName"), + bwPacket.get("serverVersion"), + bwPacket.get("serverBuildDate"), + bwPacket.get("serverBranch"), + bwPacket.get("clientName"), + bwPacket.get("clientIP"), + bwPacket.get("clientVersion"), + bwPacket.get("clientBuildDate"), + bwPacket.get("clientBranch"), + bwPacket.get("inputSource"), + bwPacket.get("frequency") + ) + self.cursor.execute(self.sqlInserts.get("fms"), val) + + def pocsag(self, bwPacket): + """!Called on POCSAG alarm + + @param bwPacket: bwPacket instance + Remove if not implemented""" + val = ( + datetime.fromtimestamp(float(bwPacket.get("timestamp"))), + bwPacket.get("mode"), + bwPacket.get("ric"), + bwPacket.get("subric"), + bwPacket.get("subricText"), + bwPacket.get("message"), + bwPacket.get("bitrate"), + bwPacket.get("serverName"), + bwPacket.get("serverVersion"), + bwPacket.get("serverBuildDate"), + bwPacket.get("serverBranch"), + bwPacket.get("clientName"), + bwPacket.get("clientIP"), + bwPacket.get("clientVersion"), + bwPacket.get("clientBuildDate"), + bwPacket.get("clientBranch"), + bwPacket.get("inputSource"), + bwPacket.get("frequency") + ) + self.cursor.execute(self.sqlInserts.get("pocsag"), val) + + def zvei(self, bwPacket): + """!Called on ZVEI alarm + + @param bwPacket: bwPacket instance + Remove if not implemented""" + val = ( + datetime.fromtimestamp(float(bwPacket.get("timestamp"))), + bwPacket.get("mode"), + bwPacket.get("tone"), + bwPacket.get("serverName"), + bwPacket.get("serverVersion"), + bwPacket.get("serverBuildDate"), + bwPacket.get("serverBranch"), + bwPacket.get("clientName"), + bwPacket.get("clientIP"), + bwPacket.get("clientVersion"), + bwPacket.get("clientBuildDate"), + bwPacket.get("clientBranch"), + bwPacket.get("inputSource"), + bwPacket.get("frequency") + ) + self.cursor.execute(self.sqlInserts.get("pocsag"), val) + + def msg(self, bwPacket): + """!Called on MSG packet + + @param bwPacket: bwPacket instance + Remove if not implemented""" + val = ( + datetime.fromtimestamp(float(bwPacket.get("timestamp"))), + bwPacket.get("mode"), + bwPacket.get("serverName"), + bwPacket.get("serverVersion"), + bwPacket.get("serverBuildDate"), + bwPacket.get("serverBranch"), + bwPacket.get("clientName"), + bwPacket.get("clientIP"), + bwPacket.get("clientVersion"), + bwPacket.get("clientBuildDate"), + bwPacket.get("clientBranch"), + bwPacket.get("inputSource"), + bwPacket.get("frequency") + ) + self.cursor.execute(self.sqlInserts.get("msg"), val) + + def teardown(self): + """!Called after alarm + Remove if not implemented""" + self.connection.commit() + + def onUnload(self): + """!Called by destruction of the plugin + Remove if not implemented""" + pass From 99859f961cd230773ae59a375e4f9899197b6cf0 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 16 Feb 2021 15:06:18 +0100 Subject: [PATCH 02/21] Update Dockerfile --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 36568ce..95db75b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.10 AS build-base +FROM alpine:3.13 AS build-base RUN apk add git make cmake g++ libusb-dev libpulse FROM build-base AS rtl_fm @@ -8,18 +8,18 @@ WORKDIR /opt/rtl_sdr/build RUN cmake .. && make FROM build-base AS multimon -ARG MULTIMON_VERSION=1.1.8 +ARG MULTIMON_VERSION=1.1.9 RUN git clone --depth 1 --branch ${MULTIMON_VERSION} https://github.com/EliasOenal/multimon-ng.git /opt/multimon WORKDIR /opt/multimon/build RUN cmake .. && make -FROM alpine:3.10 AS boswatch +FROM alpine:3.13 AS boswatch ARG BW_VERSION=develop RUN apk add git && \ git clone --depth 1 --branch ${BW_VERSION} https://github.com/BOSWatch/BW3-Core.git /opt/boswatch -FROM python:3.6-alpine AS runner +FROM python:3.9.1-alpine AS runner LABEL maintainer="bastian@schroll-software.de" # for RTL for MM @@ -28,4 +28,4 @@ RUN apk add libusb-dev libpulse && \ COPY --from=boswatch /opt/boswatch/ /opt/boswatch/ COPY --from=multimon /opt/multimon/build/multimon-ng /opt/multimon/multimon-ng -COPY --from=rtl_fm /opt/rtl_sdr/build/src/ /opt/rtl_sdr/build/src/ \ No newline at end of file +COPY --from=rtl_fm /opt/rtl_sdr/build/src/ /opt/rtl_sdr/build/src/ From 77acab0429d4e034b73e36354998d40779bb5aee Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 16 Feb 2021 15:08:30 +0100 Subject: [PATCH 03/21] Update Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 95db75b..8ac0c9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,5 +27,5 @@ RUN apk add libusb-dev libpulse && \ pip3 install pyyaml COPY --from=boswatch /opt/boswatch/ /opt/boswatch/ -COPY --from=multimon /opt/multimon/build/multimon-ng /opt/multimon/multimon-ng -COPY --from=rtl_fm /opt/rtl_sdr/build/src/ /opt/rtl_sdr/build/src/ +COPY --from=multimon /opt/multimon/build/multimon-ng /opt/multimon-ng +COPY --from=rtl_fm /opt/rtl_sdr/build/src/ /opt/rtl_sdr From 90d932d53c8c36a7466b783adb3fcfd80eabe2ef Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Sun, 28 Feb 2021 13:58:29 +0100 Subject: [PATCH 04/21] update mysql plugin: add init_db.sql and create table automatically --- boswatch/router/routerManager.py | 4 ++-- init_db.sql | 34 ++++++++++++++++++++++++++++++++ plugin/mysql.py | 29 +++++++++++++++++++-------- 3 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 init_db.sql diff --git a/boswatch/router/routerManager.py b/boswatch/router/routerManager.py index 28a1788..86f6326 100644 --- a/boswatch/router/routerManager.py +++ b/boswatch/router/routerManager.py @@ -93,8 +93,8 @@ class RouterManager: logging.error("unknown type '%s' in %s", routeType, route) return False - except ModuleNotFoundError as e: - logging.error("%s not found: %s (%s)", route.get("type"), route.get("res"), str(e)) + except ModuleNotFoundError: + logging.exception("%s not found: %s", route.get("type"), route.get("res")) return False logging.debug("finished building routers") diff --git a/init_db.sql b/init_db.sql new file mode 100644 index 0000000..79a86fc --- /dev/null +++ b/init_db.sql @@ -0,0 +1,34 @@ +create table boswatch +( + id int auto_increment primary key, + packetTimestamp timestamp default now() not null, + packetMode enum('fms', 'pocsag', 'zvei', 'msg') not null, + pocsag_ric char(7) default null, + pocsag_subric enum('1', '2', '3', '4') default null, + pocsag_subricText enum('a', 'b', 'c', 'd') default null, + pocsag_message text default null, + pocsag_bitrate enum('512', '1200', '2400') default null, + zvei_tone char(5) default null, + fms_fms char(8) default null, + fms_service varchar(255) default null, + fms_country varchar(255) default null, + fms_location varchar(255) default null, + fms_vehicle varchar(255) default null, + fms_status char(1) default null, + fms_direction char(1) default null, + fms_directionText tinytext default null, + fms_tacticalInfo char(3) default null, + serverName varchar(255) not null, + serverVersion varchar(100) not null, + serverBuildDate varchar(255) not null, + serverBranch varchar(255) not null, + clientName varchar(255) not null, + clientIP varchar(255) not null, + clientVersion varchar(100) not null, + clientBuildDate varchar(255) not null, + clientBranch varchar(255) not null, + inputSource varchar(30) not null, + frequency varchar(30) not null +); +create unique index boswatch_id_uindex + on boswatch (id); \ No newline at end of file diff --git a/plugin/mysql.py b/plugin/mysql.py index e4c153e..f882703 100644 --- a/plugin/mysql.py +++ b/plugin/mysql.py @@ -37,12 +37,6 @@ class BoswatchPlugin(PluginBase): def onLoad(self): """!Called by import of the plugin Remove if not implemented""" - self.connection = mysql.connector.connect( - host=self.config.get("host"), - user=self.config.get("user"), - password=self.config.get("password"), - database=self.config.get("database"), - ) self.sqlInserts = { "pocsag": "INSERT INTO boswatch (packetTimestamp, packetMode, pocsag_ric, pocsag_subric, pocsag_subricText, pocsag_message, pocsag_bitrate, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", "zvei": "INSERT INTO boswatch (packetTimestamp, packetMode, zvei_tone, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", @@ -50,12 +44,30 @@ class BoswatchPlugin(PluginBase): "msg": "INSERT INTO boswatch (packetTimestamp, packetMode, serverName, serverVersion, serverBuildDate, serverBranch, clientName, clientIP, clientVersion, clientBuildDate, clientBranch, inputSource, frequency) VALUE (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" } + self.connection = mysql.connector.connect( + host=self.config.get("host"), + user=self.config.get("user"), + password=self.config.get("password"), + database=self.config.get("database"), + ) + + self.cursor = self.connection.cursor() + self.cursor.execute("SHOW TABLES LIKE 'boswatch'") + + if self.cursor.fetchone() is None: + with open('init_db.sql') as f: + for stmnt in f.read().split(';'): + self.cursor.execute(stmnt) + self.connection.commit() + + self.cursor.close() + def setup(self): """!Called before alarm Remove if not implemented""" try: self.connection.ping(reconnect=True, attempts=3, delay=2) - except mysql.connector.Error as err: + except mysql.connector.Error: logging.warning("Connection was down, trying to reconnect...") self.onLoad() @@ -168,8 +180,9 @@ class BoswatchPlugin(PluginBase): """!Called after alarm Remove if not implemented""" self.connection.commit() + self.cursor.close() def onUnload(self): """!Called by destruction of the plugin Remove if not implemented""" - pass + self.connection.close() From 3354a7d5f2353e95fd970a3e3e6b7d663316186e Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Mon, 1 Mar 2021 08:13:26 +0100 Subject: [PATCH 05/21] add documentation --- docu/docs/plugin/mysql.md | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 docu/docs/plugin/mysql.md diff --git a/docu/docs/plugin/mysql.md b/docu/docs/plugin/mysql.md new file mode 100644 index 0000000..0497aeb --- /dev/null +++ b/docu/docs/plugin/mysql.md @@ -0,0 +1,42 @@ +#
Mysql
+--- + +## Beschreibung +Mit diesem Plugin ist es moeglich, die Alarmierungen in einer Mysql / Mariadb Datenbank zu speichern. + +## Unterstütze Alarmtypen +- Fms +- Pocsag +- Zvei +- Msg + +## Resource +`mysql` + +## Konfiguration +|Feld|Beschreibung|Default| +|----|------------|-------| +|host|IP-Adresse bzw. URL des Hosts|| +|user|Username|| +|password|Passwort|| +|database|Name der Datenbank|| + +**Beispiel:** +```yaml + - type: plugin + name: mysql + res: mysql + config: + host: HOST + user: USERNAME + password: PASSWORD + database: DATABASE +``` + +--- +## Modul Abhängigkeiten +- keine + +--- +## Externe Abhängigkeiten +- mysql-connector-python From 31ee935628bcff0988a078cb7a04f737062f289c Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Thu, 4 Mar 2021 12:40:57 +0100 Subject: [PATCH 06/21] Change spacing in init_db.sql and add comment on table creation --- docu/docs/plugin/mysql.md | 1 + init_db.sql | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docu/docs/plugin/mysql.md b/docu/docs/plugin/mysql.md index 0497aeb..b2cd2d4 100644 --- a/docu/docs/plugin/mysql.md +++ b/docu/docs/plugin/mysql.md @@ -3,6 +3,7 @@ ## Beschreibung Mit diesem Plugin ist es moeglich, die Alarmierungen in einer Mysql / Mariadb Datenbank zu speichern. +Das Plugin legt die Tabelle "boswatch" selbststaendig an, wenn diese nicht vorhanden ist. ## Unterstütze Alarmtypen - Fms diff --git a/init_db.sql b/init_db.sql index 79a86fc..b5948bc 100644 --- a/init_db.sql +++ b/init_db.sql @@ -8,16 +8,16 @@ create table boswatch pocsag_subricText enum('a', 'b', 'c', 'd') default null, pocsag_message text default null, pocsag_bitrate enum('512', '1200', '2400') default null, - zvei_tone char(5) default null, - fms_fms char(8) default null, - fms_service varchar(255) default null, - fms_country varchar(255) default null, - fms_location varchar(255) default null, - fms_vehicle varchar(255) default null, - fms_status char(1) default null, - fms_direction char(1) default null, - fms_directionText tinytext default null, - fms_tacticalInfo char(3) default null, + zvei_tone char(5) default null, + fms_fms char(8) default null, + fms_service varchar(255) default null, + fms_country varchar(255) default null, + fms_location varchar(255) default null, + fms_vehicle varchar(255) default null, + fms_status char(1) default null, + fms_direction char(1) default null, + fms_directionText tinytext default null, + fms_tacticalInfo char(3) default null, serverName varchar(255) not null, serverVersion varchar(100) not null, serverBuildDate varchar(255) not null, @@ -31,4 +31,5 @@ create table boswatch frequency varchar(30) not null ); create unique index boswatch_id_uindex - on boswatch (id); \ No newline at end of file + on boswatch (id); + From 8a1bcebbd923da2536c568b489faf4d1cdc51f37 Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Sat, 13 Mar 2021 17:41:25 +0100 Subject: [PATCH 07/21] fix issue if additionalWildcard is not set (eg. descriptor) --- boswatch/wildcard.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boswatch/wildcard.py b/boswatch/wildcard.py index 3519502..3c7debd 100644 --- a/boswatch/wildcard.py +++ b/boswatch/wildcard.py @@ -97,8 +97,9 @@ def replaceWildcards(message, bwPacket): if field is not None: message = message.replace(wildcard, field) - for wildcard, field in _additionalWildcards.items(): + for wildcard, fieldName in _additionalWildcards.items(): + field = bwPacket.get(fieldName) if field is not None: - message = message.replace(wildcard, bwPacket.get(field)) + message = message.replace(wildcard, field) return message From 18d2ff7e1f04010aecd8025b5aae055f4392917f Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 10:54:36 +0100 Subject: [PATCH 08/21] Add Divera24/7-Plugin --- docu/docs/changelog.md | 9 +++ docu/docs/plugin/divera.md | 67 ++++++++++++++++++ plugin/divera.py | 138 +++++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 docu/docs/plugin/divera.md create mode 100644 plugin/divera.py diff --git a/docu/docs/changelog.md b/docu/docs/changelog.md index 6abd741..e249b9c 100644 --- a/docu/docs/changelog.md +++ b/docu/docs/changelog.md @@ -1,6 +1,15 @@ #
Changelog
--- +## Version [3.0.1] - date +### Added + * Divera24/7-Plugin +### Changed +### Deprecated +### Removed +### Fixed +### Security + ## Version [2.9.0] - date Functions implemented in initial version: diff --git a/docu/docs/plugin/divera.md b/docu/docs/plugin/divera.md new file mode 100644 index 0000000..9e5fa02 --- /dev/null +++ b/docu/docs/plugin/divera.md @@ -0,0 +1,67 @@ +#
Divera 24/7
+--- + +## Beschreibung +Mit diesem Plugin ist es moeglich, Http-Anfragen für Alarmierungen an Divera 24/7 zu senden. +Wildcards in den Urls werden automatisch ersetzt. + +## Unterstütze Alarmtypen +- Fms +- Pocsag +- Zvei +- Msg + +## Resource +`divera` + +## Konfiguration +|Feld|Beschreibung|Default| +|----|------------|-------| +|accesskey|Web-API-Schlüssel von Divera24/7 || +|priority|Sonderrechte|false| +|title| Titel der Meldung | s. Beispiel| +|message| Nachrichteninhalt| s. Beispiel| +|ric|Auszulösende RIC in Divera; Gruppen->Alarmierungs-RIC|| +|vehicle|Fahrzeug-Alarmierungs-RIC|| + +**Beispiel:** +```yaml + - type: plugin + name: Divera Plugin + res: divera + config: + accesskey: API-Key + pocsag: + priority: false + title: "{RIC}({SRIC})\n{MSG}" + message: "{MSG}" + # RIC ist in Divera definiert + ric: Probealarm + fms: + priority: false + title: "{FMS}" + message: "{FMS}" + vehicle: MTF + zvei: + ric: Probealarm + title: "{TONE}" + message: "{TONE}" + priority: false + msg: + priority: false + title: "{MSG}" + message: "{MSG}" + # RIC ist in Divera definiert + ric: Probealarm + +``` + +--- +## Modul Abhängigkeiten +- keine + +--- +## Externe Abhängigkeiten +- asyncio +- aiohttp +- urllib diff --git a/plugin/divera.py b/plugin/divera.py new file mode 100644 index 0000000..55593c5 --- /dev/null +++ b/plugin/divera.py @@ -0,0 +1,138 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +"""! + ____ ____ ______ __ __ __ _____ + / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / + / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < + / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / +/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ + German BOS Information Script + by Bastian Schroll + +@file: divera.py +@date: 16.01.2022 +@author: Lars Gremme +@description: Divera247 Plugin +""" +import logging +from plugin.pluginBase import PluginBase + +# ###################### # +# Custom plugin includes # +import asyncio +from aiohttp import ClientSession +import urllib +# ###################### # + +logging.debug("- %s loaded", __name__) + + +class BoswatchPlugin(PluginBase): + """!Description of the Plugin""" + def __init__(self, config): + """!Do not change anything here!""" + super().__init__(__name__, config) # you can access the config class on 'self.config' + + + def fms(self, bwPacket): + """!Called on FMS alarm + + @param bwPacket: bwPacket instance + Remove if not implemented""" + fms_data = self.config.get("fms") + apicall = urllib.parse.urlencode({ + "accesskey": self.config.get("accesskey", default=""), + "vehicle_ric": self.parseWildcards(fms_data.get("vehicle", default="")), + "status_id": bwPacket.get("status"), + "status_note": bwPacket.get("directionText"), + "title": self.parseWildcards(fms_data.get("title", default="{FMS}")), + "text": self.parseWildcards(fms_data.get("message", default="{FMS}")), + "priority": fms_data.get("priority", default="false"), + }) + apipath = "/api/fms" + self.makeRequests(apipath, apicall) + + def pocsag(self, bwPacket): + """!Called on POCSAG alarm + + @param bwPacket: bwPacket instance + Remove if not implemented""" + poc_data = self.config.get("pocsag") + apicall = urllib.parse.urlencode({ + "accesskey": self.config.get("accesskey", default=""), + "title": self.parseWildcards(poc_data.get("title", default="{RIC}({SRIC})\n{MSG}")), + "ric": self.parseWildcards(poc_data.get("ric", default="")), + "text": self.parseWildcards(poc_data.get("message", default="{MSG}")), + "priority": poc_data.get("priority", default="false"), + }) + apipath = "/api/alarm" + self.makeRequests(apipath, apicall) + + def zvei(self, bwPacket): + """!Called on ZVEI alarm + + @param bwPacket: bwPacket instance + Remove if not implemented""" + zvei_data = self.config.get("zvei") + apicall = urllib.parse.urlencode({ + "accesskey": self.config.get("accesskey", default=""), + "title": self.parseWildcards(zvei_data.get("title", default="{TONE}")), + "ric": self.parseWildcards(zvei_data.get("ric", default="{TONE}")), + "text": self.parseWildcards(zvei_data.get("message", default="{TONE}")), + "priority": zvei_data.get("priority", default="false"), + }) + apipath = "/api/alarm" + self.makeRequests(apipath, apicall) + + def msg(self, bwPacket): + """!Called on MSG packet + + @param bwPacket: bwPacket instance + Remove if not implemented""" + msg_data = self.config.get("msg") + apicall = urllib.parse.urlencode({ + "accesskey": self.config.get("accesskey", default=""), + "title": self.parseWildcards(msg_data.get("title", default="{MSG}")), + "ric": self.parseWildcards(msg_data.get("ric", default="")), + "text": self.parseWildcards(msg_data.get("message", default="{MSG}")), + "priority": msg_data.get("priority", default="false"), + }) + apipath = "/api/alarm" + self.makeRequests(apipath, apicall) + + def makeRequests(self, apipath, apicall): + """Parses wildcard urls and handles asynchronus requests + + @param urls: array of urls""" + url = "https://www.divera247.com" + request = url + apipath + "?" + apicall + + loop = asyncio.get_event_loop() + + future = asyncio.ensure_future(self.asyncRequests(request)) + loop.run_until_complete(future) + + async def asyncRequests(self, url): + """Handles asynchronus requests + + @param urls: array of urls to send requests to""" + tasks = [] + + async with ClientSession() as session: + logging.debug("Generated URL: [{}]".format(url)) + task = asyncio.ensure_future(self.fetch(url, session)) + tasks.append(task) + + responses = asyncio.gather(*tasks) + await responses + + async def fetch(self, url, session): + """Fetches requests + + @param url: url + + @param session: Clientsession instance""" + logging.debug("Post URL: [{}]".format(url)) + async with session.post(url) as response: + logging.info("{} returned [{}]".format(response.url, response.status)) + return await response.read() From 112254b928523ba6951e1ee05428adaa0a9b0952 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 11:01:50 +0100 Subject: [PATCH 09/21] Add python3-pip, alsa-utils to install-script; Fix install-script to use GIT in boswatch3-folder, use running RTL-FM version --- docu/docs/changelog.md | 4 +++ install.sh | 79 +++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/docu/docs/changelog.md b/docu/docs/changelog.md index e249b9c..062b9cd 100644 --- a/docu/docs/changelog.md +++ b/docu/docs/changelog.md @@ -4,10 +4,14 @@ ## Version [3.0.1] - date ### Added * Divera24/7-Plugin + * Python3-pip for requirements in install-script + * Alsa-utils in install-script ### Changed ### Deprecated ### Removed ### Fixed + * Install-Script to use GIT in boswatch3-folder + * Running RTL-FM Version (on RPi buster) ### Security ## Version [2.9.0] - date diff --git a/install.sh b/install.sh index 7c0611c..6e2244c 100644 --- a/install.sh +++ b/install.sh @@ -37,17 +37,17 @@ function exitcodefunction { module=$3 if [ $errorcode -ne "0" ]; then - echo "Action: $action on $module failed." >> $boswatchpath/install/setup_log.txt - echo "Exitcode: $errorcode" >> $boswatchpath/install/setup_log.txt + echo "Action: ${action} on ${module} failed." >> ${boswatch_install_path}/setup_log.txt + echo "Exitcode: ${errorcode}" >> ${boswatch_install_path}/setup_log.txt echo "" - echo "Action: $action on $module failed." - echo "Exitcode: $errorcode" + echo "Action: ${action} on ${module} failed." + echo "Exitcode: ${errorcode}" echo "" echo " -> If you want to open an issue at https://github.com/BOSWatch/BW3-Core/issues" - echo " please post the logfile, located at $boswatchpath/install/setup_log.txt" + echo " please post the logfile, located at ${boswatch_install_path}/setup_log.txt" exit 1 else - echo "Action: $action on $module ok." >> $boswatchpath/install/setup_log.txt + echo "Action: ${action} on ${module} ok." >> ${boswatch_install_path}/setup_log.txt fi } @@ -76,6 +76,7 @@ echo "Caution, script does not install a webserver with PHP and MySQL" echo "So you have to make up manually if you want to use MySQL support" boswatchpath=/opt/boswatch3 +boswatch_install_path=/opt/boswatch3_install reboot=false for (( i=1; i<=$#; i=$i+2 )); do @@ -83,11 +84,11 @@ for (( i=1; i<=$#; i=$i+2 )); do eval arg=\$$i eval arg2=\$$t - case $arg in + case ${arg} in -r|--reboot) reboot=true ;; -b|--branch) - case $arg2 in + case ${arg2} in dev|develop) echo " !!! WARNING: you are using the DEV BRANCH !!! "; branch=dev ;; *) branch=master ;; esac ;; @@ -98,8 +99,7 @@ for (( i=1; i<=$#; i=$i+2 )); do esac done -mkdir -p $boswatchpath -mkdir -p $boswatchpath/install +mkdir -p ${boswatchpath} ${boswatch_install_path} echo "" @@ -107,57 +107,58 @@ tput cup 13 15 echo "[ 1/9] [#--------]" tput cup 15 5 echo "-> make an apt-get update................" -apt-get update -y > $boswatchpath/install/setup_log.txt 2>&1 +apt-get update -y > ${boswatch_install_path}/setup_log.txt 2>&1 tput cup 13 15 echo "[ 2/9] [##-------]" tput cup 15 5 echo "-> download GIT and other stuff.........." -apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox >> $boswatchpath/install/setup_log.txt 2>&1 +apt-get -y install git cmake build-essential libusb-1.0 qt5-qmake libpulse-dev libx11-dev sox >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? download stuff tput cup 13 15 echo "[ 3/9] [###------]" tput cup 15 5 echo "-> download Python, Yaml and other stuff.." -sudo apt-get -y install python3 python3-yaml >> $boswatchpath/install/setup_log.txt 2>&1 +sudo apt-get -y install python3 python3-yaml python3-pip alsa-utils>> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? download python tput cup 13 15 echo "[ 4/9] [####-----]" tput cup 15 5 echo "-> download rtl_fm........................." -cd $boswatchpath/install -git clone --branch v0.5.4 https://github.com/osmocom/rtl-sdr.git rtl-sdr >> $boswatchpath/install/setup_log.txt 2>&1 +cd ${boswatch_install_path} +git clone --branch master https://github.com/osmocom/rtl-sdr.git rtl-sdr >> ${boswatch_install_path}/setup_log.txt 2>&1 +cd ${boswatch_install_path}/rtl-sdr/ +git checkout 2659e2df31e592d74d6dd264a4f5ce242c6369c8 exitcodefunction $? git-clone rtl-sdr -cd $boswatchpath/install/rtl-sdr/ tput cup 13 15 echo "[ 5/9] [#####----]" tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build -cmake ../ -DINSTALL_UDEV_RULES=ON >> $boswatchpath/install/setup_log.txt 2>&1 +cmake ../ -DINSTALL_UDEV_RULES=ON >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? cmake rtl-sdr -make >> $boswatchpath/install/setup_log.txt 2>&1 +make >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? make rtl-sdr -make install >> $boswatchpath/install/setup_log.txt 2>&1 +make install >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? make-install rtl-sdr -ldconfig >> $boswatchpath/install/setup_log.txt 2>&1 +ldconfig >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? ldconfig rtl-sdr tput cup 13 15 echo "[ 6/9] [######---]" tput cup 15 5 echo "-> download multimon-ng................" -cd $boswatchpath/install -git clone --branch 1.1.8 https://github.com/EliasOenal/multimon-ng.git multimonNG >> $boswatchpath/install/setup_log.txt 2>&1 +cd ${boswatch_install_path} +git clone --branch 1.1.8 https://github.com/EliasOenal/multimon-ng.git multimonNG >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? git-clone multimonNG -cd $boswatchpath/install/multimonNG/ +cd ${boswatch_install_path}/multimonNG/ tput cup 13 15 echo "[ 7/9] [#######--]" @@ -165,25 +166,26 @@ tput cup 15 5 echo "-> compile multimon-ng................." mkdir -p build cd build -qmake ../multimon-ng.pro >> $boswatchpath/install/setup_log.txt 2>&1 +# Export environment variable for qt5 +export QT_SELECT=qt5 +qmake ../multimon-ng.pro >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? qmake multimonNG -make >> $boswatchpath/install/setup_log.txt 2>&1 +make >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? make multimonNG -make install >> $boswatchpath/install/setup_log.txt 2>&1 +make install >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? qmakeinstall multimonNG tput cup 13 15 echo "[ 8/9] [########-]" tput cup 15 5 echo "-> download BOSWatch3.................." -cd $boswatchpath/ -case $branch in - "dev") git clone -b develop https://github.com/BOSWatch/BW3-Core >> $boswatchpath/install/setup_log.txt 2>&1 && \ +case ${branch} in + "dev") git clone -b develop https://github.com/BOSWatch/BW3-Core ${boswatchpath} >> ${boswatch_install_path}/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BW3-Core-develop ;; - *) git clone -b master https://github.com/BOSWatch/BW3-Core >> $boswatchpath/install/setup_log.txt 2>&1 && \ + *) git clone -b master https://github.com/BOSWatch/BW3-Core ${boswatchpath} >> ${boswatch_install_path}/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BW3-Core ;; esac @@ -191,22 +193,22 @@ tput cup 13 15 echo "[9/9] [#########]" tput cup 15 5 echo "-> configure..........................." -cd $boswatchpath/ +cd ${boswatchpath}/ chmod +x * echo $'# BOSWatch3 - blacklist the DVB drivers to avoid conflicts 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 tput cup 17 1 tput rev # Schrift zur besseren lesbarkeit Revers -echo "BOSWatch is now installed in $boswatchpath/ Installation ready!" +echo "BOSWatch is now installed in ${boswatchpath}/ Installation ready!" tput sgr0 # Schrift wieder Normal tput cup 19 3 echo "Watch out: to run BOSWatch3 you have to modify the server.yaml and client.yaml!" echo "Do the following step to do so:" -echo "sudo nano $boswatchpath/config/client.yaml eg. server.yaml" +echo "sudo nano ${boswatchpath}/config/client.yaml eg. server.yaml" echo "and modify the config as you need. This step is optional if you are upgrading an old version of BOSWatch3." echo "You can read the instructions on https://docs.boswatch.de/" tput setaf 1 # Rote Schrift -echo "Please REBOOT bevor the first start" +echo "Please REBOOT before the first start" tput setaf 9 # Schrift zurücksetzen echo "start Boswatch3 with" echo "sudo python3 bw_client.py -c client.yaml and sudo python3 bw_server.py -c server.yaml" @@ -214,12 +216,9 @@ echo "sudo python3 bw_client.py -c client.yaml and sudo python3 bw_server.p tput cnorm # cleanup -mkdir $boswatchpath/log/install -p -mv $boswatchpath/install/setup_log.txt $boswatchpath/log/install/ -rm $boswatchpath/install/ -R - -mv $boswatchpath/BW3-Core/* $boswatchpath/ -rm $boswatchpath/BW3-Core -R +mkdir ${boswatchpath}/log/install -p +mv ${boswatch_install_path}/setup_log.txt ${boswatchpath}/log/install/ +rm ${boswatch_install_path} -R if [ $reboot = "true" ]; then /sbin/reboot From c6df7a6b7ba94ce93f0d10000f1ca8dbd02d9eb6 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 11:06:24 +0100 Subject: [PATCH 10/21] Add fir_size as optionally value --- boswatch/inputSource/sdrInput.py | 2 ++ config/client.yaml | 1 + docu/docs/changelog.md | 1 + 3 files changed, 4 insertions(+) diff --git a/boswatch/inputSource/sdrInput.py b/boswatch/inputSource/sdrInput.py index 6b1faf7..cc4e64f 100644 --- a/boswatch/inputSource/sdrInput.py +++ b/boswatch/inputSource/sdrInput.py @@ -36,6 +36,8 @@ class SdrInput(InputBase): sdrProc.addArgument("-p " + str(sdrConfig.get("error", default="0"))) # frequency error in ppm sdrProc.addArgument("-l " + str(sdrConfig.get("squelch", default="1"))) # squelch sdrProc.addArgument("-g " + str(sdrConfig.get("gain", default="100"))) # gain + if (sdrConfig.get("fir_size") != None): + sdrProc.addArgument("-F " + str(sdrConfig.get("fir_size"))) # fir_size sdrProc.addArgument("-M fm") # set mode to fm sdrProc.addArgument("-E DC") # set DC filter sdrProc.addArgument("-s 22050") # bit rate of audio stream diff --git a/config/client.yaml b/config/client.yaml index 1550eab..b6e2baf 100644 --- a/config/client.yaml +++ b/config/client.yaml @@ -26,6 +26,7 @@ inputSource: error: 0 squelch: 1 gain: 100 + #fir_size: 0 rtlPath: /usr/bin/rtl_fm lineIn: card: 1 diff --git a/docu/docs/changelog.md b/docu/docs/changelog.md index 062b9cd..a022d4b 100644 --- a/docu/docs/changelog.md +++ b/docu/docs/changelog.md @@ -6,6 +6,7 @@ * Divera24/7-Plugin * Python3-pip for requirements in install-script * Alsa-utils in install-script + * Add fir_size for RTL-FM as optionally value ### Changed ### Deprecated ### Removed From 0e386e79c96a67fc46f12e2efc80060f9fb72f5f Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 12:25:30 +0100 Subject: [PATCH 11/21] Changes request by review --- docu/docs/plugin/divera.md | 2 +- install.sh | 2 +- plugin/divera.py | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docu/docs/plugin/divera.md b/docu/docs/plugin/divera.md index 9e5fa02..a78c7cb 100644 --- a/docu/docs/plugin/divera.md +++ b/docu/docs/plugin/divera.md @@ -2,7 +2,7 @@ --- ## Beschreibung -Mit diesem Plugin ist es moeglich, Http-Anfragen für Alarmierungen an Divera 24/7 zu senden. +Mit diesem Plugin ist es möglich, HTTPS-Anfragen für Alarmierungen an Divera 24/7 zu senden. Wildcards in den Urls werden automatisch ersetzt. ## Unterstütze Alarmtypen diff --git a/install.sh b/install.sh index 6e2244c..839d018 100644 --- a/install.sh +++ b/install.sh @@ -113,7 +113,7 @@ tput cup 13 15 echo "[ 2/9] [##-------]" tput cup 15 5 echo "-> download GIT and other stuff.........." -apt-get -y install git cmake build-essential libusb-1.0 qt5-qmake libpulse-dev libx11-dev sox >> ${boswatch_install_path}/setup_log.txt 2>&1 +apt-get -y install git cmake build-essential libusb-1.0 qt5-qmake qt5-default libpulse-dev libx11-dev sox >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? download stuff tput cup 13 15 diff --git a/plugin/divera.py b/plugin/divera.py index 55593c5..e6d4e25 100644 --- a/plugin/divera.py +++ b/plugin/divera.py @@ -50,7 +50,7 @@ class BoswatchPlugin(PluginBase): "priority": fms_data.get("priority", default="false"), }) apipath = "/api/fms" - self.makeRequests(apipath, apicall) + self._makeRequests(apipath, apicall) def pocsag(self, bwPacket): """!Called on POCSAG alarm @@ -66,7 +66,7 @@ class BoswatchPlugin(PluginBase): "priority": poc_data.get("priority", default="false"), }) apipath = "/api/alarm" - self.makeRequests(apipath, apicall) + self._makeRequests(apipath, apicall) def zvei(self, bwPacket): """!Called on ZVEI alarm @@ -82,7 +82,7 @@ class BoswatchPlugin(PluginBase): "priority": zvei_data.get("priority", default="false"), }) apipath = "/api/alarm" - self.makeRequests(apipath, apicall) + self._makeRequests(apipath, apicall) def msg(self, bwPacket): """!Called on MSG packet @@ -98,9 +98,9 @@ class BoswatchPlugin(PluginBase): "priority": msg_data.get("priority", default="false"), }) apipath = "/api/alarm" - self.makeRequests(apipath, apicall) + self._makeRequests(apipath, apicall) - def makeRequests(self, apipath, apicall): + def _makeRequests(self, apipath, apicall): """Parses wildcard urls and handles asynchronus requests @param urls: array of urls""" @@ -109,10 +109,10 @@ class BoswatchPlugin(PluginBase): loop = asyncio.get_event_loop() - future = asyncio.ensure_future(self.asyncRequests(request)) + future = asyncio.ensure_future(self._asyncRequests(request)) loop.run_until_complete(future) - async def asyncRequests(self, url): + async def _asyncRequests(self, url): """Handles asynchronus requests @param urls: array of urls to send requests to""" @@ -120,13 +120,13 @@ class BoswatchPlugin(PluginBase): async with ClientSession() as session: logging.debug("Generated URL: [{}]".format(url)) - task = asyncio.ensure_future(self.fetch(url, session)) + task = asyncio.ensure_future(self._fetch(url, session)) tasks.append(task) responses = asyncio.gather(*tasks) await responses - async def fetch(self, url, session): + async def _fetch(self, url, session): """Fetches requests @param url: url From 07b6ded17fe8c7670adffe921f12710775f0f387 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 12:27:08 +0100 Subject: [PATCH 12/21] Update http.py --- plugin/http.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin/http.py b/plugin/http.py index 5d206bc..207dce8 100644 --- a/plugin/http.py +++ b/plugin/http.py @@ -38,7 +38,7 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" urls = self.config.get("fms") - self.makeRequests(urls) + self._makeRequests(urls) def pocsag(self, bwPacket): """!Called on POCSAG alarm @@ -46,7 +46,7 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" urls = self.config.get("pocsag") - self.makeRequests(urls) + self._makeRequests(urls) def zvei(self, bwPacket): """!Called on ZVEI alarm @@ -54,7 +54,7 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" urls = self.config.get("zvei") - self.makeRequests(urls) + self._makeRequests(urls) def msg(self, bwPacket): """!Called on MSG packet @@ -62,7 +62,7 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" urls = self.config.get("msg") - self.makeRequests(urls) + self._makeRequests(urls) def makeRequests(self, urls): """Parses wildcard urls and handles asynchronus requests @@ -75,7 +75,7 @@ class BoswatchPlugin(PluginBase): future = asyncio.ensure_future(self.asyncRequests(urls)) loop.run_until_complete(future) - async def asyncRequests(self, urls): + async def _asyncRequests(self, urls): """Handles asynchronus requests @param urls: array of urls to send requests to""" @@ -83,13 +83,13 @@ class BoswatchPlugin(PluginBase): async with ClientSession() as session: for url in urls: - task = asyncio.ensure_future(self.fetch(url, session)) + task = asyncio.ensure_future(self._fetch(url, session)) tasks.append(task) responses = asyncio.gather(*tasks) await responses - async def fetch(self, url, session): + async def _fetch(self, url, session): """Fetches requests @param url: url From b44dcd2de6861122845ecf16a12580bd5b553976 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 12:38:26 +0100 Subject: [PATCH 13/21] Set qt5 variable direct to qmake --- install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 839d018..488d2eb 100644 --- a/install.sh +++ b/install.sh @@ -166,9 +166,7 @@ tput cup 15 5 echo "-> compile multimon-ng................." mkdir -p build cd build -# Export environment variable for qt5 -export QT_SELECT=qt5 -qmake ../multimon-ng.pro >> ${boswatch_install_path}/setup_log.txt 2>&1 +qmake -qt=qt5 ../multimon-ng.pro >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? qmake multimonNG make >> ${boswatch_install_path}/setup_log.txt 2>&1 From e4822cbf701f22723fcba5436b158749a3c84b0c Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Sun, 23 Jan 2022 12:46:47 +0100 Subject: [PATCH 14/21] Add hint for fir_size in docu --- docu/docs/config.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docu/docs/config.md b/docu/docs/config.md index b833101..0c69065 100644 --- a/docu/docs/config.md +++ b/docu/docs/config.md @@ -49,6 +49,7 @@ Mit `PulseAudio` wird ein PulseAudio-Sink an Multimon-NG weitergereicht, z.B. in |error|Frequenz Abweichung in ppm|0| |squelch|Einstellung der Rauschsperre|1| |gain|Verstärkung des Eingangssignals|100| +|fir_size| niedrig leckagearmen Filter, default 0 = off|| |rtlPath|Pfad zur rtl_fm Binary|rtl_fm| **Beispiel:** From 01e94856ac17c481f1a7f2884783f493097e972b Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 17 Feb 2022 10:05:07 +0100 Subject: [PATCH 15/21] Update run_pytest.yml drop py3.6, add py3.10 to action --- .github/workflows/run_pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_pytest.yml b/.github/workflows/run_pytest.yml index 69d1a7d..c4c5751 100644 --- a/.github/workflows/run_pytest.yml +++ b/.github/workflows/run_pytest.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, 3.10] runs-on: ${{matrix.os}} steps: From 7ecec6940fde2329aed357cdd6a0bce189ca4748 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 17 Feb 2022 10:07:51 +0100 Subject: [PATCH 16/21] Update run_pytest.yml fix gh-action --- .github/workflows/run_pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_pytest.yml b/.github/workflows/run_pytest.yml index c4c5751..9ed7032 100644 --- a/.github/workflows/run_pytest.yml +++ b/.github/workflows/run_pytest.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [3.7, 3.8, 3.9, 3.10] + python-version: [3.7, 3.8, 3.9, 3.10.2] runs-on: ${{matrix.os}} steps: From 8a8fc3bd6b7e1541ac063259a41fe06b089a6ae3 Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Thu, 17 Feb 2022 20:01:26 +0100 Subject: [PATCH 17/21] Update dependencies and correct issue --- install.sh | 4 ++-- plugin/http.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 488d2eb..0e02751 100644 --- a/install.sh +++ b/install.sh @@ -113,14 +113,14 @@ tput cup 13 15 echo "[ 2/9] [##-------]" tput cup 15 5 echo "-> download GIT and other stuff.........." -apt-get -y install git cmake build-essential libusb-1.0 qt5-qmake qt5-default libpulse-dev libx11-dev sox >> ${boswatch_install_path}/setup_log.txt 2>&1 +apt-get -y install git cmake build-essential libusb-1.0 qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qt5-default libpulse-dev libx11-dev sox >> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? download stuff tput cup 13 15 echo "[ 3/9] [###------]" tput cup 15 5 echo "-> download Python, Yaml and other stuff.." -sudo apt-get -y install python3 python3-yaml python3-pip alsa-utils>> ${boswatch_install_path}/setup_log.txt 2>&1 +apt-get -y install python3 python3-yaml python3-pip alsa-utils>> ${boswatch_install_path}/setup_log.txt 2>&1 exitcodefunction $? download python tput cup 13 15 diff --git a/plugin/http.py b/plugin/http.py index 207dce8..1af3035 100644 --- a/plugin/http.py +++ b/plugin/http.py @@ -64,7 +64,7 @@ class BoswatchPlugin(PluginBase): urls = self.config.get("msg") self._makeRequests(urls) - def makeRequests(self, urls): + def _makeRequests(self, urls): """Parses wildcard urls and handles asynchronus requests @param urls: array of urls""" From b5477e137d5912a1264a819845d52fd73c9086bb Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Thu, 17 Feb 2022 20:57:13 +0100 Subject: [PATCH 18/21] Update for flake8 --- boswatch/inputSource/sdrInput.py | 2 +- plugin/divera.py | 61 ++++++++++++++++---------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/boswatch/inputSource/sdrInput.py b/boswatch/inputSource/sdrInput.py index cc4e64f..803e658 100644 --- a/boswatch/inputSource/sdrInput.py +++ b/boswatch/inputSource/sdrInput.py @@ -36,7 +36,7 @@ class SdrInput(InputBase): sdrProc.addArgument("-p " + str(sdrConfig.get("error", default="0"))) # frequency error in ppm sdrProc.addArgument("-l " + str(sdrConfig.get("squelch", default="1"))) # squelch sdrProc.addArgument("-g " + str(sdrConfig.get("gain", default="100"))) # gain - if (sdrConfig.get("fir_size") != None): + if (sdrConfig.get("fir_size") is not None): sdrProc.addArgument("-F " + str(sdrConfig.get("fir_size"))) # fir_size sdrProc.addArgument("-M fm") # set mode to fm sdrProc.addArgument("-E DC") # set DC filter diff --git a/plugin/divera.py b/plugin/divera.py index e6d4e25..b3cc39b 100644 --- a/plugin/divera.py +++ b/plugin/divera.py @@ -33,22 +33,21 @@ class BoswatchPlugin(PluginBase): """!Do not change anything here!""" super().__init__(__name__, config) # you can access the config class on 'self.config' - def fms(self, bwPacket): """!Called on FMS alarm @param bwPacket: bwPacket instance Remove if not implemented""" - fms_data = self.config.get("fms") + fms_data = self.config.get("fms") apicall = urllib.parse.urlencode({ - "accesskey": self.config.get("accesskey", default=""), - "vehicle_ric": self.parseWildcards(fms_data.get("vehicle", default="")), - "status_id": bwPacket.get("status"), - "status_note": bwPacket.get("directionText"), - "title": self.parseWildcards(fms_data.get("title", default="{FMS}")), - "text": self.parseWildcards(fms_data.get("message", default="{FMS}")), - "priority": fms_data.get("priority", default="false"), - }) + "accesskey": self.config.get("accesskey", default=""), + "vehicle_ric": self.parseWildcards(fms_data.get("vehicle", default="")), + "status_id": bwPacket.get("status"), + "status_note": bwPacket.get("directionText"), + "title": self.parseWildcards(fms_data.get("title", default="{FMS}")), + "text": self.parseWildcards(fms_data.get("message", default="{FMS}")), + "priority": fms_data.get("priority", default="false"), + }) apipath = "/api/fms" self._makeRequests(apipath, apicall) @@ -57,14 +56,14 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" - poc_data = self.config.get("pocsag") + poc_data = self.config.get("pocsag") apicall = urllib.parse.urlencode({ - "accesskey": self.config.get("accesskey", default=""), - "title": self.parseWildcards(poc_data.get("title", default="{RIC}({SRIC})\n{MSG}")), - "ric": self.parseWildcards(poc_data.get("ric", default="")), - "text": self.parseWildcards(poc_data.get("message", default="{MSG}")), - "priority": poc_data.get("priority", default="false"), - }) + "accesskey": self.config.get("accesskey", default=""), + "title": self.parseWildcards(poc_data.get("title", default="{RIC}({SRIC})\n{MSG}")), + "ric": self.parseWildcards(poc_data.get("ric", default="")), + "text": self.parseWildcards(poc_data.get("message", default="{MSG}")), + "priority": poc_data.get("priority", default="false"), + }) apipath = "/api/alarm" self._makeRequests(apipath, apicall) @@ -73,14 +72,14 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" - zvei_data = self.config.get("zvei") + zvei_data = self.config.get("zvei") apicall = urllib.parse.urlencode({ - "accesskey": self.config.get("accesskey", default=""), - "title": self.parseWildcards(zvei_data.get("title", default="{TONE}")), - "ric": self.parseWildcards(zvei_data.get("ric", default="{TONE}")), - "text": self.parseWildcards(zvei_data.get("message", default="{TONE}")), - "priority": zvei_data.get("priority", default="false"), - }) + "accesskey": self.config.get("accesskey", default=""), + "title": self.parseWildcards(zvei_data.get("title", default="{TONE}")), + "ric": self.parseWildcards(zvei_data.get("ric", default="{TONE}")), + "text": self.parseWildcards(zvei_data.get("message", default="{TONE}")), + "priority": zvei_data.get("priority", default="false"), + }) apipath = "/api/alarm" self._makeRequests(apipath, apicall) @@ -89,14 +88,14 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance Remove if not implemented""" - msg_data = self.config.get("msg") + msg_data = self.config.get("msg") apicall = urllib.parse.urlencode({ - "accesskey": self.config.get("accesskey", default=""), - "title": self.parseWildcards(msg_data.get("title", default="{MSG}")), - "ric": self.parseWildcards(msg_data.get("ric", default="")), - "text": self.parseWildcards(msg_data.get("message", default="{MSG}")), - "priority": msg_data.get("priority", default="false"), - }) + "accesskey": self.config.get("accesskey", default=""), + "title": self.parseWildcards(msg_data.get("title", default="{MSG}")), + "ric": self.parseWildcards(msg_data.get("ric", default="")), + "text": self.parseWildcards(msg_data.get("message", default="{MSG}")), + "priority": msg_data.get("priority", default="false"), + }) apipath = "/api/alarm" self._makeRequests(apipath, apicall) From 3b65052a5bdd1fbaf9c203406931055ec12da3be Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Fri, 18 Feb 2022 19:34:00 +0100 Subject: [PATCH 19/21] Update Changelog and remove double negation --- boswatch/inputSource/sdrInput.py | 2 +- docu/docs/changelog.md | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/boswatch/inputSource/sdrInput.py b/boswatch/inputSource/sdrInput.py index 803e658..940ad80 100644 --- a/boswatch/inputSource/sdrInput.py +++ b/boswatch/inputSource/sdrInput.py @@ -36,7 +36,7 @@ class SdrInput(InputBase): sdrProc.addArgument("-p " + str(sdrConfig.get("error", default="0"))) # frequency error in ppm sdrProc.addArgument("-l " + str(sdrConfig.get("squelch", default="1"))) # squelch sdrProc.addArgument("-g " + str(sdrConfig.get("gain", default="100"))) # gain - if (sdrConfig.get("fir_size") is not None): + if sdrConfig.get("fir_size", default=None): sdrProc.addArgument("-F " + str(sdrConfig.get("fir_size"))) # fir_size sdrProc.addArgument("-M fm") # set mode to fm sdrProc.addArgument("-E DC") # set DC filter diff --git a/docu/docs/changelog.md b/docu/docs/changelog.md index a022d4b..6abd741 100644 --- a/docu/docs/changelog.md +++ b/docu/docs/changelog.md @@ -1,20 +1,6 @@ #
Changelog
--- -## Version [3.0.1] - date -### Added - * Divera24/7-Plugin - * Python3-pip for requirements in install-script - * Alsa-utils in install-script - * Add fir_size for RTL-FM as optionally value -### Changed -### Deprecated -### Removed -### Fixed - * Install-Script to use GIT in boswatch3-folder - * Running RTL-FM Version (on RPi buster) -### Security - ## Version [2.9.0] - date Functions implemented in initial version: From b12c11d2681b4a1e4cd2ebfca9b0b6fc0122893b Mon Sep 17 00:00:00 2001 From: Lars Gremme Date: Wed, 23 Feb 2022 19:15:45 +0100 Subject: [PATCH 20/21] Update fir_size value and correct fir_size in docu --- boswatch/inputSource/sdrInput.py | 2 +- docu/docs/config.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boswatch/inputSource/sdrInput.py b/boswatch/inputSource/sdrInput.py index 940ad80..3fa2af3 100644 --- a/boswatch/inputSource/sdrInput.py +++ b/boswatch/inputSource/sdrInput.py @@ -36,7 +36,7 @@ class SdrInput(InputBase): sdrProc.addArgument("-p " + str(sdrConfig.get("error", default="0"))) # frequency error in ppm sdrProc.addArgument("-l " + str(sdrConfig.get("squelch", default="1"))) # squelch sdrProc.addArgument("-g " + str(sdrConfig.get("gain", default="100"))) # gain - if sdrConfig.get("fir_size", default=None): + if (sdrConfig.get("fir_size", default=None) is not None): sdrProc.addArgument("-F " + str(sdrConfig.get("fir_size"))) # fir_size sdrProc.addArgument("-M fm") # set mode to fm sdrProc.addArgument("-E DC") # set DC filter diff --git a/docu/docs/config.md b/docu/docs/config.md index 0c69065..08a761f 100644 --- a/docu/docs/config.md +++ b/docu/docs/config.md @@ -49,7 +49,7 @@ Mit `PulseAudio` wird ein PulseAudio-Sink an Multimon-NG weitergereicht, z.B. in |error|Frequenz Abweichung in ppm|0| |squelch|Einstellung der Rauschsperre|1| |gain|Verstärkung des Eingangssignals|100| -|fir_size| niedrig leckagearmen Filter, default 0 = off|| +|fir_size| niedrig leckagearmen Filter|None| |rtlPath|Pfad zur rtl_fm Binary|rtl_fm| **Beispiel:** From b66bc14241db23f9e1f561ac3704ee4a9c24e84e Mon Sep 17 00:00:00 2001 From: 1nt4x Date: Thu, 17 Mar 2022 22:20:42 +0100 Subject: [PATCH 21/21] fixed rtl_fm path --- config/client.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/client.yaml b/config/client.yaml index b6e2baf..907e7fc 100644 --- a/config/client.yaml +++ b/config/client.yaml @@ -27,7 +27,7 @@ inputSource: squelch: 1 gain: 100 #fir_size: 0 - rtlPath: /usr/bin/rtl_fm + rtlPath: /usr/local/bin/rtl_fm lineIn: card: 1 device: 0