mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
commit
ff07a9a867
|
|
@ -22,10 +22,12 @@ unless you are developer you can use the develop-Branch - may be unstable!
|
|||
- simple Web Frontend with Data Parsing
|
||||
- Logfiles for better Troubleshooting
|
||||
- verbose/quiet Mode for more/none information
|
||||
|
||||
- POCSAG1200 and POCSAG512 support
|
||||
- Filtering of POCSAG512 and POCSAG1200 RIC´s (adjustment at config)
|
||||
-
|
||||
##### Features for the Future:
|
||||
- extensive filtering options
|
||||
- POCSAG 512,1200,2400 support (need RAW data from multimon-ng)
|
||||
- 2400 support (need RAW data from multimon-ng)
|
||||
- automatic Audio recording at alarm
|
||||
- Web Frontend with Overview and configuration
|
||||
|
||||
|
|
@ -91,6 +93,9 @@ So you have to make up manually if you want to use MySQL support.
|
|||
- Webserver with PHP
|
||||
- MySQL Database Server
|
||||
|
||||
##### filtering
|
||||
- you can adjust your rangefilter for POCSAG Decode at config file under the section POC
|
||||
|
||||
Thanks to smith_fms and McBo from [Funkmeldesystem.de - Forum](http://www.funkmeldesystem.de/) for Inspiration and Groundwork!
|
||||
|
||||
###### Greetz Schrolli
|
||||
|
|
|
|||
126
boswatch.py
126
boswatch.py
|
|
@ -131,16 +131,23 @@ try:
|
|||
zvei_id = 0
|
||||
zvei_id_old = 0
|
||||
zvei_time_old = 0
|
||||
|
||||
poc_id = 0
|
||||
poc_id_old = 0
|
||||
poc_time_old = 0
|
||||
|
||||
|
||||
#ConfigParser
|
||||
log("reading config file")
|
||||
try:
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(script_path+"/config.ini")
|
||||
config.read(script_path+"/config/config.ini")
|
||||
fms_double_ignore_time = int(config.get("FMS", "double_ignore_time"))
|
||||
zvei_double_ignore_time = int(config.get("ZVEI", "double_ignore_time"))
|
||||
|
||||
poc_double_ignore_time = int(config.get("POC", "double_ignore_time"))
|
||||
poc_filter_range_start = int(config.get("POC", "filter_range_start"))
|
||||
poc_filter_range_end = int(config.get("POC", "filter_range_end"))
|
||||
|
||||
#MySQL config
|
||||
useMySQL = int(config.get("Module", "useMySQL")) #use MySQL support?
|
||||
if useMySQL: #only if MySQL is active
|
||||
|
|
@ -165,9 +172,13 @@ try:
|
|||
log("set to standard configuration")
|
||||
fms_double_ignore_time = 5
|
||||
zvei_double_ignore_time = 5
|
||||
poc_double_ignore_time = 10
|
||||
poc_filter_range_start = 0000000
|
||||
poc_filter_range_end = 9999999
|
||||
useMySQL = 0
|
||||
useHTTPrequest = 0
|
||||
|
||||
|
||||
|
||||
if useMySQL: #only if MySQL is active
|
||||
log("testing MySQL connection")
|
||||
|
|
@ -312,6 +323,115 @@ try:
|
|||
log("ZVEI to HTTP failed","error")
|
||||
else:
|
||||
log("No valid ZVEI: "+zvei_id)
|
||||
#POCSAG512 Decoder Section
|
||||
#check POCSAG512: -> validate -> check double alarm -> log -> (MySQL)
|
||||
#POCSAG512: Address: 1234567 Function: 1 Alpha: XXMSG MEfeweffsjh
|
||||
|
||||
if "POCSAG512:" in decoded:
|
||||
log("recived POCSAG512")
|
||||
poc_id = decoded[20:27] #POC Code
|
||||
poc_sub = decoded[39].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
|
||||
if decoded.__contains__("Alpha:"):
|
||||
poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip()
|
||||
else:
|
||||
poc_text = ""
|
||||
if len(poc_id) == 7: #if POC is valid
|
||||
if poc_id >= poc_filter_range_start:
|
||||
if poc_id >= poc_filter_range_start:
|
||||
if poc_id == poc_id_old and timestamp < poc_time_old + poc_double_ignore_time: #check for double alarm
|
||||
log("POC512 double alarm: "+poc_id_old)
|
||||
poc_time_old = timestamp #in case of double alarm, poc_double_ignore_time set new
|
||||
else:
|
||||
log("POCSAG512: "+poc_id+" "+poc_sub+" "+poc_text,"info")
|
||||
poc_id_old = poc_id #save last id
|
||||
poc_time_old = timestamp #save last time
|
||||
|
||||
if useMySQL: #only if MySQL is active
|
||||
log("POC to MySQL")
|
||||
try:
|
||||
connection = mysql.connector.connect(host = str(dbserver), user = str(dbuser), passwd = str(dbpassword), db = str(database))
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("INSERT INTO "+tablePOC+" (time,ric,funktion,text) VALUES (%s,%s,%s,%s)",(curtime(),poc_id,poc_sub,poc_text,))
|
||||
cursor.close()
|
||||
connection.commit()
|
||||
except:
|
||||
log("POC512 to MySQL failed","error")
|
||||
finally:
|
||||
connection.close() #Close connection in every case
|
||||
|
||||
if useHTTPrequest: #only if HTTPrequest is active
|
||||
log("POC512 to HTTP")
|
||||
try:
|
||||
httprequest = httplib.HTTPConnection(url)
|
||||
httprequest.request("HEAD", "/")
|
||||
httpresponse = httprequest.getresponse()
|
||||
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
|
||||
log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason))
|
||||
else:
|
||||
log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason),"error")
|
||||
except:
|
||||
log("POCSAG512 to HTTP failed","error")
|
||||
else:
|
||||
log("POCSAG512: "+poc_id+" out of filter range! Nothing to do.","info")
|
||||
else:
|
||||
log("POCSAG512: "+poc_id+" out of filter range! Nothing to do.","info")
|
||||
else:
|
||||
log("No valid POCSAG512: "+poc_id)
|
||||
|
||||
#POCSAG1200 Decoder Section
|
||||
#check POCSAG1200: -> validate -> check double alarm -> log -> (MySQL)
|
||||
#POCSAG1200: Address: 1234567 Function: 1 Alpha: XXMSG MEfeweffsjh
|
||||
|
||||
if "POCSAG1200:" in decoded:
|
||||
log("recived POCSAG1200")
|
||||
poc_id = decoded[21:28] #POC Code
|
||||
poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
|
||||
if decoded.__contains__("Alpha:"):
|
||||
poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip()
|
||||
else:
|
||||
poc_text = ""
|
||||
if len(poc_id) == 7: #if POC is valid
|
||||
if poc_id >= poc_filter_range_start:
|
||||
if poc_id >= poc_filter_range_start:
|
||||
if poc_id == poc_id_old and timestamp < poc_time_old + poc_double_ignore_time: #check for double alarm
|
||||
log("POC1200 double alarm: "+poc_id_old)
|
||||
poc_time_old = timestamp #in case of double alarm, poc_double_ignore_time set new
|
||||
else:
|
||||
log("POCSAG1200: "+poc_id+" "+poc_sub+" "+poc_text,"info")
|
||||
poc_id_old = poc_id #save last id
|
||||
poc_time_old = timestamp #save last time
|
||||
|
||||
if useMySQL: #only if MySQL is active
|
||||
log("POC to MySQL")
|
||||
try:
|
||||
connection = mysql.connector.connect(host = str(dbserver), user = str(dbuser), passwd = str(dbpassword), db = str(database))
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("INSERT INTO "+tablePOC+" (time,ric,funktion,text) VALUES (%s,%s,%s,%s)",(curtime(),poc_id,poc_sub,poc_text,))
|
||||
cursor.close()
|
||||
connection.commit()
|
||||
except:
|
||||
log("POC1200 to MySQL failed","error")
|
||||
finally:
|
||||
connection.close() #Close connection in every case
|
||||
|
||||
if useHTTPrequest: #only if HTTPrequest is active
|
||||
log("POC1200 to HTTP")
|
||||
try:
|
||||
httprequest = httplib.HTTPConnection(url)
|
||||
httprequest.request("HEAD", "/")
|
||||
httpresponse = httprequest.getresponse()
|
||||
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
|
||||
log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason))
|
||||
else:
|
||||
log("HTTP response: "+str(httpresponse.status)+" - "+str(httpresponse.reason),"error")
|
||||
except:
|
||||
log("POCSAG1200 to HTTP failed","error")
|
||||
else:
|
||||
log("POCSAG1200: "+poc_id+" out of filter range! Nothing to do.","info")
|
||||
else:
|
||||
log("POCSAG1200: "+poc_id+" out of filter range! Nothing to do.","info")
|
||||
else:
|
||||
log("No valid POCSAG1200: "+poc_id)
|
||||
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
|
@ -324,4 +444,4 @@ finally:
|
|||
multimon_ng.terminate()
|
||||
log("multimon-ng terminated")
|
||||
log("exiting BOSWatch")
|
||||
exit(0)
|
||||
exit(0)
|
||||
|
|
|
|||
20
config.ini
20
config.ini
|
|
@ -10,23 +10,29 @@ double_ignore_time = 5
|
|||
#time to ignore same alarm in a row (sek)
|
||||
double_ignore_time = 5
|
||||
|
||||
[POC]
|
||||
#time to ignore same alarm in a row (sek)
|
||||
double_ignore_time = 10
|
||||
filter_range_start = 0000000
|
||||
filter_range_end = 9999999
|
||||
|
||||
#can take on or off the modules (0|1)
|
||||
[Module]
|
||||
useMySQL = 0
|
||||
useMySQL = 1
|
||||
#useAudiorecord = 0
|
||||
useHTTPrequest = 0
|
||||
|
||||
[MySQL]
|
||||
#Data for MySQL connection
|
||||
dbserver = localhost
|
||||
dbuser = root
|
||||
dbpassword = root
|
||||
database = boswatch
|
||||
dbserver = www.bos-tec.de
|
||||
dbuser = raspoc
|
||||
dbpassword = 080787
|
||||
database = bos-tec.de
|
||||
|
||||
#tables in the database
|
||||
tableFMS = bos_fms
|
||||
tableZVEI = bos_zvei
|
||||
tablePOC = bos_pocsag
|
||||
tablePOC = pocsag_hist
|
||||
|
||||
#[Audiorecord]
|
||||
#recording time (sek)
|
||||
|
|
@ -34,4 +40,4 @@ tablePOC = bos_pocsag
|
|||
|
||||
[HTTPrequest]
|
||||
#url without http:// !
|
||||
url = www.google.de
|
||||
url = www.google.de
|
||||
|
|
|
|||
Loading…
Reference in a new issue