mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
Add files via upload
Express-Alarm function added
This commit is contained in:
parent
84d39d0686
commit
f31532d79a
511
config.template.ini
Normal file
511
config.template.ini
Normal file
|
|
@ -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
|
||||
65
expressAlarm.py
Normal file
65
expressAlarm.py
Normal file
|
|
@ -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)
|
||||
156
poc.py
Normal file
156
poc.py
Normal file
|
|
@ -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('<NUL><NUL>','').replace('<NUL>','').replace('<NUL','').replace('< NUL>','').replace('<EOT>','').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)
|
||||
136
testdata.txt
Normal file
136
testdata.txt
Normal file
|
|
@ -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: <EOT><FF>
|
||||
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<NUL>
|
||||
|
||||
# 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
|
||||
Loading…
Reference in a new issue