From f31532d79a5f1e146751b2df25700382aa3373b3 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:49:36 +0200 Subject: [PATCH 01/45] Add files via upload Express-Alarm function added --- config.template.ini | 511 ++++++++++++++++++++++++++++++++++++++++++++ expressAlarm.py | 65 ++++++ poc.py | 156 ++++++++++++++ testdata.txt | 136 ++++++++++++ 4 files changed, 868 insertions(+) create mode 100644 config.template.ini create mode 100644 expressAlarm.py create mode 100644 poc.py create mode 100644 testdata.txt diff --git a/config.template.ini b/config.template.ini new file mode 100644 index 00000000..f3373f33 --- /dev/null +++ b/config.template.ini @@ -0,0 +1,511 @@ +######################## +# BOSWatch Config File # +######################## + +[BOSWatch] +# set loglevel for logfile +# 10 = debug +# 20 = info +# 30 = warning +# 40 = error +# 50 = critical +loglevel = 10 + +# BOSWatch uses a rotating logfile +# Rotating is at midnight +# You can set the backupCount here +# backupCount = 7 (keeps logfiles for 7 days) +backupCount = 7 + +# if you want to start BOSWatch as a daemon with rc2.d, +# you have to set the path to rtl_fm and multimon-ng ! +# both pathes have to end with an / +#rtl_path = /usr/local/bin/ +#multimon_path = /usr/local/bin/ + +# if you are using many plugins or plugins with a long execution time +# you can execute them in an asynchronous manner +# It must be pointed out that enabling (0|1) this consumes time, +# so don't use it for one rapid plugin +processAlarmAsync = 0 + +# Using RegEx-filter (0 - off | 1 - on) +# filter-configuration in section [Filters] +useRegExFilter = 0 + +# for double check save the last n IDs +# it is used in combination with double_ignore_time +# 1 is required if you want to use the double alarm filter +doubleFilter_ignore_entries = 10 + +# time to ignore same alarm (only ID is checked) (sec) +doubleFilter_ignore_time = 5 + +# ignore msg is only usefull for POCSAG (0 - off | 1 - on) +# 0: double check ignores the msg-text (only check ID + function) +# 1: if you want to differentiate between with/ without msg +# f.e. if they use quick-alarm (without text, then same RIC with msg) +# you will get more then one alarm anyway if the msg is different (receiving-problems) +doubleFilter_check_msg = 0 + +# writes the multimon-ng raw data stream into a text file named mm_raw.txt +writeMultimonRaw = 0 + +[NMAHandler] +# you can use a logging handler for sending logging records to NotifyMyAndroid +# enableHandler (0|1) will enable the NMA handler +enableHandler = 0 + +# loglevel for NMAHandler (see BOSWatch loglevel description) +loglevel = 50 + +# logging record will send to APIKey +APIKey = + +# you can change the name of the application (default: BOSWatch) +# (f.e. if you use more than one instance of BOSWatch) +appName = BOSWatch + + +[FMS] +# look-up-table for adding a description +# using description (0 - off | 1 - on) +# descriptions are loaded from csv/fms.csv +idDescribed = 0 + +# Check for correct CRC-information is provided by multimon-ng +# As this seems to be incorrect in many cases it might be useful to disable this +# (0 - off | 1 - on) +# Better use RegEX to verify the correct data +checkCRC = 0 + +[ZVEI] +# look-up-table for adding a description +# using description (0 - off | 1 - on) +# descriptions are loaded from csv/zvei.csv +idDescribed = 0 + +[POC] +# some very simple filters: +# Allow only this RICs (empty: allow all, separator ",") +# f.e.: allow_ric = 1234566,1234567,1234568 +allow_ric = + +# Deny this RICs (empty: allow all, separator ",") +# f.e.: deny_ric = 1234566,1234567,1234568 +deny_ric = + +# start and end of an allowed filter range +filter_range_start = 0000000 +filter_range_end = 9999999 + +# look-up-table for adding a description +# using description (0 - off | 1 - on) +# descriptions are loaded from csv/poc.csv +idDescribed = 0 + +# Static Massages for Subrics. +rica = Feuer +ricb = TH +ricc = AGT +ricd = Unwetter + +# RIC for net identification +# Usually sent periodically, separated by comma +netIdent_ric = 0174760, 1398098 + +[ExpressAlarm] +# Using Express-Alarm (0 - off | 1 - on) +expressAlarm = 0 + +# time limit for alarms that do not belong to the Express-Alarm sequence +expressAlarm_ignore_time = 15 + +# Express-Alarm delimiter RIC +expressAlarm_delimiter_ric = + +# Express-Alarm RIC that is used to send the message +expressAlarm_ric = + +[Filters] +# RegEX Filter Configuration +# http://www.regexr.com/ - RegEX Test Tool an Documentation +# No Filter for a Typ/Plugin Combination = all Data pass +# INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX +# TYP = the Data Typ (FMS|ZVEI|POC) +# DATAFIELD = the field of the Data Array (see readme.md in plugin folder) +# PLUGIN = the name of the Plugin to call with this Filter (* for all) +# FREQUENZ = the Frequenz to use the Filter (for more SDR Sticks (* for all)) +# REGEX = the RegEX + +# only ZVEI to all plugins with 25### at 85.5MHz +#testfilter = ZVEI;zvei;*;85500000;25[0-9]{3} + +# only POCSAG to MySQL with the text "ALARM:" in the message +#pocTest = POC;msg;MySQL;*;ALARM: + + +[Plugins] +# turn the plugins on or off (0 - off | 1 - on) +MySQL = 0 +httpRequest = 0 +eMail = 0 +BosMon = 0 +firEmergency = 0 +jsonSocket = 0 +notifyMyAndroid = 0 +SMS = 0 +Sms77 = 0 +FFAgent = 0 +Pushover = 0 +Telegram = 0 +yowsup = 0 + +# for developing template-module +template = 0 + + +[MySQL] +# MySQL configuration +dbserver = localhost +dbuser = boswatch +dbpassword = root +database = boswatch + +# tables in the database +tableFMS = bos_fms +tableZVEI = bos_zvei +tablePOC = bos_pocsag +tableSIG = bos_signal + + +[httpRequest] +# example URL http://example.com/remote.php?DESCR=%DESCR% + +# multiple URLs can be separated by comma + +# you can use the following wildcards in your URL as GET params: +# http://en.wikipedia.org/wiki/Query_string + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description from csv-file +# %TIME% = Time (by script) +# %DATE% = Date (by script) +#fms_url = http://www.google.de?code=%FMS%&stat=%STATUS% +fms_url = + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description from csv-file +# %TIME% = Time (by script) +# %DATE% = Date (by script) +#zvei_url = http://www.google.de?zvei=%ZVEI% +zvei_url = + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric as character (a-d) +# %FUNCTEXT% = POCSAG function/Subric static massage definded in POCSAG section +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description from csv-file +# %TIME% = Time (by script) +# %DATE% = Date (by script) +#poc_url = http://www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% +poc_url = + + +[eMail] +# SMTP-Server +smtp_server = localhost +# Port of SMTP-server (default: ) +smtp_port = +# use tls for connection (0|1) +tls = 0 +# Use this, when SMTP-server has restricted access +user = +password = + +# Parameters for Alarm-Msg: +# "to" can be more than one address, comma separated +from = local@localhost +to = user@irgendwo, user2@woanders + +# Priority of the eMail: +# normal|urgent|non-urgent +priority = urgent + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) +fms_subject = FMS: %FMS% +fms_message = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) +zvei_subject = Alarm: %ZVEI% +zvei_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %FUNCTEXT% = POCSAG function/Subric static massage definded in POCSAG section +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) +poc_subject = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR% +poc_message = %DATE% %TIME% - %DESCR%: %MSG% + + +[BosMon] +# IP-address of the server (without http://) +# actually no SSL-support +bosmon_server = 192.168.0.1 +bosmon_port = 80 + +# channel-name of type "Web-Telegramm" +bosmon_channel = channel + +# Use this, when BosMon has restricted access +bosmon_user = +bosmon_password = + + +[firEmergency] +# firEmergency configuration +firserver = localhost +firport = 9001 + + +[jsonSocket] +# Protocol for socket (TCP|UDP) +protocol = UDP +# IP-address of the server (without http://) +server = 192.168.0.1 +port = 8888 + + +[notifyMyAndroid] +# APIKey given from notifyMyAndroid +APIKey = + +# Priority goes from -2 (lowest) to 2 (highest). The default priority is 0 (normal) +priority = 0 + +# You can change the name of the application (default: BOSWatch) +# (f.e. if you use more than one instance of BOSWatch) +appName = BOSWatch + +# instead of a given APIKey/priority you could import them by a csv-file (0|1) +# APIKey and priority above will be ignored, if you use a csv +# configuration loaded from csv/nma.csv +usecsv = 0 + + +[SMS] +# be aware that you need 'gammu' installed and running +# at least you need an UMTS-stick which is supported by 'gammu' + +quantity = 1 +# be sensitive to single RIC +ric1 = 1234567 + +# but you can watch several subrics, comma-separated +subric1 = a, b + +# a single cellphone-number +phonenumber1 = 0160321654987 + +# and the text for the sms +# ! DO NOT USE ANY UMLAUT ! +text1 = Rueckruf Leitstelle! + + +[Sms77] +# SMS77 configuration +# Login Username +user = + +# Password or API Key +password = + +# Receiver singlenumber or groupname from adressbook +to = + +# Sender number or name +from = + +# Type of Message (see https://www.sms77.de/funktionen/smstypen and https://www.sms77.de/funktionen/http-api) +type = quality + + +[FFAgent] +# set live mode (0/1) +live = 0 + +# send messages as type test (0/1) +test = 1 + +# path to server certificate file +serverCertFile = + +# path to client certificate file (LIVE) +clientCertFile = + +# path to client certificate password file (LIVE) +clientCertPass = + +# webapi token +webApiToken = + +# webapi key +webApiKey = + +# access token +accessToken = + +# selective Call Code +selectiveCallCode = + + +[Pushover] +# Pushover API Key +api_key = + +# Pushover Userkey or Groupkey to receive message +user_key = + +# Title of the message +title = BOSWatch Message + +# Adapt Pocsag Subric (a,b,c,d) to Pushover Priorities (see https://pushover.net/api#priority) +SubA = 0 +SubB = 2 +SubC = 1 +SubD = 0 + +# how often should Pushover re-alert in seconds (emergency-messages) +retry = 30 + +# when should Pushover stop to re-alert in seconds (emergency-messages) +expire = 90 + +# use HTML in messages (0/1) +html = 1 + + +[Telegram] +# This is your unique BOT token. You will get it from the BotFather once you have created your BOT. +BOTTokenAPIKey = +# Create a group chat with your BOT and enter the chat ID here. +# The plugin will send messages as your BOT and post everything in this group chat. +BOTChatIDAPIKey = +# The plugin can extract a location from the POCSAG message. +# However, this will be done for the following RIC only (7 digits e.g. 0012345). +RICforLocationAPIKey = +# This is your Google API key. +# Required if you want to create a map based on location information received with the above RIC. +GoogleAPIKey = + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +FMS_message = %DATE% %TIME%: %FMS% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +ZVEI_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +POC_message = %MSG% + + +[yowsup] +# number or chat-number who whants to become the news +empfaenger = +# WhatsApp-number of that the news comes +sender = +# password from this number +password= + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +fms_message = %DATE% %TIME%: %FMS% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +zvei_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +poc_message = %MSG% + + +##################### +##### Not ready yet # +##################### + +[template] +test1 = testString +test2 = 123456 diff --git a/expressAlarm.py b/expressAlarm.py new file mode 100644 index 00000000..03ca5d13 --- /dev/null +++ b/expressAlarm.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +expressAlarm is the function to enable BOSwatch to deal with Swissfone Express-Alarm + +@author: Fabian Kessler + +@requires: Configuration has to be set in the config.ini +""" + +import logging # Global logger +import time # timestamp for expressAlarm + +from includes import globalVars # Global variables + +expressList = [] + +def newEntryExpressList(eatyp, eapoc_id, eapoc_sub, eapoc_text): + """ + add entry to express alarm list and remove old entries + + @return: nothing + """ + global expressList + tmpexpressList = [] + timestamp = int(time.time()) + # Express-Alarm processing if enabled and delimiter RIC has been received + if eapoc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric"): + expressList = [] + logging.debug("Express-Alarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) + else: + expressList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) + logging.debug("Added %s %s %s to expressList", eapoc_id, eapoc_sub, eapoc_text) + # check for old entries in expressList + for i in range(len(expressList)): + # we have to remove entries older than timestamp - ignore time + if int(expressList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): + tmpexpressList.append(expressList[i]) + expressList = tmpexpressList + + +def expressAlarmExec(typ, freq, data): + """ + call alarmHandler for every entry in expressList + + @return: nothing + """ + logging.debug("data before update from expressList: %s", data) + for i in range(len(expressList)): + #update with eapoc_id (RIC) + data['ric'] = expressList[i][1] + #update with eapoc_sub (Sub RIC) + data['function'] = expressList[i][2] + # Add function as character a-d to dataset (reused from includes/poc.py) + data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") + #update with eapoc_id (RIC) + data['description'] = expressList[i][1] + logging.debug("data after update from expressList: %s", data) + try: + from includes import alarmHandler + alarmHandler.processAlarmHandler(typ, freq, data) + except: + logging.error("processing alarm failed") + logging.debug("processing alarm failed", exc_info=True) \ No newline at end of file diff --git a/poc.py b/poc.py new file mode 100644 index 00000000..1c9816b9 --- /dev/null +++ b/poc.py @@ -0,0 +1,156 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +""" +POCSAG Decoder + +@author: Bastian Schroll +@author: Jens Herrmann + +@requires: Configuration has to be set in the config.ini +""" + +import logging # Global logger +import re # Regex for validation + +from includes import globalVars # Global variables +from includes import doubleFilter # double alarm filter + +## +# +# Simple local filter +# +def isAllowed(poc_id): + """ + Simple Filter Functions (Allowed, Denied and Range) + + @type poc_id: string + @param poc_id: POCSAG Ric + + @requires: Configuration has to be set in the config.ini + + @return: Checks both allow/deny-rule and filter-range (suitable for signal-RIC) + @exception: none + """ + + allowed = 0 + + # 1.) If allowed RICs is set, only they will path, + # If RIC is the right one return True, else False + if globalVars.config.get("POC", "allow_ric"): + if poc_id in globalVars.config.get("POC", "allow_ric"): + logging.info("RIC %s is allowed", poc_id) + return True + else: + logging.info("RIC %s is not in the allowed list", poc_id) + allowed = 0 + # 2.) If denied RIC, return False + if poc_id in globalVars.config.get("POC", "deny_ric"): + logging.info("RIC %s is denied by config.ini", poc_id) + return False # RIC is denied - strongest way to block + # 3.) Check Range, return False if outside def. range + if globalVars.config.getint("POC", "filter_range_start") < int(poc_id) < globalVars.config.getint("POC", "filter_range_end"): + logging.info("RIC %s in between filter range", poc_id) + return True + else: + logging.info("RIC %s out of filter range", poc_id) + allowed = 0 + # 4.) Implementation for net identifiers + if globalVars.config.get("POC", "netIdent_ric"): + if poc_id in globalVars.config.get("POC", "netIdent_ric"): + logging.info("RIC %s as net identifier", poc_id) + return True + else: + allowed = 0 + + if allowed == 0: + return False + return True + +## +# +# POCSAG decoder function +# validate -> check double alarm -> log +# +def decode(freq, decoded): + """ + Export POCSAG information from Multimon-NG string and call alarmHandler.processAlarmHandler() + + @type freq: string + @param freq: frequency of the SDR Stick + @type decoded: string + @param decoded: RAW Information from Multimon-NG + + @requires: Configuration has to be set in the config.ini + + @return: nothing + @exception: Exception if POCSAG decode failed + """ + try: + bitrate = 0 + + if "POCSAG512:" in decoded: + bitrate = 512 + poc_id = decoded[20:27].replace(" ", "").zfill(7) + poc_sub = str(int(decoded[39])+1) + + elif "POCSAG1200:" in decoded: + bitrate = 1200 + poc_id = decoded[21:28].replace(" ", "").zfill(7) + poc_sub = str(int(decoded[40])+1) + + elif "POCSAG2400:" in decoded: + bitrate = 2400 + poc_id = decoded[21:28].replace(" ", "").zfill(7) + poc_sub = str(int(decoded[40])+1) + + if bitrate is 0: + logging.warning("POCSAG Bitrate not found") + logging.debug(" - (%s)", decoded) + else: + logging.debug("POCSAG Bitrate: %s", bitrate) + + if "Alpha:" in decoded: #check if there is a text message + poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() + else: + poc_text = "" + + if re.search("[0-9]{7}", poc_id) and re.search("[1-4]{1}", poc_sub): #if POC is valid + if isAllowed(poc_id): + # check for double alarm + if doubleFilter.checkID("POC", poc_id+poc_sub, poc_text): + logging.info("POCSAG%s: %s %s %s ", bitrate, poc_id, poc_sub, poc_text) + data = {"ric":poc_id, "function":poc_sub, "msg":poc_text, "bitrate":bitrate, "description":poc_id} + # Add function as character a-d to dataset + data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") + # If enabled, look up description + if globalVars.config.getint("POC", "idDescribed"): + from includes import descriptionList + data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"]) + # Express-Alarm processing if enabled and message without text ord delimiter RIC received + if globalVars.config.getint("ExpressAlarm", "expressAlarm") and (poc_text == "" or poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric")): + logging.debug("POCSAG%s: %s %s %s - Express-Alarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text) + from includes import expressAlarm + expressAlarm.newEntryExpressList("POC", poc_id, poc_sub, poc_text) + # Express-Alarm processing if enabled and alarm message has been received + elif globalVars.config.getint("ExpressAlarm", "expressAlarm") and poc_text != "" and poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_ric"): + logging.debug("EA RIC with text message - POCSAG%s: %s %s %s", bitrate, poc_id, poc_sub, poc_text) + from includes import expressAlarm + expressAlarm.expressAlarmExec("POC", freq, data) + else: + # processing the alarm + try: + from includes import alarmHandler + alarmHandler.processAlarmHandler("POC", freq, data) + except: + logging.error("processing alarm failed") + logging.debug("processing alarm failed", exc_info=True) + # in every time save old data for double alarm + doubleFilter.newEntry(poc_id+poc_sub, poc_text) + else: + logging.debug("POCSAG%s: %s is not allowed", bitrate, poc_id) + else: + logging.warning("No valid POCSAG%s RIC: %s SUB: %s", bitrate, poc_id, poc_sub) + except: + logging.error("error while decoding") + logging.debug("error while decoding", exc_info=True) diff --git a/testdata.txt b/testdata.txt new file mode 100644 index 00000000..83dd6c83 --- /dev/null +++ b/testdata.txt @@ -0,0 +1,136 @@ +# Testdata for the BOSWatch Test Mode function +# Data in Multimon-NG Raw Format +# Data is alternately passed to the decoder to simulate an used Radio-Frequency + +# +# POCSAG +# ------ +# +# The following settings in config.ini are expected for POCSAG +# +# [BOSWatch] +# useDescription = 1 +# doubleFilter_ignore_entries = 10 +# doubleFilter_check_msg = 1 +# +# [POC] +# deny_ric = 7777777 +# filter_range_start = 0000005 +# filter_range_end = 8999999 +# idDescribed = 1 +# + +# bitrate +POCSAG512: Address: 1000512 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay +POCSAG1200: Address: 1001200 Function: 1 Alpha: BOSWatch-Test: okay +POCSAG2400: Address: 1002400 Function: 1 Alpha: BOSWatch-Test: okay + +# function-code +POCSAG512: Address: 1000000 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 1000001 Function: 1 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 1000002 Function: 2 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay + +# german special sign +POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay +POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay + +# with csv +POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv + +# without csv +POCSAG1200: Address: 2345678 Function: 2 Alpha: BOSWatch-Test: without csv +POCSAG2400: Address: 3456789 Function: 3 Alpha: BOSWatch-Test: without csv + +# OHNE TEXT???? +POCSAG1200: Address: 1100000 Function: 0 +POCSAG1200: Address: 1100000 Function: 1 +POCSAG1200: Address: 1100000 Function: 2 +POCSAG1200: Address: 1100000 Function: 3 + +# duplicate with same and other msg +POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Testing: okay + +# duplicate in different order +POCSAG1200: Address: 2100000 Function: 2 +POCSAG1200: Address: 2100001 Function: 2 +POCSAG1200: Address: 2100002 Function: 2 +POCSAG1200: Address: 2100000 Function: 2 +POCSAG1200: Address: 2100001 Function: 2 +POCSAG1200: Address: 2100002 Function: 2 +POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate + +# invalid +POCSAG512: Address: 3 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 33 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 3333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 33333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 333333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 3333333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 333333F Function: 0 Alpha: BOSWatch-Test: invalid +POCSAG512: Address: 333333F Function: 1 Alpha: BOSWatch-Test: invalid +POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid + +# denied +POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied + +# out of filter Range +#POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start +#POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end +# +##Probealram +POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! +## Express Alarm +POCSAG1200: Address: 0871002 Function: 0 Alpha: +POCSAG1200: Address: 0860001 Function: 0 +POCSAG1200: Address: 0860002 Function: 0 +POCSAG1200: Address: 0860003 Function: 0 +POCSAG1200: Address: 0860004 Function: 0 +POCSAG1200: Address: 0860005 Function: 0 +POCSAG1200: Address: 0860006 Function: 0 +POCSAG1200: Address: 0860007 Function: 0 +POCSAG1200: Address: 0860008 Function: 0 +POCSAG1200: Address: 0860009 Function: 0 +POCSAG1200: Address: 0860010 Function: 0 +POCSAG1200: Address: 0871003 Function: 0 Alpha: B2 Feuer Gebäude Pers in Gefahr. bla bla bla + +# regEx-Filter? + + +# +# FMS +# --- +# +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct + + +# +# ZVEI +# ---- +# + +#with csv description +ZVEI1: 12345 +#without csv description +ZVEI1: 56789 +#duplicate +ZVEI1: 56789 +#with repeat Tone +ZVEI1: 1F2F3 +#in case of invalid id +ZVEI1: 135 +#in case of a double-tone for siren n-'D's are sended +ZVEI1: DDD +ZVEI1: DDDDD From c52c76aa5043335f471d4d89e0fd17c92e43b1e5 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:51:53 +0200 Subject: [PATCH 02/45] Delete expressAlarm.py --- expressAlarm.py | 65 ------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 expressAlarm.py diff --git a/expressAlarm.py b/expressAlarm.py deleted file mode 100644 index 03ca5d13..00000000 --- a/expressAlarm.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -""" -expressAlarm is the function to enable BOSwatch to deal with Swissfone Express-Alarm - -@author: Fabian Kessler - -@requires: Configuration has to be set in the config.ini -""" - -import logging # Global logger -import time # timestamp for expressAlarm - -from includes import globalVars # Global variables - -expressList = [] - -def newEntryExpressList(eatyp, eapoc_id, eapoc_sub, eapoc_text): - """ - add entry to express alarm list and remove old entries - - @return: nothing - """ - global expressList - tmpexpressList = [] - timestamp = int(time.time()) - # Express-Alarm processing if enabled and delimiter RIC has been received - if eapoc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric"): - expressList = [] - logging.debug("Express-Alarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) - else: - expressList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) - logging.debug("Added %s %s %s to expressList", eapoc_id, eapoc_sub, eapoc_text) - # check for old entries in expressList - for i in range(len(expressList)): - # we have to remove entries older than timestamp - ignore time - if int(expressList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): - tmpexpressList.append(expressList[i]) - expressList = tmpexpressList - - -def expressAlarmExec(typ, freq, data): - """ - call alarmHandler for every entry in expressList - - @return: nothing - """ - logging.debug("data before update from expressList: %s", data) - for i in range(len(expressList)): - #update with eapoc_id (RIC) - data['ric'] = expressList[i][1] - #update with eapoc_sub (Sub RIC) - data['function'] = expressList[i][2] - # Add function as character a-d to dataset (reused from includes/poc.py) - data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") - #update with eapoc_id (RIC) - data['description'] = expressList[i][1] - logging.debug("data after update from expressList: %s", data) - try: - from includes import alarmHandler - alarmHandler.processAlarmHandler(typ, freq, data) - except: - logging.error("processing alarm failed") - logging.debug("processing alarm failed", exc_info=True) \ No newline at end of file From 5503ac0be894327cab61e438f95e754dc4550a65 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:52:39 +0200 Subject: [PATCH 03/45] Delete config.template.ini --- config.template.ini | 511 -------------------------------------------- 1 file changed, 511 deletions(-) delete mode 100644 config.template.ini diff --git a/config.template.ini b/config.template.ini deleted file mode 100644 index f3373f33..00000000 --- a/config.template.ini +++ /dev/null @@ -1,511 +0,0 @@ -######################## -# BOSWatch Config File # -######################## - -[BOSWatch] -# set loglevel for logfile -# 10 = debug -# 20 = info -# 30 = warning -# 40 = error -# 50 = critical -loglevel = 10 - -# BOSWatch uses a rotating logfile -# Rotating is at midnight -# You can set the backupCount here -# backupCount = 7 (keeps logfiles for 7 days) -backupCount = 7 - -# if you want to start BOSWatch as a daemon with rc2.d, -# you have to set the path to rtl_fm and multimon-ng ! -# both pathes have to end with an / -#rtl_path = /usr/local/bin/ -#multimon_path = /usr/local/bin/ - -# if you are using many plugins or plugins with a long execution time -# you can execute them in an asynchronous manner -# It must be pointed out that enabling (0|1) this consumes time, -# so don't use it for one rapid plugin -processAlarmAsync = 0 - -# Using RegEx-filter (0 - off | 1 - on) -# filter-configuration in section [Filters] -useRegExFilter = 0 - -# for double check save the last n IDs -# it is used in combination with double_ignore_time -# 1 is required if you want to use the double alarm filter -doubleFilter_ignore_entries = 10 - -# time to ignore same alarm (only ID is checked) (sec) -doubleFilter_ignore_time = 5 - -# ignore msg is only usefull for POCSAG (0 - off | 1 - on) -# 0: double check ignores the msg-text (only check ID + function) -# 1: if you want to differentiate between with/ without msg -# f.e. if they use quick-alarm (without text, then same RIC with msg) -# you will get more then one alarm anyway if the msg is different (receiving-problems) -doubleFilter_check_msg = 0 - -# writes the multimon-ng raw data stream into a text file named mm_raw.txt -writeMultimonRaw = 0 - -[NMAHandler] -# you can use a logging handler for sending logging records to NotifyMyAndroid -# enableHandler (0|1) will enable the NMA handler -enableHandler = 0 - -# loglevel for NMAHandler (see BOSWatch loglevel description) -loglevel = 50 - -# logging record will send to APIKey -APIKey = - -# you can change the name of the application (default: BOSWatch) -# (f.e. if you use more than one instance of BOSWatch) -appName = BOSWatch - - -[FMS] -# look-up-table for adding a description -# using description (0 - off | 1 - on) -# descriptions are loaded from csv/fms.csv -idDescribed = 0 - -# Check for correct CRC-information is provided by multimon-ng -# As this seems to be incorrect in many cases it might be useful to disable this -# (0 - off | 1 - on) -# Better use RegEX to verify the correct data -checkCRC = 0 - -[ZVEI] -# look-up-table for adding a description -# using description (0 - off | 1 - on) -# descriptions are loaded from csv/zvei.csv -idDescribed = 0 - -[POC] -# some very simple filters: -# Allow only this RICs (empty: allow all, separator ",") -# f.e.: allow_ric = 1234566,1234567,1234568 -allow_ric = - -# Deny this RICs (empty: allow all, separator ",") -# f.e.: deny_ric = 1234566,1234567,1234568 -deny_ric = - -# start and end of an allowed filter range -filter_range_start = 0000000 -filter_range_end = 9999999 - -# look-up-table for adding a description -# using description (0 - off | 1 - on) -# descriptions are loaded from csv/poc.csv -idDescribed = 0 - -# Static Massages for Subrics. -rica = Feuer -ricb = TH -ricc = AGT -ricd = Unwetter - -# RIC for net identification -# Usually sent periodically, separated by comma -netIdent_ric = 0174760, 1398098 - -[ExpressAlarm] -# Using Express-Alarm (0 - off | 1 - on) -expressAlarm = 0 - -# time limit for alarms that do not belong to the Express-Alarm sequence -expressAlarm_ignore_time = 15 - -# Express-Alarm delimiter RIC -expressAlarm_delimiter_ric = - -# Express-Alarm RIC that is used to send the message -expressAlarm_ric = - -[Filters] -# RegEX Filter Configuration -# http://www.regexr.com/ - RegEX Test Tool an Documentation -# No Filter for a Typ/Plugin Combination = all Data pass -# INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX -# TYP = the Data Typ (FMS|ZVEI|POC) -# DATAFIELD = the field of the Data Array (see readme.md in plugin folder) -# PLUGIN = the name of the Plugin to call with this Filter (* for all) -# FREQUENZ = the Frequenz to use the Filter (for more SDR Sticks (* for all)) -# REGEX = the RegEX - -# only ZVEI to all plugins with 25### at 85.5MHz -#testfilter = ZVEI;zvei;*;85500000;25[0-9]{3} - -# only POCSAG to MySQL with the text "ALARM:" in the message -#pocTest = POC;msg;MySQL;*;ALARM: - - -[Plugins] -# turn the plugins on or off (0 - off | 1 - on) -MySQL = 0 -httpRequest = 0 -eMail = 0 -BosMon = 0 -firEmergency = 0 -jsonSocket = 0 -notifyMyAndroid = 0 -SMS = 0 -Sms77 = 0 -FFAgent = 0 -Pushover = 0 -Telegram = 0 -yowsup = 0 - -# for developing template-module -template = 0 - - -[MySQL] -# MySQL configuration -dbserver = localhost -dbuser = boswatch -dbpassword = root -database = boswatch - -# tables in the database -tableFMS = bos_fms -tableZVEI = bos_zvei -tablePOC = bos_pocsag -tableSIG = bos_signal - - -[httpRequest] -# example URL http://example.com/remote.php?DESCR=%DESCR% - -# multiple URLs can be separated by comma - -# you can use the following wildcards in your URL as GET params: -# http://en.wikipedia.org/wiki/Query_string - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description from csv-file -# %TIME% = Time (by script) -# %DATE% = Date (by script) -#fms_url = http://www.google.de?code=%FMS%&stat=%STATUS% -fms_url = - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description from csv-file -# %TIME% = Time (by script) -# %DATE% = Date (by script) -#zvei_url = http://www.google.de?zvei=%ZVEI% -zvei_url = - -# %RIC% = POCSAG RIC -# %FUNC% = POCSAG function/Subric (1-4) -# %FUNCCHAR% = POCSAG function/Subric as character (a-d) -# %FUNCTEXT% = POCSAG function/Subric static massage definded in POCSAG section -# %MSG% = Message of the POCSAG telegram -# %BITRATE% = Bitrate of the POCSAG telegram -# %DESCR% = Description from csv-file -# %TIME% = Time (by script) -# %DATE% = Date (by script) -#poc_url = http://www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% -poc_url = - - -[eMail] -# SMTP-Server -smtp_server = localhost -# Port of SMTP-server (default: ) -smtp_port = -# use tls for connection (0|1) -tls = 0 -# Use this, when SMTP-server has restricted access -user = -password = - -# Parameters for Alarm-Msg: -# "to" can be more than one address, comma separated -from = local@localhost -to = user@irgendwo, user2@woanders - -# Priority of the eMail: -# normal|urgent|non-urgent -priority = urgent - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %BR% = Insert line wrap (only in message) -# %LPAR% = ( -# %RPAR% = ) -fms_subject = FMS: %FMS% -fms_message = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %BR% = Insert line wrap (only in message) -# %LPAR% = ( -# %RPAR% = ) -zvei_subject = Alarm: %ZVEI% -zvei_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = POCSAG RIC -# %FUNC% = POCSAG function/Subric (1-4) -# %FUNCCHAR% = POCSAG function/Subric als character (a-d) -# %FUNCTEXT% = POCSAG function/Subric static massage definded in POCSAG section -# %MSG% = Message of the POCSAG telegram -# %BITRATE% = Bitrate of the POCSAG telegram -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %BR% = Insert line wrap (only in message) -# %LPAR% = ( -# %RPAR% = ) -poc_subject = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR% -poc_message = %DATE% %TIME% - %DESCR%: %MSG% - - -[BosMon] -# IP-address of the server (without http://) -# actually no SSL-support -bosmon_server = 192.168.0.1 -bosmon_port = 80 - -# channel-name of type "Web-Telegramm" -bosmon_channel = channel - -# Use this, when BosMon has restricted access -bosmon_user = -bosmon_password = - - -[firEmergency] -# firEmergency configuration -firserver = localhost -firport = 9001 - - -[jsonSocket] -# Protocol for socket (TCP|UDP) -protocol = UDP -# IP-address of the server (without http://) -server = 192.168.0.1 -port = 8888 - - -[notifyMyAndroid] -# APIKey given from notifyMyAndroid -APIKey = - -# Priority goes from -2 (lowest) to 2 (highest). The default priority is 0 (normal) -priority = 0 - -# You can change the name of the application (default: BOSWatch) -# (f.e. if you use more than one instance of BOSWatch) -appName = BOSWatch - -# instead of a given APIKey/priority you could import them by a csv-file (0|1) -# APIKey and priority above will be ignored, if you use a csv -# configuration loaded from csv/nma.csv -usecsv = 0 - - -[SMS] -# be aware that you need 'gammu' installed and running -# at least you need an UMTS-stick which is supported by 'gammu' - -quantity = 1 -# be sensitive to single RIC -ric1 = 1234567 - -# but you can watch several subrics, comma-separated -subric1 = a, b - -# a single cellphone-number -phonenumber1 = 0160321654987 - -# and the text for the sms -# ! DO NOT USE ANY UMLAUT ! -text1 = Rueckruf Leitstelle! - - -[Sms77] -# SMS77 configuration -# Login Username -user = - -# Password or API Key -password = - -# Receiver singlenumber or groupname from adressbook -to = - -# Sender number or name -from = - -# Type of Message (see https://www.sms77.de/funktionen/smstypen and https://www.sms77.de/funktionen/http-api) -type = quality - - -[FFAgent] -# set live mode (0/1) -live = 0 - -# send messages as type test (0/1) -test = 1 - -# path to server certificate file -serverCertFile = - -# path to client certificate file (LIVE) -clientCertFile = - -# path to client certificate password file (LIVE) -clientCertPass = - -# webapi token -webApiToken = - -# webapi key -webApiKey = - -# access token -accessToken = - -# selective Call Code -selectiveCallCode = - - -[Pushover] -# Pushover API Key -api_key = - -# Pushover Userkey or Groupkey to receive message -user_key = - -# Title of the message -title = BOSWatch Message - -# Adapt Pocsag Subric (a,b,c,d) to Pushover Priorities (see https://pushover.net/api#priority) -SubA = 0 -SubB = 2 -SubC = 1 -SubD = 0 - -# how often should Pushover re-alert in seconds (emergency-messages) -retry = 30 - -# when should Pushover stop to re-alert in seconds (emergency-messages) -expire = 90 - -# use HTML in messages (0/1) -html = 1 - - -[Telegram] -# This is your unique BOT token. You will get it from the BotFather once you have created your BOT. -BOTTokenAPIKey = -# Create a group chat with your BOT and enter the chat ID here. -# The plugin will send messages as your BOT and post everything in this group chat. -BOTChatIDAPIKey = -# The plugin can extract a location from the POCSAG message. -# However, this will be done for the following RIC only (7 digits e.g. 0012345). -RICforLocationAPIKey = -# This is your Google API key. -# Required if you want to create a map based on location information received with the above RIC. -GoogleAPIKey = - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -FMS_message = %DATE% %TIME%: %FMS% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -ZVEI_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = POCSAG RIC -# %FUNC% = POCSAG function/Subric (1-4) -# %FUNCCHAR% = POCSAG function/Subric als character (a-d) -# %MSG% = Message of the POCSAG telegram -# %BITRATE% = Bitrate of the POCSAG telegram -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -POC_message = %MSG% - - -[yowsup] -# number or chat-number who whants to become the news -empfaenger = -# WhatsApp-number of that the news comes -sender = -# password from this number -password= - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -fms_message = %DATE% %TIME%: %FMS% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -zvei_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = POCSAG RIC -# %FUNC% = POCSAG function/Subric (1-4) -# %FUNCCHAR% = POCSAG function/Subric als character (a-d) -# %MSG% = Message of the POCSAG telegram -# %BITRATE% = Bitrate of the POCSAG telegram -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -poc_message = %MSG% - - -##################### -##### Not ready yet # -##################### - -[template] -test1 = testString -test2 = 123456 From 990ef0ff1ce39f469eebde1a1be96ae2df58e8bc Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:53:02 +0200 Subject: [PATCH 04/45] Delete poc.py --- poc.py | 156 --------------------------------------------------------- 1 file changed, 156 deletions(-) delete mode 100644 poc.py diff --git a/poc.py b/poc.py deleted file mode 100644 index 1c9816b9..00000000 --- a/poc.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -""" -POCSAG Decoder - -@author: Bastian Schroll -@author: Jens Herrmann - -@requires: Configuration has to be set in the config.ini -""" - -import logging # Global logger -import re # Regex for validation - -from includes import globalVars # Global variables -from includes import doubleFilter # double alarm filter - -## -# -# Simple local filter -# -def isAllowed(poc_id): - """ - Simple Filter Functions (Allowed, Denied and Range) - - @type poc_id: string - @param poc_id: POCSAG Ric - - @requires: Configuration has to be set in the config.ini - - @return: Checks both allow/deny-rule and filter-range (suitable for signal-RIC) - @exception: none - """ - - allowed = 0 - - # 1.) If allowed RICs is set, only they will path, - # If RIC is the right one return True, else False - if globalVars.config.get("POC", "allow_ric"): - if poc_id in globalVars.config.get("POC", "allow_ric"): - logging.info("RIC %s is allowed", poc_id) - return True - else: - logging.info("RIC %s is not in the allowed list", poc_id) - allowed = 0 - # 2.) If denied RIC, return False - if poc_id in globalVars.config.get("POC", "deny_ric"): - logging.info("RIC %s is denied by config.ini", poc_id) - return False # RIC is denied - strongest way to block - # 3.) Check Range, return False if outside def. range - if globalVars.config.getint("POC", "filter_range_start") < int(poc_id) < globalVars.config.getint("POC", "filter_range_end"): - logging.info("RIC %s in between filter range", poc_id) - return True - else: - logging.info("RIC %s out of filter range", poc_id) - allowed = 0 - # 4.) Implementation for net identifiers - if globalVars.config.get("POC", "netIdent_ric"): - if poc_id in globalVars.config.get("POC", "netIdent_ric"): - logging.info("RIC %s as net identifier", poc_id) - return True - else: - allowed = 0 - - if allowed == 0: - return False - return True - -## -# -# POCSAG decoder function -# validate -> check double alarm -> log -# -def decode(freq, decoded): - """ - Export POCSAG information from Multimon-NG string and call alarmHandler.processAlarmHandler() - - @type freq: string - @param freq: frequency of the SDR Stick - @type decoded: string - @param decoded: RAW Information from Multimon-NG - - @requires: Configuration has to be set in the config.ini - - @return: nothing - @exception: Exception if POCSAG decode failed - """ - try: - bitrate = 0 - - if "POCSAG512:" in decoded: - bitrate = 512 - poc_id = decoded[20:27].replace(" ", "").zfill(7) - poc_sub = str(int(decoded[39])+1) - - elif "POCSAG1200:" in decoded: - bitrate = 1200 - poc_id = decoded[21:28].replace(" ", "").zfill(7) - poc_sub = str(int(decoded[40])+1) - - elif "POCSAG2400:" in decoded: - bitrate = 2400 - poc_id = decoded[21:28].replace(" ", "").zfill(7) - poc_sub = str(int(decoded[40])+1) - - if bitrate is 0: - logging.warning("POCSAG Bitrate not found") - logging.debug(" - (%s)", decoded) - else: - logging.debug("POCSAG Bitrate: %s", bitrate) - - if "Alpha:" in decoded: #check if there is a text message - poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() - else: - poc_text = "" - - if re.search("[0-9]{7}", poc_id) and re.search("[1-4]{1}", poc_sub): #if POC is valid - if isAllowed(poc_id): - # check for double alarm - if doubleFilter.checkID("POC", poc_id+poc_sub, poc_text): - logging.info("POCSAG%s: %s %s %s ", bitrate, poc_id, poc_sub, poc_text) - data = {"ric":poc_id, "function":poc_sub, "msg":poc_text, "bitrate":bitrate, "description":poc_id} - # Add function as character a-d to dataset - data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") - # If enabled, look up description - if globalVars.config.getint("POC", "idDescribed"): - from includes import descriptionList - data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"]) - # Express-Alarm processing if enabled and message without text ord delimiter RIC received - if globalVars.config.getint("ExpressAlarm", "expressAlarm") and (poc_text == "" or poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric")): - logging.debug("POCSAG%s: %s %s %s - Express-Alarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text) - from includes import expressAlarm - expressAlarm.newEntryExpressList("POC", poc_id, poc_sub, poc_text) - # Express-Alarm processing if enabled and alarm message has been received - elif globalVars.config.getint("ExpressAlarm", "expressAlarm") and poc_text != "" and poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_ric"): - logging.debug("EA RIC with text message - POCSAG%s: %s %s %s", bitrate, poc_id, poc_sub, poc_text) - from includes import expressAlarm - expressAlarm.expressAlarmExec("POC", freq, data) - else: - # processing the alarm - try: - from includes import alarmHandler - alarmHandler.processAlarmHandler("POC", freq, data) - except: - logging.error("processing alarm failed") - logging.debug("processing alarm failed", exc_info=True) - # in every time save old data for double alarm - doubleFilter.newEntry(poc_id+poc_sub, poc_text) - else: - logging.debug("POCSAG%s: %s is not allowed", bitrate, poc_id) - else: - logging.warning("No valid POCSAG%s RIC: %s SUB: %s", bitrate, poc_id, poc_sub) - except: - logging.error("error while decoding") - logging.debug("error while decoding", exc_info=True) From 3532a64cf175b96f39423eb8c19efdc32b8cb1d4 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:53:12 +0200 Subject: [PATCH 05/45] Delete testdata.txt --- testdata.txt | 136 --------------------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 testdata.txt diff --git a/testdata.txt b/testdata.txt deleted file mode 100644 index 83dd6c83..00000000 --- a/testdata.txt +++ /dev/null @@ -1,136 +0,0 @@ -# Testdata for the BOSWatch Test Mode function -# Data in Multimon-NG Raw Format -# Data is alternately passed to the decoder to simulate an used Radio-Frequency - -# -# POCSAG -# ------ -# -# The following settings in config.ini are expected for POCSAG -# -# [BOSWatch] -# useDescription = 1 -# doubleFilter_ignore_entries = 10 -# doubleFilter_check_msg = 1 -# -# [POC] -# deny_ric = 7777777 -# filter_range_start = 0000005 -# filter_range_end = 8999999 -# idDescribed = 1 -# - -# bitrate -POCSAG512: Address: 1000512 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay -POCSAG1200: Address: 1001200 Function: 1 Alpha: BOSWatch-Test: okay -POCSAG2400: Address: 1002400 Function: 1 Alpha: BOSWatch-Test: okay - -# function-code -POCSAG512: Address: 1000000 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 1000001 Function: 1 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 1000002 Function: 2 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay - -# german special sign -POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay -POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay - -# with csv -POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv - -# without csv -POCSAG1200: Address: 2345678 Function: 2 Alpha: BOSWatch-Test: without csv -POCSAG2400: Address: 3456789 Function: 3 Alpha: BOSWatch-Test: without csv - -# OHNE TEXT???? -POCSAG1200: Address: 1100000 Function: 0 -POCSAG1200: Address: 1100000 Function: 1 -POCSAG1200: Address: 1100000 Function: 2 -POCSAG1200: Address: 1100000 Function: 3 - -# duplicate with same and other msg -POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Testing: okay - -# duplicate in different order -POCSAG1200: Address: 2100000 Function: 2 -POCSAG1200: Address: 2100001 Function: 2 -POCSAG1200: Address: 2100002 Function: 2 -POCSAG1200: Address: 2100000 Function: 2 -POCSAG1200: Address: 2100001 Function: 2 -POCSAG1200: Address: 2100002 Function: 2 -POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate - -# invalid -POCSAG512: Address: 3 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 33 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 3333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 33333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 333333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 3333333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 333333F Function: 0 Alpha: BOSWatch-Test: invalid -POCSAG512: Address: 333333F Function: 1 Alpha: BOSWatch-Test: invalid -POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid - -# denied -POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied - -# out of filter Range -#POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start -#POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end -# -##Probealram -POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! -## Express Alarm -POCSAG1200: Address: 0871002 Function: 0 Alpha: -POCSAG1200: Address: 0860001 Function: 0 -POCSAG1200: Address: 0860002 Function: 0 -POCSAG1200: Address: 0860003 Function: 0 -POCSAG1200: Address: 0860004 Function: 0 -POCSAG1200: Address: 0860005 Function: 0 -POCSAG1200: Address: 0860006 Function: 0 -POCSAG1200: Address: 0860007 Function: 0 -POCSAG1200: Address: 0860008 Function: 0 -POCSAG1200: Address: 0860009 Function: 0 -POCSAG1200: Address: 0860010 Function: 0 -POCSAG1200: Address: 0871003 Function: 0 Alpha: B2 Feuer Gebäude Pers in Gefahr. bla bla bla - -# regEx-Filter? - - -# -# FMS -# --- -# -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct - - -# -# ZVEI -# ---- -# - -#with csv description -ZVEI1: 12345 -#without csv description -ZVEI1: 56789 -#duplicate -ZVEI1: 56789 -#with repeat Tone -ZVEI1: 1F2F3 -#in case of invalid id -ZVEI1: 135 -#in case of a double-tone for siren n-'D's are sended -ZVEI1: DDD -ZVEI1: DDDDD From e770937c6d296f0d17d88087c59202e0a17dd361 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:54:01 +0200 Subject: [PATCH 06/45] Add files via upload added options for Express-Alarm --- config/testdata.txt | 136 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 config/testdata.txt diff --git a/config/testdata.txt b/config/testdata.txt new file mode 100644 index 00000000..83dd6c83 --- /dev/null +++ b/config/testdata.txt @@ -0,0 +1,136 @@ +# Testdata for the BOSWatch Test Mode function +# Data in Multimon-NG Raw Format +# Data is alternately passed to the decoder to simulate an used Radio-Frequency + +# +# POCSAG +# ------ +# +# The following settings in config.ini are expected for POCSAG +# +# [BOSWatch] +# useDescription = 1 +# doubleFilter_ignore_entries = 10 +# doubleFilter_check_msg = 1 +# +# [POC] +# deny_ric = 7777777 +# filter_range_start = 0000005 +# filter_range_end = 8999999 +# idDescribed = 1 +# + +# bitrate +POCSAG512: Address: 1000512 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay +POCSAG1200: Address: 1001200 Function: 1 Alpha: BOSWatch-Test: okay +POCSAG2400: Address: 1002400 Function: 1 Alpha: BOSWatch-Test: okay + +# function-code +POCSAG512: Address: 1000000 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 1000001 Function: 1 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 1000002 Function: 2 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay + +# german special sign +POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay +POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay + +# with csv +POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv + +# without csv +POCSAG1200: Address: 2345678 Function: 2 Alpha: BOSWatch-Test: without csv +POCSAG2400: Address: 3456789 Function: 3 Alpha: BOSWatch-Test: without csv + +# OHNE TEXT???? +POCSAG1200: Address: 1100000 Function: 0 +POCSAG1200: Address: 1100000 Function: 1 +POCSAG1200: Address: 1100000 Function: 2 +POCSAG1200: Address: 1100000 Function: 3 + +# duplicate with same and other msg +POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Testing: okay + +# duplicate in different order +POCSAG1200: Address: 2100000 Function: 2 +POCSAG1200: Address: 2100001 Function: 2 +POCSAG1200: Address: 2100002 Function: 2 +POCSAG1200: Address: 2100000 Function: 2 +POCSAG1200: Address: 2100001 Function: 2 +POCSAG1200: Address: 2100002 Function: 2 +POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate +POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate + +# invalid +POCSAG512: Address: 3 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 33 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 3333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 33333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 333333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 3333333 Function: 0 Alpha: BOSWatch-Test: okay +POCSAG512: Address: 333333F Function: 0 Alpha: BOSWatch-Test: invalid +POCSAG512: Address: 333333F Function: 1 Alpha: BOSWatch-Test: invalid +POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid + +# denied +POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied + +# out of filter Range +#POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start +#POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end +# +##Probealram +POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! +## Express Alarm +POCSAG1200: Address: 0871002 Function: 0 Alpha: +POCSAG1200: Address: 0860001 Function: 0 +POCSAG1200: Address: 0860002 Function: 0 +POCSAG1200: Address: 0860003 Function: 0 +POCSAG1200: Address: 0860004 Function: 0 +POCSAG1200: Address: 0860005 Function: 0 +POCSAG1200: Address: 0860006 Function: 0 +POCSAG1200: Address: 0860007 Function: 0 +POCSAG1200: Address: 0860008 Function: 0 +POCSAG1200: Address: 0860009 Function: 0 +POCSAG1200: Address: 0860010 Function: 0 +POCSAG1200: Address: 0871003 Function: 0 Alpha: B2 Feuer Gebäude Pers in Gefahr. bla bla bla + +# regEx-Filter? + + +# +# FMS +# --- +# +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct +FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct + + +# +# ZVEI +# ---- +# + +#with csv description +ZVEI1: 12345 +#without csv description +ZVEI1: 56789 +#duplicate +ZVEI1: 56789 +#with repeat Tone +ZVEI1: 1F2F3 +#in case of invalid id +ZVEI1: 135 +#in case of a double-tone for siren n-'D's are sended +ZVEI1: DDD +ZVEI1: DDDDD From fbc3e53a1df6303a73e984ebf5bc31c05169c395 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:54:26 +0200 Subject: [PATCH 07/45] Delete testdata.txt --- config/testdata.txt | 136 -------------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 config/testdata.txt diff --git a/config/testdata.txt b/config/testdata.txt deleted file mode 100644 index 83dd6c83..00000000 --- a/config/testdata.txt +++ /dev/null @@ -1,136 +0,0 @@ -# Testdata for the BOSWatch Test Mode function -# Data in Multimon-NG Raw Format -# Data is alternately passed to the decoder to simulate an used Radio-Frequency - -# -# POCSAG -# ------ -# -# The following settings in config.ini are expected for POCSAG -# -# [BOSWatch] -# useDescription = 1 -# doubleFilter_ignore_entries = 10 -# doubleFilter_check_msg = 1 -# -# [POC] -# deny_ric = 7777777 -# filter_range_start = 0000005 -# filter_range_end = 8999999 -# idDescribed = 1 -# - -# bitrate -POCSAG512: Address: 1000512 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay -POCSAG1200: Address: 1001200 Function: 1 Alpha: BOSWatch-Test: okay -POCSAG2400: Address: 1002400 Function: 1 Alpha: BOSWatch-Test: okay - -# function-code -POCSAG512: Address: 1000000 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 1000001 Function: 1 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 1000002 Function: 2 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay - -# german special sign -POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay -POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay - -# with csv -POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv - -# without csv -POCSAG1200: Address: 2345678 Function: 2 Alpha: BOSWatch-Test: without csv -POCSAG2400: Address: 3456789 Function: 3 Alpha: BOSWatch-Test: without csv - -# OHNE TEXT???? -POCSAG1200: Address: 1100000 Function: 0 -POCSAG1200: Address: 1100000 Function: 1 -POCSAG1200: Address: 1100000 Function: 2 -POCSAG1200: Address: 1100000 Function: 3 - -# duplicate with same and other msg -POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2000001 Function: 2 Alpha: BOSWatch-Testing: okay - -# duplicate in different order -POCSAG1200: Address: 2100000 Function: 2 -POCSAG1200: Address: 2100001 Function: 2 -POCSAG1200: Address: 2100002 Function: 2 -POCSAG1200: Address: 2100000 Function: 2 -POCSAG1200: Address: 2100001 Function: 2 -POCSAG1200: Address: 2100002 Function: 2 -POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100000 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100001 Function: 2 Alpha: BOSWatch-Test: second is a duplicate -POCSAG1200: Address: 2100002 Function: 2 Alpha: BOSWatch-Test: second is a duplicate - -# invalid -POCSAG512: Address: 3 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 33 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 3333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 33333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 333333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 3333333 Function: 0 Alpha: BOSWatch-Test: okay -POCSAG512: Address: 333333F Function: 0 Alpha: BOSWatch-Test: invalid -POCSAG512: Address: 333333F Function: 1 Alpha: BOSWatch-Test: invalid -POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid - -# denied -POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied - -# out of filter Range -#POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start -#POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end -# -##Probealram -POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! -## Express Alarm -POCSAG1200: Address: 0871002 Function: 0 Alpha: -POCSAG1200: Address: 0860001 Function: 0 -POCSAG1200: Address: 0860002 Function: 0 -POCSAG1200: Address: 0860003 Function: 0 -POCSAG1200: Address: 0860004 Function: 0 -POCSAG1200: Address: 0860005 Function: 0 -POCSAG1200: Address: 0860006 Function: 0 -POCSAG1200: Address: 0860007 Function: 0 -POCSAG1200: Address: 0860008 Function: 0 -POCSAG1200: Address: 0860009 Function: 0 -POCSAG1200: Address: 0860010 Function: 0 -POCSAG1200: Address: 0871003 Function: 0 Alpha: B2 Feuer Gebäude Pers in Gefahr. bla bla bla - -# regEx-Filter? - - -# -# FMS -# --- -# -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct -FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct - - -# -# ZVEI -# ---- -# - -#with csv description -ZVEI1: 12345 -#without csv description -ZVEI1: 56789 -#duplicate -ZVEI1: 56789 -#with repeat Tone -ZVEI1: 1F2F3 -#in case of invalid id -ZVEI1: 135 -#in case of a double-tone for siren n-'D's are sended -ZVEI1: DDD -ZVEI1: DDDDD From 9ffa872b74d840e2f87e9622cd1ea560e3fef6ff Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:55:03 +0200 Subject: [PATCH 08/45] Add files via upload added options for Express-Alarm --- config/config.template.ini | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index d943faff..f3373f33 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -114,6 +114,19 @@ ricd = Unwetter # Usually sent periodically, separated by comma netIdent_ric = 0174760, 1398098 +[ExpressAlarm] +# Using Express-Alarm (0 - off | 1 - on) +expressAlarm = 0 + +# time limit for alarms that do not belong to the Express-Alarm sequence +expressAlarm_ignore_time = 15 + +# Express-Alarm delimiter RIC +expressAlarm_delimiter_ric = + +# Express-Alarm RIC that is used to send the message +expressAlarm_ric = + [Filters] # RegEX Filter Configuration # http://www.regexr.com/ - RegEX Test Tool an Documentation From 81a146b78f699164fb10ccf776c31c751dd2a0b3 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:55:59 +0200 Subject: [PATCH 09/45] Add files via upload new function to support Express-Alarm --- includes/expressAlarm.py | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 includes/expressAlarm.py diff --git a/includes/expressAlarm.py b/includes/expressAlarm.py new file mode 100644 index 00000000..03ca5d13 --- /dev/null +++ b/includes/expressAlarm.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +expressAlarm is the function to enable BOSwatch to deal with Swissfone Express-Alarm + +@author: Fabian Kessler + +@requires: Configuration has to be set in the config.ini +""" + +import logging # Global logger +import time # timestamp for expressAlarm + +from includes import globalVars # Global variables + +expressList = [] + +def newEntryExpressList(eatyp, eapoc_id, eapoc_sub, eapoc_text): + """ + add entry to express alarm list and remove old entries + + @return: nothing + """ + global expressList + tmpexpressList = [] + timestamp = int(time.time()) + # Express-Alarm processing if enabled and delimiter RIC has been received + if eapoc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric"): + expressList = [] + logging.debug("Express-Alarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) + else: + expressList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) + logging.debug("Added %s %s %s to expressList", eapoc_id, eapoc_sub, eapoc_text) + # check for old entries in expressList + for i in range(len(expressList)): + # we have to remove entries older than timestamp - ignore time + if int(expressList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): + tmpexpressList.append(expressList[i]) + expressList = tmpexpressList + + +def expressAlarmExec(typ, freq, data): + """ + call alarmHandler for every entry in expressList + + @return: nothing + """ + logging.debug("data before update from expressList: %s", data) + for i in range(len(expressList)): + #update with eapoc_id (RIC) + data['ric'] = expressList[i][1] + #update with eapoc_sub (Sub RIC) + data['function'] = expressList[i][2] + # Add function as character a-d to dataset (reused from includes/poc.py) + data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") + #update with eapoc_id (RIC) + data['description'] = expressList[i][1] + logging.debug("data after update from expressList: %s", data) + try: + from includes import alarmHandler + alarmHandler.processAlarmHandler(typ, freq, data) + except: + logging.error("processing alarm failed") + logging.debug("processing alarm failed", exc_info=True) \ No newline at end of file From 46a53dd8dc288d23b0e1c9a73d6ca50f33839a1e Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:56:59 +0200 Subject: [PATCH 10/45] Add files via upload added processing of Express-Alarms --- includes/decoders/poc.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index b0198f09..1c9816b9 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -127,13 +127,24 @@ def decode(freq, decoded): if globalVars.config.getint("POC", "idDescribed"): from includes import descriptionList data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"]) - # processing the alarm - try: - from includes import alarmHandler - alarmHandler.processAlarmHandler("POC", freq, data) - except: - logging.error("processing alarm failed") - logging.debug("processing alarm failed", exc_info=True) + # Express-Alarm processing if enabled and message without text ord delimiter RIC received + if globalVars.config.getint("ExpressAlarm", "expressAlarm") and (poc_text == "" or poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric")): + logging.debug("POCSAG%s: %s %s %s - Express-Alarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text) + from includes import expressAlarm + expressAlarm.newEntryExpressList("POC", poc_id, poc_sub, poc_text) + # Express-Alarm processing if enabled and alarm message has been received + elif globalVars.config.getint("ExpressAlarm", "expressAlarm") and poc_text != "" and poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_ric"): + logging.debug("EA RIC with text message - POCSAG%s: %s %s %s", bitrate, poc_id, poc_sub, poc_text) + from includes import expressAlarm + expressAlarm.expressAlarmExec("POC", freq, data) + else: + # processing the alarm + try: + from includes import alarmHandler + alarmHandler.processAlarmHandler("POC", freq, data) + except: + logging.error("processing alarm failed") + logging.debug("processing alarm failed", exc_info=True) # in every time save old data for double alarm doubleFilter.newEntry(poc_id+poc_sub, poc_text) else: From f171bda8355effab7a0027ec4183e4a6dd4561e2 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 20:57:48 +0200 Subject: [PATCH 11/45] Add files via upload added test data for Express-Alarm --- citest/testdata.txt | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/citest/testdata.txt b/citest/testdata.txt index e4ac22e5..83dd6c83 100644 --- a/citest/testdata.txt +++ b/citest/testdata.txt @@ -35,7 +35,7 @@ POCSAG512: Address: 1000003 Function: 3 Alpha: BOSWatch-Test: okay POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test ÖÄÜß: okay POCSAG512: Address: 1200001 Function: 1 Alpha: BOSWatch-Test öäü: okay -# witch csv +# with csv POCSAG512: Address: 1234567 Function: 1 Alpha: BOSWatch-Test: with csv # without csv @@ -83,8 +83,24 @@ POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied # out of filter Range -POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start -POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end +#POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start +#POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end +# +##Probealram +POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! +## Express Alarm +POCSAG1200: Address: 0871002 Function: 0 Alpha: +POCSAG1200: Address: 0860001 Function: 0 +POCSAG1200: Address: 0860002 Function: 0 +POCSAG1200: Address: 0860003 Function: 0 +POCSAG1200: Address: 0860004 Function: 0 +POCSAG1200: Address: 0860005 Function: 0 +POCSAG1200: Address: 0860006 Function: 0 +POCSAG1200: Address: 0860007 Function: 0 +POCSAG1200: Address: 0860008 Function: 0 +POCSAG1200: Address: 0860009 Function: 0 +POCSAG1200: Address: 0860010 Function: 0 +POCSAG1200: Address: 0871003 Function: 0 Alpha: B2 Feuer Gebäude Pers in Gefahr. bla bla bla # regEx-Filter? From 70d769862ca5481c2a2c85b08bee684e015d754b Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 21:36:53 +0200 Subject: [PATCH 12/45] Update testdata.txt --- citest/testdata.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/citest/testdata.txt b/citest/testdata.txt index 83dd6c83..bec65594 100644 --- a/citest/testdata.txt +++ b/citest/testdata.txt @@ -83,10 +83,10 @@ POCSAG512: Address: 3333333 Function: 4 Alpha: BOSWatch-Test: invalid POCSAG1200: Address: 7777777 Function: 1 Alpha: BOSWatch-Test: denied # out of filter Range -#POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start -#POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end -# -##Probealram +POCSAG1200: Address: 0000004 Function: 1 Alpha: BOSWatch-Test: out of filter start +POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter end + +#Probealram POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! ## Express Alarm POCSAG1200: Address: 0871002 Function: 0 Alpha: From 7fd88a452bf29b591a23266d50468114f235d8bc Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 21:37:47 +0200 Subject: [PATCH 13/45] Update config.template.ini --- config/config.template.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.template.ini b/config/config.template.ini index f3373f33..d891580b 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -118,7 +118,7 @@ netIdent_ric = 0174760, 1398098 # Using Express-Alarm (0 - off | 1 - on) expressAlarm = 0 -# time limit for alarms that do not belong to the Express-Alarm sequence +# time limit for alarms that do not belong to the Express-Alarm sequence in seconds expressAlarm_ignore_time = 15 # Express-Alarm delimiter RIC From 55f55295d009d2c9d716ca7bb4a0df6d9375b982 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 19 Sep 2017 21:43:57 +0200 Subject: [PATCH 14/45] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ac3d336b..4f88d2a1 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ unless you are developer you can use the develop-Branch - may be unstable! - Ready for use BOSWatch as daemon - possibility to start plugins asynchron - NMA Error Handler +- Express-Alarm ##### Features for the future: - more plugins From f73e6f215be5c787a05164e8b81c4c8832a901b1 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 19 Sep 2017 22:04:41 +0200 Subject: [PATCH 15/45] edit changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e997ab7b..8ef1e91f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### __[Unreleased]__ ##### Added +- zuschaltbare POCSAG Express-Alarm Funktionalität ##### Changed ##### Deprecated ##### Removed From 6af6981b68767d8aa7a05369f5625d2870ab5ac5 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 20 Sep 2017 06:25:06 +0200 Subject: [PATCH 16/45] changes for codacy --- includes/expressAlarm.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/expressAlarm.py b/includes/expressAlarm.py index 03ca5d13..5b1c308a 100644 --- a/includes/expressAlarm.py +++ b/includes/expressAlarm.py @@ -29,37 +29,37 @@ def newEntryExpressList(eatyp, eapoc_id, eapoc_sub, eapoc_text): if eapoc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric"): expressList = [] logging.debug("Express-Alarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) - else: + else: expressList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) logging.debug("Added %s %s %s to expressList", eapoc_id, eapoc_sub, eapoc_text) # check for old entries in expressList - for i in range(len(expressList)): + for i, exList in enumerate(expressList): # we have to remove entries older than timestamp - ignore time - if int(expressList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): - tmpexpressList.append(expressList[i]) + if int(exList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): + tmpexpressList.append(exList[i]) expressList = tmpexpressList def expressAlarmExec(typ, freq, data): """ call alarmHandler for every entry in expressList - + @return: nothing """ logging.debug("data before update from expressList: %s", data) - for i in range(len(expressList)): + for i, exList in enumerate(expressList): #update with eapoc_id (RIC) - data['ric'] = expressList[i][1] + data['ric'] = exList[i][1] #update with eapoc_sub (Sub RIC) - data['function'] = expressList[i][2] + data['function'] = exList[i][2] # Add function as character a-d to dataset (reused from includes/poc.py) data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") #update with eapoc_id (RIC) - data['description'] = expressList[i][1] - logging.debug("data after update from expressList: %s", data) + data['description'] = exList[i][1] + logging.debug("data after update from expressList: %s", data) try: from includes import alarmHandler alarmHandler.processAlarmHandler(typ, freq, data) except: logging.error("processing alarm failed") - logging.debug("processing alarm failed", exc_info=True) \ No newline at end of file + logging.debug("processing alarm failed", exc_info=True) From 0ed8df0202fca78d24045fcb50eb5b6f807a0b76 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 20 Sep 2017 06:31:47 +0200 Subject: [PATCH 17/45] add ExpressAlarm to logging --- boswatch.py | 2 ++ config/config.template.ini | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/boswatch.py b/boswatch.py index e8b7b3a2..50b1e032 100755 --- a/boswatch.py +++ b/boswatch.py @@ -217,6 +217,8 @@ # if given loglevel is debug: if globalVars.config.getint("BOSWatch","loglevel") == 10: configHandler.checkConfig("BOSWatch") + configHandler.checkConfig("ExpressAlarm") + configHandler.checkConfig("Filters") configHandler.checkConfig("FMS") configHandler.checkConfig("ZVEI") configHandler.checkConfig("POC") diff --git a/config/config.template.ini b/config/config.template.ini index d891580b..d1c8c70a 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -122,10 +122,10 @@ expressAlarm = 0 expressAlarm_ignore_time = 15 # Express-Alarm delimiter RIC -expressAlarm_delimiter_ric = +expressAlarm_delimiter_ric = # Express-Alarm RIC that is used to send the message -expressAlarm_ric = +expressAlarm_ric = [Filters] # RegEX Filter Configuration From ae03473f940caa9455a5d4ba40b0f80b363d148e Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 21 Sep 2017 12:09:17 +0200 Subject: [PATCH 18/45] Update config.template.ini Hinweis zur delimiter RIC angepasst. --- config/config.template.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.template.ini b/config/config.template.ini index d1c8c70a..e54065e4 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -121,7 +121,7 @@ expressAlarm = 0 # time limit for alarms that do not belong to the Express-Alarm sequence in seconds expressAlarm_ignore_time = 15 -# Express-Alarm delimiter RIC +# Express-Alarm delimiter RIC (usually used as a starting point for a Express-Alarm sequence) (can be empty) expressAlarm_delimiter_ric = # Express-Alarm RIC that is used to send the message From 0fc12abf44a2e51ef5e50c1c67c707c5f065c3e5 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sat, 23 Sep 2017 09:23:49 +0200 Subject: [PATCH 19/45] Changed naming and description --- config/config.template.ini | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index e54065e4..fea5f171 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -114,18 +114,23 @@ ricd = Unwetter # Usually sent periodically, separated by comma netIdent_ric = 0174760, 1398098 -[ExpressAlarm] -# Using Express-Alarm (0 - off | 1 - on) -expressAlarm = 0 - -# time limit for alarms that do not belong to the Express-Alarm sequence in seconds -expressAlarm_ignore_time = 15 - -# Express-Alarm delimiter RIC (usually used as a starting point for a Express-Alarm sequence) (can be empty) -expressAlarm_delimiter_ric = - -# Express-Alarm RIC that is used to send the message -expressAlarm_ric = +[multicastAlarm] +# Configure multicastAlarm if your POCSAG network uses an optimized transmission scheme for alarms with more than one RIC (often found in Swissphone networks). +# The optimized transmission scheme sends a POCSAG telegram with each RIC that needs to be alarmed in a sequence. These telegrams are send without a text message. This sequence is directly followed by a telegram with a special RIC and the text message. +# A POCSAG pager (DME) can be configured to start an acoustic alarm if a specific RIC without text has been received. If afterwards the RIC with the text message will be received, the pager will show the message in it's display. +# multicastAlarm enables BOSwatch to forward the all received RIC joined with the text message +# +# enable multicastAlarm (0 - off | 1 - on) +multicastAlarm = 0 + +# time limit for alarms that do not belong to the multicastAlarm sequence in seconds +multicastAlarm_ignore_time = 15 + +# multicastAlarm delimiter RIC (usually used as a starting point for a alarm sequence) (can be empty) +multicastAlarm_delimiter_ric = + +# multicastAlarm RIC that is used to send the text message +multicastAlarm_ric = [Filters] # RegEX Filter Configuration From 07f42e15d8d1eb1fba7fe1ed0f6409848470741c Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sat, 23 Sep 2017 09:25:08 +0200 Subject: [PATCH 20/45] Changed naming --- includes/expressAlarm.py | 65 -------------------------------------- includes/multicastAlarm.py | 65 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 includes/expressAlarm.py create mode 100644 includes/multicastAlarm.py diff --git a/includes/expressAlarm.py b/includes/expressAlarm.py deleted file mode 100644 index 5b1c308a..00000000 --- a/includes/expressAlarm.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -""" -expressAlarm is the function to enable BOSwatch to deal with Swissfone Express-Alarm - -@author: Fabian Kessler - -@requires: Configuration has to be set in the config.ini -""" - -import logging # Global logger -import time # timestamp for expressAlarm - -from includes import globalVars # Global variables - -expressList = [] - -def newEntryExpressList(eatyp, eapoc_id, eapoc_sub, eapoc_text): - """ - add entry to express alarm list and remove old entries - - @return: nothing - """ - global expressList - tmpexpressList = [] - timestamp = int(time.time()) - # Express-Alarm processing if enabled and delimiter RIC has been received - if eapoc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric"): - expressList = [] - logging.debug("Express-Alarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) - else: - expressList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) - logging.debug("Added %s %s %s to expressList", eapoc_id, eapoc_sub, eapoc_text) - # check for old entries in expressList - for i, exList in enumerate(expressList): - # we have to remove entries older than timestamp - ignore time - if int(exList[i][4]) > timestamp-globalVars.config.getint("ExpressAlarm", "expressAlarm_ignore_time"): - tmpexpressList.append(exList[i]) - expressList = tmpexpressList - - -def expressAlarmExec(typ, freq, data): - """ - call alarmHandler for every entry in expressList - - @return: nothing - """ - logging.debug("data before update from expressList: %s", data) - for i, exList in enumerate(expressList): - #update with eapoc_id (RIC) - data['ric'] = exList[i][1] - #update with eapoc_sub (Sub RIC) - data['function'] = exList[i][2] - # Add function as character a-d to dataset (reused from includes/poc.py) - data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") - #update with eapoc_id (RIC) - data['description'] = exList[i][1] - logging.debug("data after update from expressList: %s", data) - try: - from includes import alarmHandler - alarmHandler.processAlarmHandler(typ, freq, data) - except: - logging.error("processing alarm failed") - logging.debug("processing alarm failed", exc_info=True) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py new file mode 100644 index 00000000..9d00e235 --- /dev/null +++ b/includes/multicastAlarm.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +multicastAlarm is the function to enable BOSwatch to deal networks that optimise the transmission of POCSAG telegrams + +@author: Fabian Kessler + +@requires: Configuration has to be set in the config.ini +""" + +import logging # Global logger +import time # timestamp for multicastAlarm + +from includes import globalVars # Global variables + +multiList = [] + +def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): + """ + add entry to multi alarm list and remove old entries + + @return: nothing + """ + global multiList + tmpmultiList = [] + timestamp = int(time.time()) + # multicastAlarm processing if enabled and delimiter RIC has been received + if eapoc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): + multiList = [] + logging.debug("multicastAlarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) + else: + multiList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) + logging.debug("Added %s %s %s to multiList", eapoc_id, eapoc_sub, eapoc_text) + # check for old entries in multiList + for i in range(len(multiList)): + # we have to remove entries older than timestamp - ignore time + if int(multiList[i][4]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): + tmpmultiList.append(multiList[i]) + multiList = tmpmultiList + + +def multicastAlarmExec(typ, freq, data): + """ + call alarmHandler for every entry in multiList + + @return: nothing + """ + logging.debug("data before update from multiList: %s", data) + for i in range(len(multiList)): + #update with eapoc_id (RIC) + data['ric'] = multiList[i][1] + #update with eapoc_sub (Sub RIC) + data['function'] = multiList[i][2] + # Add function as character a-d to dataset (reused from includes/poc.py) + data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") + #update with eapoc_id (RIC) + data['description'] = multiList[i][1] + logging.debug("data after update from multiList: %s", data) + try: + from includes import alarmHandler + alarmHandler.processAlarmHandler(typ, freq, data) + except: + logging.error("processing alarm failed") + logging.debug("processing alarm failed", exc_info=True) From d30eee586692bb1338c9b06d4b58a37ac1fd27c1 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sat, 23 Sep 2017 09:25:43 +0200 Subject: [PATCH 21/45] Updated naming --- includes/decoders/poc.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 1c9816b9..3fc7e15b 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -127,16 +127,16 @@ def decode(freq, decoded): if globalVars.config.getint("POC", "idDescribed"): from includes import descriptionList data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"]) - # Express-Alarm processing if enabled and message without text ord delimiter RIC received - if globalVars.config.getint("ExpressAlarm", "expressAlarm") and (poc_text == "" or poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_delimiter_ric")): - logging.debug("POCSAG%s: %s %s %s - Express-Alarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text) - from includes import expressAlarm - expressAlarm.newEntryExpressList("POC", poc_id, poc_sub, poc_text) - # Express-Alarm processing if enabled and alarm message has been received - elif globalVars.config.getint("ExpressAlarm", "expressAlarm") and poc_text != "" and poc_id == globalVars.config.get("ExpressAlarm", "expressAlarm_ric"): + # multicastAlarm processing if enabled and message without text ord delimiter RIC received + if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (poc_text == "" or poc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): + logging.debug("POCSAG%s: %s %s %s - multicastAlarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text) + from includes import multicastAlarm + multicastAlarm.newEntrymultiList("POC", poc_id, poc_sub, poc_text) + # multicastAlarm processing if enabled and alarm message has been received + elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and poc_text != "" and poc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): logging.debug("EA RIC with text message - POCSAG%s: %s %s %s", bitrate, poc_id, poc_sub, poc_text) - from includes import expressAlarm - expressAlarm.expressAlarmExec("POC", freq, data) + from includes import multicastAlarm + multicastAlarm.multicastAlarmExec("POC", freq, data) else: # processing the alarm try: From 06d36b3b48f54b3870d44c37308890517aaefc59 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sat, 23 Sep 2017 09:30:26 +0200 Subject: [PATCH 22/45] Changed EA to multicastAlarm --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f88d2a1..5137f3fb 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ unless you are developer you can use the develop-Branch - may be unstable! - Ready for use BOSWatch as daemon - possibility to start plugins asynchron - NMA Error Handler -- Express-Alarm +- multicastAlarm for transmission optimized networks ##### Features for the future: - more plugins From bd733b61b459a68cd0d809839afc5a14a87cf6be Mon Sep 17 00:00:00 2001 From: f-kessler Date: Sun, 24 Sep 2017 12:01:15 +0200 Subject: [PATCH 23/45] changed logging to multicastAlarm --- boswatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boswatch.py b/boswatch.py index 50b1e032..1a92c4ab 100755 --- a/boswatch.py +++ b/boswatch.py @@ -217,7 +217,7 @@ # if given loglevel is debug: if globalVars.config.getint("BOSWatch","loglevel") == 10: configHandler.checkConfig("BOSWatch") - configHandler.checkConfig("ExpressAlarm") + configHandler.checkConfig("multicastAlarm") configHandler.checkConfig("Filters") configHandler.checkConfig("FMS") configHandler.checkConfig("ZVEI") From 736d0f95ce50c3cbdf9858cba7b53f8ddb75420d Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 24 Sep 2017 12:11:50 +0200 Subject: [PATCH 24/45] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef1e91f..7bf85c3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### __[Unreleased]__ ##### Added -- zuschaltbare POCSAG Express-Alarm Funktionalität +- zuschaltbare POCSAG Multicast-Alarm Funktionalität ##### Changed ##### Deprecated ##### Removed From f6e4c8d3a94f5c64a3a533ff872f34301e0b0ae6 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 24 Sep 2017 12:12:27 +0200 Subject: [PATCH 25/45] Update testdata.txt --- citest/testdata.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/citest/testdata.txt b/citest/testdata.txt index bec65594..4f1d5d11 100644 --- a/citest/testdata.txt +++ b/citest/testdata.txt @@ -88,7 +88,7 @@ POCSAG1200: Address: 9000000 Function: 1 Alpha: BOSWatch-Test: out of filter #Probealram POCSAG1200: Address: 0871004 Function: 1 Alpha: Dies ist ein Probealarm! -## Express Alarm +## Multicast Alarm POCSAG1200: Address: 0871002 Function: 0 Alpha: POCSAG1200: Address: 0860001 Function: 0 POCSAG1200: Address: 0860002 Function: 0 From 8069ded206ed3bb649c43f687394fb224053e174 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Mon, 25 Sep 2017 20:47:06 +0200 Subject: [PATCH 26/45] enumerate() instead of range(len()) --- includes/multicastAlarm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 9d00e235..b96e6157 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -33,7 +33,7 @@ def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): multiList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) logging.debug("Added %s %s %s to multiList", eapoc_id, eapoc_sub, eapoc_text) # check for old entries in multiList - for i in range(len(multiList)): + for i in enumerate(multiList): # we have to remove entries older than timestamp - ignore time if int(multiList[i][4]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): tmpmultiList.append(multiList[i]) @@ -47,7 +47,7 @@ def multicastAlarmExec(typ, freq, data): @return: nothing """ logging.debug("data before update from multiList: %s", data) - for i in range(len(multiList)): + for i in enumerate(multiList): #update with eapoc_id (RIC) data['ric'] = multiList[i][1] #update with eapoc_sub (Sub RIC) From 00e4e52352a9c82cec895af393997f50204fe653 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Mon, 25 Sep 2017 20:57:28 +0200 Subject: [PATCH 27/45] Update multicastAlarm.py --- includes/multicastAlarm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index b96e6157..a37c58d0 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -33,7 +33,7 @@ def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): multiList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) logging.debug("Added %s %s %s to multiList", eapoc_id, eapoc_sub, eapoc_text) # check for old entries in multiList - for i in enumerate(multiList): + for i,j in enumerate(multiList): # we have to remove entries older than timestamp - ignore time if int(multiList[i][4]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): tmpmultiList.append(multiList[i]) @@ -47,7 +47,7 @@ def multicastAlarmExec(typ, freq, data): @return: nothing """ logging.debug("data before update from multiList: %s", data) - for i in enumerate(multiList): + for i,j in enumerate(multiList): #update with eapoc_id (RIC) data['ric'] = multiList[i][1] #update with eapoc_sub (Sub RIC) From 3aa0b382e9e8866d749d3f4861f5ed79c64ee772 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 29 Sep 2017 13:33:21 +0200 Subject: [PATCH 28/45] edit changelog with link --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c5c36a1..65372fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,12 @@ ### __[v2.2.3]__ - unreleased ##### Added -- zuschaltbare POCSAG Multicast-Alarm Funktionalität +- zuschaltbare POCSAG Multicast-Alarm Funktionalität [#307](https://github.com/Schrolli91/BOSWatch/pull/307) ##### Changed ##### Deprecated ##### Removed ##### Fixed +- einige Code-Style Verbesserungen ##### Security From c54bd558888bebd2189ca05809c085453091faa1 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 1 Oct 2017 18:06:56 +0200 Subject: [PATCH 29/45] change to data-field at checks --- includes/decoders/poc.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 3fc7e15b..552f06de 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -117,26 +117,31 @@ def decode(freq, decoded): if re.search("[0-9]{7}", poc_id) and re.search("[1-4]{1}", poc_sub): #if POC is valid if isAllowed(poc_id): + # check for double alarm if doubleFilter.checkID("POC", poc_id+poc_sub, poc_text): - logging.info("POCSAG%s: %s %s %s ", bitrate, poc_id, poc_sub, poc_text) data = {"ric":poc_id, "function":poc_sub, "msg":poc_text, "bitrate":bitrate, "description":poc_id} # Add function as character a-d to dataset data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") + + logging.info("POCSAG%s: %s %s %s ", data["bitrate"], data["ric"], data["function"], data["msg"]) + # If enabled, look up description if globalVars.config.getint("POC", "idDescribed"): from includes import descriptionList - data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"]) + data["description"] = descriptionList.getDescription("POC", data["ric"]+data["functionChar"]) + # multicastAlarm processing if enabled and message without text ord delimiter RIC received - if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (poc_text == "" or poc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): - logging.debug("POCSAG%s: %s %s %s - multicastAlarm or delimiter RIC received - buffer until text received", bitrate, poc_id, poc_sub, poc_text) + if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): + logging.debug(" - multicastAlarm or delimiter RIC received - buffer alarms until text received") from includes import multicastAlarm multicastAlarm.newEntrymultiList("POC", poc_id, poc_sub, poc_text) # multicastAlarm processing if enabled and alarm message has been received - elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and poc_text != "" and poc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): - logging.debug("EA RIC with text message - POCSAG%s: %s %s %s", bitrate, poc_id, poc_sub, poc_text) + elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): + logging.debug(" - multicastAlarm RIC with text message") from includes import multicastAlarm multicastAlarm.multicastAlarmExec("POC", freq, data) + else: # processing the alarm try: From b6077d522d02e094c2820e8a47f9fa6e864134b3 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Mon, 2 Oct 2017 15:32:01 +0200 Subject: [PATCH 30/45] enumerate value correction --- includes/multicastAlarm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index a37c58d0..031c6e3f 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -33,7 +33,7 @@ def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): multiList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) logging.debug("Added %s %s %s to multiList", eapoc_id, eapoc_sub, eapoc_text) # check for old entries in multiList - for i,j in enumerate(multiList): + for i, _ in enumerate(multiList): # we have to remove entries older than timestamp - ignore time if int(multiList[i][4]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): tmpmultiList.append(multiList[i]) @@ -47,7 +47,7 @@ def multicastAlarmExec(typ, freq, data): @return: nothing """ logging.debug("data before update from multiList: %s", data) - for i,j in enumerate(multiList): + for i, _ in enumerate(multiList): #update with eapoc_id (RIC) data['ric'] = multiList[i][1] #update with eapoc_sub (Sub RIC) From 166dd3e3f8dd7ee0c050ca48d661edbca3707a3c Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 3 Oct 2017 11:38:24 +0200 Subject: [PATCH 31/45] changed data buffering and updating for alarms --- includes/multicastAlarm.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 031c6e3f..a2a9a0c2 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """ -multicastAlarm is the function to enable BOSwatch to deal networks that optimise the transmission of POCSAG telegrams +multicastAlarm is the function to enable BOSwatch to work in networks that optimise the transmission of POCSAG telegrams @author: Fabian Kessler @@ -16,7 +16,7 @@ multiList = [] -def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): +def newEntrymultiList(typ, freq, data): """ add entry to multi alarm list and remove old entries @@ -26,16 +26,16 @@ def newEntrymultiList(eatyp, eapoc_id, eapoc_sub, eapoc_text): tmpmultiList = [] timestamp = int(time.time()) # multicastAlarm processing if enabled and delimiter RIC has been received - if eapoc_id == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): + if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): multiList = [] - logging.debug("multicastAlarm delimiter RIC received --> buffer cleared %s %s %s ", eapoc_id, eapoc_sub, eapoc_text) + logging.debug("multicastAlarm delimiter RIC received --> buffer cleared %s ", data) else: - multiList.append([eatyp, eapoc_id, eapoc_sub, eapoc_text.strip(), timestamp]) - logging.debug("Added %s %s %s to multiList", eapoc_id, eapoc_sub, eapoc_text) + multiList.append([typ, data['ric'], data['function'], data['functionChar'], data['msg'].strip(), data['description'], timestamp]) + logging.debug("Added %s %s %s %s to multiList", data['ric'], data['function'], data['functionChar'], data['msg'].strip()) # check for old entries in multiList for i, _ in enumerate(multiList): # we have to remove entries older than timestamp - ignore time - if int(multiList[i][4]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): + if int(multiList[i][6]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): tmpmultiList.append(multiList[i]) multiList = tmpmultiList @@ -48,14 +48,11 @@ def multicastAlarmExec(typ, freq, data): """ logging.debug("data before update from multiList: %s", data) for i, _ in enumerate(multiList): - #update with eapoc_id (RIC) + #update data with values multiList data['ric'] = multiList[i][1] - #update with eapoc_sub (Sub RIC) data['function'] = multiList[i][2] - # Add function as character a-d to dataset (reused from includes/poc.py) - data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d") - #update with eapoc_id (RIC) - data['description'] = multiList[i][1] + data['functionChar'] = multiList[i][3] + data['description'] = multiList[i][5] logging.debug("data after update from multiList: %s", data) try: from includes import alarmHandler From 6bcba28979016abd0b3dc10aa9ee1a0d85d48c48 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 3 Oct 2017 11:39:57 +0200 Subject: [PATCH 32/45] changed to send complete data to multicastAlarm for buffering --- includes/decoders/poc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 552f06de..4813b9a8 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -135,7 +135,8 @@ def decode(freq, decoded): if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): logging.debug(" - multicastAlarm or delimiter RIC received - buffer alarms until text received") from includes import multicastAlarm - multicastAlarm.newEntrymultiList("POC", poc_id, poc_sub, poc_text) + multicastAlarm.newEntrymultiList("POC", freq, data) + # multicastAlarm processing if enabled and alarm message has been received elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): logging.debug(" - multicastAlarm RIC with text message") From 9aa163d5a8ed0f8d75d01e25ae7fbbc5ecd76504 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 3 Oct 2017 11:41:02 +0200 Subject: [PATCH 33/45] text for multicastAlarm config updated --- config/config.template.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 5e31d27f..1177604c 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -132,9 +132,9 @@ netIdent_ric = 0174760, 1398098 [multicastAlarm] # Configure multicastAlarm if your POCSAG network uses an optimized transmission scheme for alarms with more than one RIC (often found in Swissphone networks). -# The optimized transmission scheme sends a POCSAG telegram with each RIC that needs to be alarmed in a sequence. These telegrams are send without a text message. This sequence is directly followed by a telegram with a special RIC and the text message. -# A POCSAG pager (DME) can be configured to start an acoustic alarm if a specific RIC without text has been received. If afterwards the RIC with the text message will be received, the pager will show the message in it's display. -# multicastAlarm enables BOSwatch to forward the all received RIC joined with the text message +# In this optimized transmission scheme, a POCSAG telegram with each RIC that needs to be alarmed will be send in a sequence. These telegrams are send without a text message. This sequence is directly followed by a telegram with a specific RIC and the text message that belongs to the sequnece send right before. +# A POCSAG pager (DME) can be configured to start an acoustic alarm if a specific RIC without text has been received. If afterwards the specific RIC with the text message will be received, the pager will show the message in it's display. +# multicastAlarm enables BOSwatch to process the all received RICs joined with the text message. # # enable multicastAlarm (0 - off | 1 - on) multicastAlarm = 0 From b52d972c208a8f6c06c0d8be48001628b7b8a39e Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 12:03:08 +0200 Subject: [PATCH 34/45] edit debug msg --- includes/decoders/poc.py | 4 ++-- includes/multicastAlarm.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 4813b9a8..9f18bb60 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -133,13 +133,13 @@ def decode(freq, decoded): # multicastAlarm processing if enabled and message without text ord delimiter RIC received if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): - logging.debug(" - multicastAlarm or delimiter RIC received - buffer alarms until text received") + logging.debug(" - multicastAlarm without msg") from includes import multicastAlarm multicastAlarm.newEntrymultiList("POC", freq, data) # multicastAlarm processing if enabled and alarm message has been received elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): - logging.debug(" - multicastAlarm RIC with text message") + logging.debug(" - multicastAlarm with message") from includes import multicastAlarm multicastAlarm.multicastAlarmExec("POC", freq, data) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index a2a9a0c2..de23a3f8 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -28,10 +28,10 @@ def newEntrymultiList(typ, freq, data): # multicastAlarm processing if enabled and delimiter RIC has been received if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): multiList = [] - logging.debug("multicastAlarm delimiter RIC received --> buffer cleared %s ", data) + logging.debug("multicastAlarm delimiter RIC received --> buffer cleared") else: multiList.append([typ, data['ric'], data['function'], data['functionChar'], data['msg'].strip(), data['description'], timestamp]) - logging.debug("Added %s %s %s %s to multiList", data['ric'], data['function'], data['functionChar'], data['msg'].strip()) + logging.debug("Added %s to multiList", data['ric']) # check for old entries in multiList for i, _ in enumerate(multiList): # we have to remove entries older than timestamp - ignore time From f701b6a010506b859b9da5e7b6357a00f16b6959 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 12:08:04 +0200 Subject: [PATCH 35/45] del typ and freq in adding routine --- includes/decoders/poc.py | 2 +- includes/multicastAlarm.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 9f18bb60..94908432 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -135,7 +135,7 @@ def decode(freq, decoded): if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): logging.debug(" - multicastAlarm without msg") from includes import multicastAlarm - multicastAlarm.newEntrymultiList("POC", freq, data) + multicastAlarm.newEntrymultiList(data) # multicastAlarm processing if enabled and alarm message has been received elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index de23a3f8..7d9c3d28 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -16,7 +16,7 @@ multiList = [] -def newEntrymultiList(typ, freq, data): +def newEntrymultiList(data): """ add entry to multi alarm list and remove old entries From 9c446b0660a4e62d5aee86400017ebaaf0109f13 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 12:10:08 +0200 Subject: [PATCH 36/45] del typ and freq in adding routine --- includes/decoders/poc.py | 2 +- includes/multicastAlarm.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 94908432..fe7f724a 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -141,7 +141,7 @@ def decode(freq, decoded): elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): logging.debug(" - multicastAlarm with message") from includes import multicastAlarm - multicastAlarm.multicastAlarmExec("POC", freq, data) + multicastAlarm.multicastAlarmExec(freq, data) else: # processing the alarm diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 7d9c3d28..ec9e13d9 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -40,7 +40,7 @@ def newEntrymultiList(data): multiList = tmpmultiList -def multicastAlarmExec(typ, freq, data): +def multicastAlarmExec(freq, data): """ call alarmHandler for every entry in multiList @@ -56,7 +56,7 @@ def multicastAlarmExec(typ, freq, data): logging.debug("data after update from multiList: %s", data) try: from includes import alarmHandler - alarmHandler.processAlarmHandler(typ, freq, data) + alarmHandler.processAlarmHandler("POC", freq, data) except: logging.error("processing alarm failed") logging.debug("processing alarm failed", exc_info=True) From 9aaa8aa267b5f19bd796654e1ef258900ed6dfe1 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 12:13:05 +0200 Subject: [PATCH 37/45] remove typ from adding --- includes/multicastAlarm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index ec9e13d9..75582e0a 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -30,7 +30,7 @@ def newEntrymultiList(data): multiList = [] logging.debug("multicastAlarm delimiter RIC received --> buffer cleared") else: - multiList.append([typ, data['ric'], data['function'], data['functionChar'], data['msg'].strip(), data['description'], timestamp]) + multiList.append([data['ric'], data['function'], data['functionChar'], data['msg'].strip(), data['description'], timestamp]) logging.debug("Added %s to multiList", data['ric']) # check for old entries in multiList for i, _ in enumerate(multiList): From 3220088e6cfb247bd70a2f9691279f368cce1b63 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Tue, 3 Oct 2017 12:43:12 +0200 Subject: [PATCH 38/45] update indexes after remove of typ from multiList --- includes/multicastAlarm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 75582e0a..437e8789 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -35,7 +35,7 @@ def newEntrymultiList(data): # check for old entries in multiList for i, _ in enumerate(multiList): # we have to remove entries older than timestamp - ignore time - if int(multiList[i][6]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): + if int(multiList[i][5]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): tmpmultiList.append(multiList[i]) multiList = tmpmultiList @@ -49,10 +49,10 @@ def multicastAlarmExec(freq, data): logging.debug("data before update from multiList: %s", data) for i, _ in enumerate(multiList): #update data with values multiList - data['ric'] = multiList[i][1] - data['function'] = multiList[i][2] - data['functionChar'] = multiList[i][3] - data['description'] = multiList[i][5] + data['ric'] = multiList[i][0] + data['function'] = multiList[i][1] + data['functionChar'] = multiList[i][2] + data['description'] = multiList[i][4] logging.debug("data after update from multiList: %s", data) try: from includes import alarmHandler From 63f2e58310cd4881034f49d79c58142ef48a3399 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 14:43:36 +0200 Subject: [PATCH 39/45] edit multicastAlarm --- includes/multicastAlarm.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 437e8789..b153a0b1 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -14,6 +14,9 @@ from includes import globalVars # Global variables +# +# ListStructure [0..n] = (Data, TimeStamp) +# multiList = [] def newEntrymultiList(data): @@ -22,22 +25,18 @@ def newEntrymultiList(data): @return: nothing """ - global multiList - tmpmultiList = [] timestamp = int(time.time()) # multicastAlarm processing if enabled and delimiter RIC has been received if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): multiList = [] logging.debug("multicastAlarm delimiter RIC received --> buffer cleared") else: - multiList.append([data['ric'], data['function'], data['functionChar'], data['msg'].strip(), data['description'], timestamp]) + multiList.append([data, timestamp]) logging.debug("Added %s to multiList", data['ric']) # check for old entries in multiList - for i, _ in enumerate(multiList): - # we have to remove entries older than timestamp - ignore time - if int(multiList[i][5]) > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): - tmpmultiList.append(multiList[i]) - multiList = tmpmultiList + for (xData, xTimestamp) in multiList: + if xTimestamp > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): + multiList.remove([xData, xTimestamp]) def multicastAlarmExec(freq, data): @@ -47,12 +46,12 @@ def multicastAlarmExec(freq, data): @return: nothing """ logging.debug("data before update from multiList: %s", data) - for i, _ in enumerate(multiList): + for (xData, xTimestamp) in multiList: #update data with values multiList - data['ric'] = multiList[i][0] - data['function'] = multiList[i][1] - data['functionChar'] = multiList[i][2] - data['description'] = multiList[i][4] + data['ric'] = xData['ric'] + data['function'] = xData['ric'] + data['functionChar'] = xData['ric'] + data['description'] = xData['ric'] logging.debug("data after update from multiList: %s", data) try: from includes import alarmHandler From fca69b974e27c905ebf9a2dcd2c04b6b81c1bcf9 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 19:32:09 +0200 Subject: [PATCH 40/45] add placeholder (unused var) --- includes/multicastAlarm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index b153a0b1..3f7b7bb4 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -46,7 +46,7 @@ def multicastAlarmExec(freq, data): @return: nothing """ logging.debug("data before update from multiList: %s", data) - for (xData, xTimestamp) in multiList: + for (xData, _) in multiList: #update data with values multiList data['ric'] = xData['ric'] data['function'] = xData['ric'] From 578750a810bc1ebcb13bf9a0defb7ccfda7fa02d Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 22:08:38 +0200 Subject: [PATCH 41/45] fix global definition issue --- includes/multicastAlarm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 3f7b7bb4..48c42099 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -25,6 +25,7 @@ def newEntrymultiList(data): @return: nothing """ + global multiList timestamp = int(time.time()) # multicastAlarm processing if enabled and delimiter RIC has been received if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): From bcdac6e2e65f35b220a3e7df4ae07337a94e75ce Mon Sep 17 00:00:00 2001 From: f-kessler Date: Thu, 5 Oct 2017 21:09:24 +0200 Subject: [PATCH 42/45] exclude netIdent_ric from multicastAlarm If not excluded it cannot be used anywhere --- includes/decoders/poc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index fe7f724a..a2ee3085 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -131,8 +131,8 @@ def decode(freq, decoded): from includes import descriptionList data["description"] = descriptionList.getDescription("POC", data["ric"]+data["functionChar"]) - # multicastAlarm processing if enabled and message without text ord delimiter RIC received - if globalVars.config.getint("multicastAlarm", "multicastAlarm") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): + # multicastAlarm processing if enabled and a message without text or delimiter RIC or netIdent_ric received + if globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["ric"] != globalVars.config.get("POC", "netIdent_ric") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): logging.debug(" - multicastAlarm without msg") from includes import multicastAlarm multicastAlarm.newEntrymultiList(data) From b7141d986b4a379f8a9afd81e1219627204a39a4 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Mon, 9 Oct 2017 20:59:03 +0200 Subject: [PATCH 43/45] fixed remove of old RICs and replacement of data for calling alarmHandler Changed for loop to iterate over a copy of multiList fixed replacement of data from xData --- includes/multicastAlarm.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/multicastAlarm.py b/includes/multicastAlarm.py index 48c42099..40a83443 100644 --- a/includes/multicastAlarm.py +++ b/includes/multicastAlarm.py @@ -30,14 +30,15 @@ def newEntrymultiList(data): # multicastAlarm processing if enabled and delimiter RIC has been received if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"): multiList = [] - logging.debug("multicastAlarm delimiter RIC received --> buffer cleared") + logging.debug("delimiter RIC received - buffer cleared") else: multiList.append([data, timestamp]) logging.debug("Added %s to multiList", data['ric']) # check for old entries in multiList - for (xData, xTimestamp) in multiList: - if xTimestamp > timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): + for (xData, xTimestamp) in multiList[:]: + if xTimestamp < timestamp-globalVars.config.getint("multicastAlarm", "multicastAlarm_ignore_time"): multiList.remove([xData, xTimestamp]) + logging.debug("RIC %s removed - %s sec. older than current timestamp", xData['ric'], xTimestamp-timestamp) def multicastAlarmExec(freq, data): @@ -50,9 +51,9 @@ def multicastAlarmExec(freq, data): for (xData, _) in multiList: #update data with values multiList data['ric'] = xData['ric'] - data['function'] = xData['ric'] - data['functionChar'] = xData['ric'] - data['description'] = xData['ric'] + data['function'] = xData['function'] + data['functionChar'] = xData['functionChar'] + data['description'] = xData['description'] logging.debug("data after update from multiList: %s", data) try: from includes import alarmHandler From fb82b1868d71526f133e8e260f63160c1649475e Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 21 Oct 2017 22:57:10 +0200 Subject: [PATCH 44/45] edit CL --- CHANGELOG.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 450fb2ac..cf39bf6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,28 @@ # Changelog -### __[v2.2.2]__ - unreleased + +### __[2.x]__ - unreleased ##### Added - zuschaltbare POCSAG Multicast-Alarm Funktionalität [#307](https://github.com/Schrolli91/BOSWatch/pull/307) +##### Changed +##### Deprecated +##### Removed +##### Fixed +##### Security + + +### __[v2.2.2]__ - 21.10.2017 +##### Added - Installations Script für Services [#316](https://github.com/Schrolli91/BOSWatch/pull/316) ##### Changed - Telegram Plugin importiert Google Maps Funktionen nur noch wenn API Key eingetragen ist [#315](https://github.com/Schrolli91/BOSWatch/pull/315) - Versions Nummer und Branch Name getrennt [3fed1ac](https://github.com/Schrolli91/BOSWatch/commit/3fed1ac12af8690213766e0e81d71c237530ed2c) ##### Deprecated -##### Removed +- Beta Branch wird mit nächstem Update entfernt [Forum](http://boswatch.de/index.php?thread/16-beta-branch-abschaffen/&postID=113#post113) ##### Fixed +- Schreibfehler der Pfadangabe im Installer [#317](https://github.com/Schrolli91/BOSWatch/pull/317) - Schreibfehler in Service Readme [#313](https://github.com/Schrolli91/BOSWatch/issues/313) - Einige Code-Style Verbesserungen [#310](https://github.com/Schrolli91/BOSWatch/pull/310) -##### Security ### __[v2.2.1]__ - 19.09.2017 From 59b78a4f64ee58ec0bd19cf2f82179f0317ae0c2 Mon Sep 17 00:00:00 2001 From: f-kessler Date: Mon, 23 Oct 2017 20:34:25 +0200 Subject: [PATCH 45/45] multi delimiter and text RICs Changed to support multiple delimiters and text RICs --- includes/decoders/poc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index a2ee3085..da863186 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -132,13 +132,13 @@ def decode(freq, decoded): data["description"] = descriptionList.getDescription("POC", data["ric"]+data["functionChar"]) # multicastAlarm processing if enabled and a message without text or delimiter RIC or netIdent_ric received - if globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["ric"] != globalVars.config.get("POC", "netIdent_ric") and (data["msg"] == "" or data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): + if globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["ric"] != globalVars.config.get("POC", "netIdent_ric") and (data["msg"] == "" or data["ric"] in globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric")): logging.debug(" - multicastAlarm without msg") from includes import multicastAlarm multicastAlarm.newEntrymultiList(data) # multicastAlarm processing if enabled and alarm message has been received - elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] == globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): + elif globalVars.config.getint("multicastAlarm", "multicastAlarm") and data["msg"] != "" and data["ric"] in globalVars.config.get("multicastAlarm", "multicastAlarm_ric"): logging.debug(" - multicastAlarm with message") from includes import multicastAlarm multicastAlarm.multicastAlarmExec(freq, data)