From b5da29d074b3aed58f0638f2da68351b127fdcea Mon Sep 17 00:00:00 2001
From: MrMurdog <156230301+MrMurdog@users.noreply.github.com>
Date: Sun, 14 Jan 2024 20:51:47 +0100
Subject: [PATCH 01/14] Add files via upload
BW2 Port
---
plugin/bosmon.py | 146 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 146 insertions(+)
create mode 100644 plugin/bosmon.py
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
new file mode 100644
index 0000000..69f0fcd
--- /dev/null
+++ b/plugin/bosmon.py
@@ -0,0 +1,146 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+r"""!
+ ____ ____ ______ __ __ __ _____
+ / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
+ / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
+ / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
+/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
+ German BOS Information Script
+ by Bastian Schroll
+
+@file: bosmon.py
+@date: 14.01.2024
+@author: Justin Kurowski | BW2 version: Jens Herrmann
+@description: Bosmon Connector Port form BOSWatch2 to BOSWatch 3
+"""
+import logging
+from plugin.pluginBase import PluginBase
+
+# ###################### #
+# Custom plugin includes #
+
+import requests
+from basicauth import encode
+
+# ###################### #
+
+logging.debug("- %s loaded", __name__)
+
+
+class BoswatchPlugin(PluginBase):
+ r"""!Description of the Plugin"""
+ def __init__(self, config):
+ r"""!Do not change anything here!"""
+ super().__init__(__name__, config) # you can access the config class on 'self.config'
+
+# Auskommentierte sachen folgen noch! #
+
+ def fms(self, bwPacket):
+ r"""!Called on FMS alarm
+
+ @param bwPacket: bwPacket instance
+ Remove if not implemented"""
+ BM_hostname=self.config.get("hostname")
+ BM_port=self.config.get("port")
+ BM_user=self.config.get("user")
+ BM_passwd=self.config.get("passwd")
+ BM_channel=self.config.get("channel")
+
+ get_FMS=bwPacket.get("fms")
+ get_status=bwPacket.get("status")
+ get_direction=bwPacket.get("direction")
+ get_tacticalInfo=bwPacket.get("tacticalInfo")
+
+ self._BosmonRequest_FMS(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo)
+
+ def pocsag(self, bwPacket):
+ r"""!Called on POCSAG alarm
+
+ @param bwPacket: bwPacket instance
+ Remove if not implemented"""
+ BM_hostname=self.config.get("hostname")
+ BM_port=self.config.get("port")
+ BM_user=self.config.get("user")
+ BM_passwd=self.config.get("passwd")
+ BM_channel=self.config.get("channel")
+
+ get_ric=bwPacket.get("ric")
+ get_subric=bwPacket.get("subricText")
+ get_message=bwPacket.get("message")
+
+ self._BosmonRequest_Poc(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_ric, get_subric, get_message)
+
+ def zvei(self, bwPacket):
+ r"""!Called on ZVEI alarm
+
+ @param bwPacket: bwPacket instance
+ Remove if not implemented"""
+ BM_hostname=self.config.get("hostname")
+ BM_port=self.config.get("port")
+ BM_user=self.config.get("user")
+ BM_passwd=self.config.get("passwd")
+ BM_channel=self.config.get("channel")
+
+ get_zvei_adress=bwPacket.get("tone")
+
+ self._BosmonRequest_Zvei(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress)
+
+ def _BosmonRequest_Poc(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_ric, get_subric, get_message):
+
+ url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
+
+ payload = 'type=pocsag&address='+get_ric+'&flags=0&function='+get_subric+'&message='+get_message
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ response = requests.request("POST", url, headers=headers, data=payload)
+
+ def _BosmonRequest_FMS(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo):
+
+ url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
+
+ payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='._getInfo(get_tacticalInfo, get_direction)
+
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ response = requests.request("POST", url, headers=headers, data=payload)
+
+ def _getInfo(self, get_tacticalInfo, get_direction):
+
+ # BosMon-Telegramin expected assembly group, direction and tsi in one field
+ # structure (binary as hex in base10):
+ # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
+ info = 0
+ # assembly group:
+ info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
+ # direction:
+ if get_direction == "1":
+ info = info + 2 # + b0010
+ # tsi:
+ if "IV" in get_tacticalInfo:
+ info = info + 12 # + b1100
+ elif "III" in get_tacticalInfo:
+ info = info + 8 # + b1000
+ elif "II" in get_tacticalInfo:
+ info = info + 4 # + b0100
+ # "I" is nothing to do + b0000
+
+ return info
+
+ def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
+
+ url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
+
+ payload = 'type=pocsag&address='+get_zvei_adress+'&flags=0'
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ response = requests.request("POST", url, headers=headers, data=payload)
\ No newline at end of file
From 0b4dc4330afff0e8aec20bd411e1741348cff220 Mon Sep 17 00:00:00 2001
From: MrMurdog <156230301+MrMurdog@users.noreply.github.com>
Date: Sun, 14 Jan 2024 20:53:31 +0100
Subject: [PATCH 02/14] Bosmon Plugin Doku
---
docu/docs/plugin/bosmon.md | 51 ++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 docu/docs/plugin/bosmon.md
diff --git a/docu/docs/plugin/bosmon.md b/docu/docs/plugin/bosmon.md
new file mode 100644
index 0000000..ca2322c
--- /dev/null
+++ b/docu/docs/plugin/bosmon.md
@@ -0,0 +1,51 @@
+#
Bosmon
+---
+
+## Beschreibung
+Mit diesem Plugin ist es moeglich, die empfangenen Daten an Bosmon weiter zu leiten.
+
+## Unterstütze Alarmtypen
+- Fms ***untested***
+- Pocsag
+- Zvei ***untested***
+
+## Resource
+`Bosmon Webserver & Networkchannel`
+
+## Konfiguration
+|Feld|Beschreibung|Default|
+|----|------------|-------|
+|fms|Zugangsdaten, um sich mit der Bosmon Instanz zu verbinden||
+|pocsag|Zugangsdaten, um sich mit der Bosmon Instanz zu verbinden||
+|zvei|Zugangsdaten, um sich mit der Bosmon Instanz zu verbinden||
+
+**Beispiel:**
+```yaml
+ - type: plugin
+ name: Bosmon Plugin
+ res: bosmon
+ config:
+ hostname: "IP Oder Hostname"
+ port: "8080"
+ user: "test"
+ passwd: "123"
+ channel: "channelname"
+
+```
+
+---
+## Hilfreiche Anleitungen seitens Bosmon
+
+| https://www.bosmon.de/forum/viewtopic.php?p=21099#p21099| Anleitung zur Verbindung mit Bosmon |
+|--|--|
+| | |
+
+
+---
+## Modul Abhängigkeiten
+- keine
+
+---
+## Externe Abhängigkeiten
+- requests
+- basicauth
From b3f3b3b4db00a6bd89b80ab27658c873084760ba Mon Sep 17 00:00:00 2001
From: MrMurdog <156230301+MrMurdog@users.noreply.github.com>
Date: Sun, 14 Jan 2024 20:58:08 +0100
Subject: [PATCH 03/14] added Bosmon.py Requirement
---
requirements.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/requirements.txt b/requirements.txt
index 0cca07d..81d8f49 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -12,3 +12,4 @@ flake8==4.0.1
pytest-flake8
pytest-flakes
pytest-randomly
+basicauth==1.0.0
From fc415d02da28954ca066766218466bab3143a668 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Sun, 14 Jan 2024 23:22:25 +0100
Subject: [PATCH 04/14] Neue methode zum testen
---
plugin/bosmon aiohttp.py | 162 ++++++++++++++++++++++++++++++++++++++
1 file changed, 162 insertions(+)
create mode 100644 plugin/bosmon aiohttp.py
diff --git a/plugin/bosmon aiohttp.py b/plugin/bosmon aiohttp.py
new file mode 100644
index 0000000..0b5d71b
--- /dev/null
+++ b/plugin/bosmon aiohttp.py
@@ -0,0 +1,162 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+r"""!
+ ____ ____ ______ __ __ __ _____
+ / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
+ / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
+ / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
+/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
+ German BOS Information Script
+ by Bastian Schroll
+
+@file: bosmon.py
+@date: 14.01.2024
+@author: Justin Kurowski | BW2 version: Jens Herrmann
+@description: Bosmon Connector Port form BOSWatch2 to BOSWatch 3
+"""
+import logging
+from plugin.pluginBase import PluginBase
+
+# ###################### #
+# Custom plugin includes #
+
+import requests
+from basicauth import encode
+import aiohttp
+
+# ###################### #
+
+logging.debug("- %s loaded", __name__)
+
+
+class BoswatchPlugin(PluginBase):
+ r"""!Description of the Plugin"""
+ def __init__(self, config):
+ r"""!Do not change anything here!"""
+ super().__init__(__name__, config) # you can access the config class on 'self.config'
+
+# Auskommentierte sachen folgen noch! #
+
+ def fms(self, bwPacket):
+ r"""!Called on FMS alarm
+
+ @param bwPacket: bwPacket instance
+ Remove if not implemented"""
+ BM_hostname=self.config.get("hostname")
+ BM_port=self.config.get("port")
+ BM_user=self.config.get("user")
+ BM_passwd=self.config.get("passwd")
+ BM_channel=self.config.get("channel")
+
+ get_FMS=bwPacket.get("fms")
+ get_status=bwPacket.get("status")
+ get_direction=bwPacket.get("direction")
+ get_tacticalInfo=bwPacket.get("tacticalInfo")
+
+ self._BosmonRequest_FMS(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo)
+
+ def pocsag(self, bwPacket):
+ r"""!Called on POCSAG alarm
+
+ @param bwPacket: bwPacket instance
+ Remove if not implemented"""
+ BM_hostname=self.config.get("hostname")
+ BM_port=self.config.get("port")
+ BM_user=self.config.get("user")
+ BM_passwd=self.config.get("passwd")
+ BM_channel=self.config.get("channel")
+
+ get_ric=bwPacket.get("ric")
+ get_subric=bwPacket.get("subricText")
+ get_message=bwPacket.get("message")
+
+ self._BosmonRequest_Poc(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_ric, get_subric, get_message)
+
+ def zvei(self, bwPacket):
+ r"""!Called on ZVEI alarm
+
+ @param bwPacket: bwPacket instance
+ Remove if not implemented"""
+ BM_hostname=self.config.get("hostname")
+ BM_port=self.config.get("port")
+ BM_user=self.config.get("user")
+ BM_passwd=self.config.get("passwd")
+ BM_channel=self.config.get("channel")
+
+ get_zvei_adress=bwPacket.get("tone")
+
+ self._BosmonRequest_Zvei(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress)
+
+ async def _BosmonRequest_Poc(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_ric, get_subric, get_message):
+
+ url = BM_hostname+":"+BM_port+"/telegramin/"+BM_channel+"/input.xml"
+
+ payload = 'type=pocsag&address='+get_ric+'&flags=0&function='+get_subric+'&message='+get_message
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ async with aiohttp.ClientSession() as session:
+ async with session.post(url, data=payload, headers=headers) as response:
+ response_text = await response.text()
+ logging.exception('Bosmon Plugin: '+response_text)
+
+ response = requests.request("POST", url, headers=headers, data=payload)
+
+ async def _BosmonRequest_FMS(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo):
+
+ url = BM_hostname+":"+BM_port+"/telegramin/"+BM_channel+"/input.xml"
+
+ payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='._getInfo(get_tacticalInfo, get_direction)
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ async with aiohttp.ClientSession() as session:
+ async with session.post(url, data=payload, headers=headers) as response:
+ response_text = await response.text()
+ logging.exception('Bosmon Plugin: '+response_text)
+
+ response = requests.request("POST", url, headers=headers, data=payload)
+
+ def _getInfo(self, get_tacticalInfo, get_direction):
+
+ # BosMon-Telegramin expected assembly group, direction and tsi in one field
+ # structure (binary as hex in base10):
+ # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
+ info = 0
+ # assembly group:
+ info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
+ # direction:
+ if get_direction == "1":
+ info = info + 2 # + b0010
+ # tsi:
+ if "IV" in get_tacticalInfo:
+ info = info + 12 # + b1100
+ elif "III" in get_tacticalInfo:
+ info = info + 8 # + b1000
+ elif "II" in get_tacticalInfo:
+ info = info + 4 # + b0100
+ # "I" is nothing to do + b0000
+
+ return info
+
+
+ async def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
+
+ url = BM_hostname+":"+BM_port+"/telegramin/"+BM_channel+"/input.xml"
+
+ payload = 'type=pocsag&address='+get_zvei_adress+'&flags=0'
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ async with aiohttp.ClientSession() as session:
+ async with session.post(url, data=payload, headers=headers) as response:
+ response_text = await response.text()
+ logging.exception('Bosmon Plugin: '+response_text)
+
+ response = requests.request("POST", url, headers=headers, data=payload)
\ No newline at end of file
From 68deba25cc5e9ef12eae5e7f8e515f5d7328569c Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Sun, 14 Jan 2024 23:57:05 +0100
Subject: [PATCH 05/14] Renamed
---
plugin/{bosmon aiohttp.py => bosmon_aiohttp.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename plugin/{bosmon aiohttp.py => bosmon_aiohttp.py} (100%)
diff --git a/plugin/bosmon aiohttp.py b/plugin/bosmon_aiohttp.py
similarity index 100%
rename from plugin/bosmon aiohttp.py
rename to plugin/bosmon_aiohttp.py
From d1dd5cc7dd2a63507d6d096d1467d80e59995000 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Mon, 15 Jan 2024 10:00:27 +0100
Subject: [PATCH 06/14] =?UTF-8?q?Kleinere=20=C3=A4nderungen?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/bosmon_aiohttp.py | 81 +++++++++-------------------------------
1 file changed, 18 insertions(+), 63 deletions(-)
diff --git a/plugin/bosmon_aiohttp.py b/plugin/bosmon_aiohttp.py
index 0b5d71b..97ad2a4 100644
--- a/plugin/bosmon_aiohttp.py
+++ b/plugin/bosmon_aiohttp.py
@@ -20,7 +20,7 @@ from plugin.pluginBase import PluginBase
# ###################### #
# Custom plugin includes #
-import requests
+import asyncio
from basicauth import encode
import aiohttp
@@ -66,11 +66,10 @@ class BoswatchPlugin(PluginBase):
BM_passwd=self.config.get("passwd")
BM_channel=self.config.get("channel")
- get_ric=bwPacket.get("ric")
- get_subric=bwPacket.get("subricText")
- get_message=bwPacket.get("message")
+ the_request = 'type=pocsag&address='+bwPacket.get("ric")+'&flags=0&function='+bwPacket.get("subricText")+'&message='+bwPacket.get("message")
+
+ self._post_Request(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, the_request)
- self._BosmonRequest_Poc(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_ric, get_subric, get_message)
def zvei(self, bwPacket):
r"""!Called on ZVEI alarm
@@ -87,11 +86,11 @@ class BoswatchPlugin(PluginBase):
self._BosmonRequest_Zvei(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress)
- async def _BosmonRequest_Poc(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_ric, get_subric, get_message):
+ async def _post_Request(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, the_request):
- url = BM_hostname+":"+BM_port+"/telegramin/"+BM_channel+"/input.xml"
+ url = BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
- payload = 'type=pocsag&address='+get_ric+'&flags=0&function='+get_subric+'&message='+get_message
+ payload = the_request
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': encode(BM_user, BM_passwd)
@@ -100,63 +99,19 @@ class BoswatchPlugin(PluginBase):
async with aiohttp.ClientSession() as session:
async with session.post(url, data=payload, headers=headers) as response:
response_text = await response.text()
- logging.exception('Bosmon Plugin: '+response_text)
+
+ asyncio.ensure_future(self._fetch(url, session))
- response = requests.request("POST", url, headers=headers, data=payload)
+ logging.exception(response_text)
- async def _BosmonRequest_FMS(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo):
-
- url = BM_hostname+":"+BM_port+"/telegramin/"+BM_channel+"/input.xml"
+ await response_text
- payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='._getInfo(get_tacticalInfo, get_direction)
- headers = {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Authorization': encode(BM_user, BM_passwd)
- }
+ async def _fetch(self, url, session):
+ """Fetches requests
- async with aiohttp.ClientSession() as session:
- async with session.post(url, data=payload, headers=headers) as response:
- response_text = await response.text()
- logging.exception('Bosmon Plugin: '+response_text)
+ @param url: url
- response = requests.request("POST", url, headers=headers, data=payload)
-
- def _getInfo(self, get_tacticalInfo, get_direction):
-
- # BosMon-Telegramin expected assembly group, direction and tsi in one field
- # structure (binary as hex in base10):
- # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
- info = 0
- # assembly group:
- info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
- # direction:
- if get_direction == "1":
- info = info + 2 # + b0010
- # tsi:
- if "IV" in get_tacticalInfo:
- info = info + 12 # + b1100
- elif "III" in get_tacticalInfo:
- info = info + 8 # + b1000
- elif "II" in get_tacticalInfo:
- info = info + 4 # + b0100
- # "I" is nothing to do + b0000
-
- return info
-
-
- async def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
-
- url = BM_hostname+":"+BM_port+"/telegramin/"+BM_channel+"/input.xml"
-
- payload = 'type=pocsag&address='+get_zvei_adress+'&flags=0'
- headers = {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Authorization': encode(BM_user, BM_passwd)
- }
-
- async with aiohttp.ClientSession() as session:
- async with session.post(url, data=payload, headers=headers) as response:
- response_text = await response.text()
- logging.exception('Bosmon Plugin: '+response_text)
-
- response = requests.request("POST", url, headers=headers, data=payload)
\ No newline at end of file
+ @param session: Clientsession instance"""
+ async with session.get(url) as response:
+ logging.info("{} returned [{}]".format(response.url, response.status))
+ return await response.read()
\ No newline at end of file
From 1a080286b3b30e24639917c3aaaab1aafa5db005 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Mon, 15 Jan 2024 10:09:43 +0100
Subject: [PATCH 07/14] =?UTF-8?q?=C3=A4nderung?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/bosmon_aiohttp.py | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/plugin/bosmon_aiohttp.py b/plugin/bosmon_aiohttp.py
index 97ad2a4..503dfe6 100644
--- a/plugin/bosmon_aiohttp.py
+++ b/plugin/bosmon_aiohttp.py
@@ -99,19 +99,12 @@ class BoswatchPlugin(PluginBase):
async with aiohttp.ClientSession() as session:
async with session.post(url, data=payload, headers=headers) as response:
response_text = await response.text()
-
- asyncio.ensure_future(self._fetch(url, session))
-
+
logging.exception(response_text)
- await response_text
-
- async def _fetch(self, url, session):
- """Fetches requests
-
- @param url: url
-
- @param session: Clientsession instance"""
- async with session.get(url) as response:
- logging.info("{} returned [{}]".format(response.url, response.status))
- return await response.read()
\ No newline at end of file
+ def teardown(self):
+ r"""!Called after alarm
+ Remove if not implemented"""
+
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(_post_Request())
\ No newline at end of file
From 1d48501ded12b08a4a77f278e3d55e7b64842f1b Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Mon, 15 Jan 2024 11:06:27 +0100
Subject: [PATCH 08/14] Removed Testfile for commit
---
plugin/bosmon_aiohttp.py | 110 ---------------------------------------
1 file changed, 110 deletions(-)
delete mode 100644 plugin/bosmon_aiohttp.py
diff --git a/plugin/bosmon_aiohttp.py b/plugin/bosmon_aiohttp.py
deleted file mode 100644
index 503dfe6..0000000
--- a/plugin/bosmon_aiohttp.py
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-r"""!
- ____ ____ ______ __ __ __ _____
- / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
- / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
- / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
-/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
- German BOS Information Script
- by Bastian Schroll
-
-@file: bosmon.py
-@date: 14.01.2024
-@author: Justin Kurowski | BW2 version: Jens Herrmann
-@description: Bosmon Connector Port form BOSWatch2 to BOSWatch 3
-"""
-import logging
-from plugin.pluginBase import PluginBase
-
-# ###################### #
-# Custom plugin includes #
-
-import asyncio
-from basicauth import encode
-import aiohttp
-
-# ###################### #
-
-logging.debug("- %s loaded", __name__)
-
-
-class BoswatchPlugin(PluginBase):
- r"""!Description of the Plugin"""
- def __init__(self, config):
- r"""!Do not change anything here!"""
- super().__init__(__name__, config) # you can access the config class on 'self.config'
-
-# Auskommentierte sachen folgen noch! #
-
- def fms(self, bwPacket):
- r"""!Called on FMS alarm
-
- @param bwPacket: bwPacket instance
- Remove if not implemented"""
- BM_hostname=self.config.get("hostname")
- BM_port=self.config.get("port")
- BM_user=self.config.get("user")
- BM_passwd=self.config.get("passwd")
- BM_channel=self.config.get("channel")
-
- get_FMS=bwPacket.get("fms")
- get_status=bwPacket.get("status")
- get_direction=bwPacket.get("direction")
- get_tacticalInfo=bwPacket.get("tacticalInfo")
-
- self._BosmonRequest_FMS(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo)
-
- def pocsag(self, bwPacket):
- r"""!Called on POCSAG alarm
-
- @param bwPacket: bwPacket instance
- Remove if not implemented"""
- BM_hostname=self.config.get("hostname")
- BM_port=self.config.get("port")
- BM_user=self.config.get("user")
- BM_passwd=self.config.get("passwd")
- BM_channel=self.config.get("channel")
-
- the_request = 'type=pocsag&address='+bwPacket.get("ric")+'&flags=0&function='+bwPacket.get("subricText")+'&message='+bwPacket.get("message")
-
- self._post_Request(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, the_request)
-
-
- def zvei(self, bwPacket):
- r"""!Called on ZVEI alarm
-
- @param bwPacket: bwPacket instance
- Remove if not implemented"""
- BM_hostname=self.config.get("hostname")
- BM_port=self.config.get("port")
- BM_user=self.config.get("user")
- BM_passwd=self.config.get("passwd")
- BM_channel=self.config.get("channel")
-
- get_zvei_adress=bwPacket.get("tone")
-
- self._BosmonRequest_Zvei(BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress)
-
- async def _post_Request(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, the_request):
-
- url = BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
-
- payload = the_request
- headers = {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Authorization': encode(BM_user, BM_passwd)
- }
-
- async with aiohttp.ClientSession() as session:
- async with session.post(url, data=payload, headers=headers) as response:
- response_text = await response.text()
-
- logging.exception(response_text)
-
- def teardown(self):
- r"""!Called after alarm
- Remove if not implemented"""
-
- loop = asyncio.get_event_loop()
- loop.run_until_complete(_post_Request())
\ No newline at end of file
From 1ffa137af4be2fdbf8dfb7981bc7025b0c03e22c Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Mon, 15 Jan 2024 11:34:32 +0100
Subject: [PATCH 09/14] Fehlerbehebung FMS
---
plugin/bosmon.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
index 69f0fcd..0d63e86 100644
--- a/plugin/bosmon.py
+++ b/plugin/bosmon.py
@@ -111,7 +111,7 @@ class BoswatchPlugin(PluginBase):
response = requests.request("POST", url, headers=headers, data=payload)
- def _getInfo(self, get_tacticalInfo, get_direction):
+ def _getInfo(get_tacticalInfo, get_direction):
# BosMon-Telegramin expected assembly group, direction and tsi in one field
# structure (binary as hex in base10):
From 4cffe7aeb8728e73bf3da5114d1200eac1db8151 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Wed, 17 Jan 2024 09:40:21 +0100
Subject: [PATCH 10/14] Versuch FMS fix
---
plugin/bosmon.py | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
index 0d63e86..ec01cb2 100644
--- a/plugin/bosmon.py
+++ b/plugin/bosmon.py
@@ -96,7 +96,7 @@ class BoswatchPlugin(PluginBase):
'Authorization': encode(BM_user, BM_passwd)
}
- response = requests.request("POST", url, headers=headers, data=payload)
+ requests.request("POST", url, headers=headers, data=payload)
def _BosmonRequest_FMS(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo):
@@ -109,9 +109,23 @@ class BoswatchPlugin(PluginBase):
'Authorization': encode(BM_user, BM_passwd)
}
- response = requests.request("POST", url, headers=headers, data=payload)
+ requests.request("POST", url, headers=headers, data=payload)
- def _getInfo(get_tacticalInfo, get_direction):
+
+
+ def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
+
+ url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
+
+ payload = 'type=pocsag&address='+get_zvei_adress+'&flags=0'
+ headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': encode(BM_user, BM_passwd)
+ }
+
+ requests.request("POST", url, headers=headers, data=payload)
+
+ def _getInfo(get_tacticalInfo, get_direction):
# BosMon-Telegramin expected assembly group, direction and tsi in one field
# structure (binary as hex in base10):
@@ -131,16 +145,4 @@ class BoswatchPlugin(PluginBase):
info = info + 4 # + b0100
# "I" is nothing to do + b0000
- return info
-
- def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
-
- url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
-
- payload = 'type=pocsag&address='+get_zvei_adress+'&flags=0'
- headers = {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Authorization': encode(BM_user, BM_passwd)
- }
-
- response = requests.request("POST", url, headers=headers, data=payload)
\ No newline at end of file
+ return info
\ No newline at end of file
From 13c4ee0764463a876e269e5c8d803520d3fa87a2 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Wed, 17 Jan 2024 09:44:39 +0100
Subject: [PATCH 11/14] Zweiter Versuch FMS Debug
---
plugin/bosmon.py | 46 ++++++++++++++++++++++------------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
index ec01cb2..b07008d 100644
--- a/plugin/bosmon.py
+++ b/plugin/bosmon.py
@@ -111,7 +111,27 @@ class BoswatchPlugin(PluginBase):
requests.request("POST", url, headers=headers, data=payload)
-
+ def _getInfo(get_tacticalInfo2, get_direction2):
+
+ # BosMon-Telegramin expected assembly group, direction and tsi in one field
+ # structure (binary as hex in base10):
+ # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
+ info = 0
+ # assembly group:
+ info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
+ # direction:
+ if get_direction2 == "1":
+ info = info + 2 # + b0010
+ # tsi:
+ if "IV" in get_tacticalInfo2:
+ info = info + 12 # + b1100
+ elif "III" in get_tacticalInfo2:
+ info = info + 8 # + b1000
+ elif "II" in get_tacticalInfo2:
+ info = info + 4 # + b0100
+ # "I" is nothing to do + b0000
+
+ return info
def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
@@ -123,26 +143,4 @@ class BoswatchPlugin(PluginBase):
'Authorization': encode(BM_user, BM_passwd)
}
- requests.request("POST", url, headers=headers, data=payload)
-
- def _getInfo(get_tacticalInfo, get_direction):
-
- # BosMon-Telegramin expected assembly group, direction and tsi in one field
- # structure (binary as hex in base10):
- # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
- info = 0
- # assembly group:
- info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
- # direction:
- if get_direction == "1":
- info = info + 2 # + b0010
- # tsi:
- if "IV" in get_tacticalInfo:
- info = info + 12 # + b1100
- elif "III" in get_tacticalInfo:
- info = info + 8 # + b1000
- elif "II" in get_tacticalInfo:
- info = info + 4 # + b0100
- # "I" is nothing to do + b0000
-
- return info
\ No newline at end of file
+ requests.request("POST", url, headers=headers, data=payload)
\ No newline at end of file
From 479b8c8deb3ead241d9da06770d0c716e26eaf58 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Wed, 17 Jan 2024 09:45:52 +0100
Subject: [PATCH 12/14] 3.Versuch
---
plugin/bosmon.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
index b07008d..25a6b40 100644
--- a/plugin/bosmon.py
+++ b/plugin/bosmon.py
@@ -102,7 +102,7 @@ class BoswatchPlugin(PluginBase):
url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
- payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='._getInfo(get_tacticalInfo, get_direction)
+ payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='+_getInfo(get_tacticalInfo, get_direction)
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
From 219e6830ea346e5b909e312928d072f0fd5792e5 Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Wed, 17 Jan 2024 10:26:53 +0100
Subject: [PATCH 13/14] =?UTF-8?q?ab=C3=A4nderung=20Daten=C3=A4nderung=20FM?=
=?UTF-8?q?S=20modul?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/bosmon.py | 45 ++++++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
index 25a6b40..8fac542 100644
--- a/plugin/bosmon.py
+++ b/plugin/bosmon.py
@@ -100,9 +100,29 @@ class BoswatchPlugin(PluginBase):
def _BosmonRequest_FMS(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_FMS, get_status, get_direction, get_tacticalInfo):
+
+ # BosMon-Telegramin expected assembly group, direction and tsi in one field
+ # structure (binary as hex in base10):
+ # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
+ info = 0
+ # assembly group:
+ info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
+ # direction:
+ if get_direction == "1":
+ info = info + 2 # + b0010
+ # tsi:
+ if "IV" in get_tacticalInfo:
+ info = info + 12 # + b1100
+ elif "III" in get_tacticalInfo:
+ info = info + 8 # + b1000
+ elif "II" in get_tacticalInfo:
+ info = info + 4 # + b0100
+ # "I" is nothing to do + b0000
+
+
url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
- payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='+_getInfo(get_tacticalInfo, get_direction)
+ payload = 'type=fms&address='+get_FMS+'&flags=0&status='+get_status+'&info='+info
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
@@ -110,28 +130,7 @@ class BoswatchPlugin(PluginBase):
}
requests.request("POST", url, headers=headers, data=payload)
-
- def _getInfo(get_tacticalInfo2, get_direction2):
-
- # BosMon-Telegramin expected assembly group, direction and tsi in one field
- # structure (binary as hex in base10):
- # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
- info = 0
- # assembly group:
- info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
- # direction:
- if get_direction2 == "1":
- info = info + 2 # + b0010
- # tsi:
- if "IV" in get_tacticalInfo2:
- info = info + 12 # + b1100
- elif "III" in get_tacticalInfo2:
- info = info + 8 # + b1000
- elif "II" in get_tacticalInfo2:
- info = info + 4 # + b0100
- # "I" is nothing to do + b0000
-
- return info
+
def _BosmonRequest_Zvei(self, BM_hostname, BM_port, BM_user, BM_passwd, BM_channel, get_zvei_adress):
From 7bb1488157443c48ca12fba59745c7d0e50b70fc Mon Sep 17 00:00:00 2001
From: MrMurdog
Date: Wed, 17 Jan 2024 10:43:50 +0100
Subject: [PATCH 14/14] Zvei fehlerbehebung
---
plugin/bosmon.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin/bosmon.py b/plugin/bosmon.py
index 8fac542..1c0750c 100644
--- a/plugin/bosmon.py
+++ b/plugin/bosmon.py
@@ -136,7 +136,7 @@ class BoswatchPlugin(PluginBase):
url = 'http://'+BM_hostname+':'+BM_port+'/telegramin/'+BM_channel+'/input.xml'
- payload = 'type=pocsag&address='+get_zvei_adress+'&flags=0'
+ payload = 'type=zvei&address='+get_zvei_adress+'&flags=0'
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': encode(BM_user, BM_passwd)