diff --git a/.github/workflows/run_pytest.yml b/.github/workflows/run_pytest.yml
index 69d1a7d..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.6, 3.7, 3.8, 3.9]
+ python-version: [3.7, 3.8, 3.9, 3.10.2]
runs-on: ${{matrix.os}}
steps:
diff --git a/boswatch/inputSource/sdrInput.py b/boswatch/inputSource/sdrInput.py
index 6b1faf7..3fa2af3 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", 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
sdrProc.addArgument("-s 22050") # bit rate of audio stream
diff --git a/config/client.yaml b/config/client.yaml
index 1550eab..907e7fc 100644
--- a/config/client.yaml
+++ b/config/client.yaml
@@ -26,7 +26,8 @@ inputSource:
error: 0
squelch: 1
gain: 100
- rtlPath: /usr/bin/rtl_fm
+ #fir_size: 0
+ rtlPath: /usr/local/bin/rtl_fm
lineIn:
card: 1
device: 0
diff --git a/docu/docs/config.md b/docu/docs/config.md
index b833101..08a761f 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|None|
|rtlPath|Pfad zur rtl_fm Binary|rtl_fm|
**Beispiel:**
diff --git a/docu/docs/plugin/divera.md b/docu/docs/plugin/divera.md
new file mode 100644
index 0000000..a78c7cb
--- /dev/null
+++ b/docu/docs/plugin/divera.md
@@ -0,0 +1,67 @@
+#
Divera 24/7
+---
+
+## Beschreibung
+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
+- 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/install.sh b/install.sh
index 7c0611c..0e02751 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 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 >> $boswatchpath/install/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
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,24 @@ tput cup 15 5
echo "-> compile multimon-ng................."
mkdir -p build
cd build
-qmake ../multimon-ng.pro >> $boswatchpath/install/setup_log.txt 2>&1
+qmake -qt=qt5 ../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 +191,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 +214,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
diff --git a/plugin/divera.py b/plugin/divera.py
new file mode 100644
index 0000000..b3cc39b
--- /dev/null
+++ b/plugin/divera.py
@@ -0,0 +1,137 @@
+#!/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()
diff --git a/plugin/http.py b/plugin/http.py
index 5d206bc..1af3035 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,9 +62,9 @@ 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):
+ def _makeRequests(self, urls):
"""Parses wildcard urls and handles asynchronus requests
@param urls: array of urls"""
@@ -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