From 7a84eedebf7a97ecf25bca0e6ccbe84a4046fc0a Mon Sep 17 00:00:00 2001 From: Schrolli Date: Tue, 28 Apr 2015 11:20:51 +0200 Subject: [PATCH 1/4] little changes --- boswatch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/boswatch.py b/boswatch.py index 20893b5..51397ee 100644 --- a/boswatch.py +++ b/boswatch.py @@ -169,12 +169,15 @@ try: except: log("cannot read config file","error") + #in case of reading error, set standard values 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 + + #no config - no modules ;-) useMySQL = 0 useHTTPrequest = 0 @@ -336,7 +339,7 @@ try: if decoded.__contains__("Alpha:"): poc_text = decoded.split('Alpha: ')[1].strip().rstrip('').strip() else: - poc_text = "" + 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: @@ -392,7 +395,7 @@ try: if decoded.__contains__("Alpha:"): poc_text = decoded.split('Alpha: ')[1].strip().rstrip('').strip() else: - poc_text = "" + 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: From 139364a41ede3d98555e2bc9ad01734dae3b1189 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Tue, 28 Apr 2015 11:21:09 +0200 Subject: [PATCH 2/4] edit config --- config.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.ini b/config.ini index 32247f9..26e93b9 100644 --- a/config.ini +++ b/config.ini @@ -24,10 +24,10 @@ useHTTPrequest = 0 [MySQL] #Data for MySQL connection -dbserver = www.bos-tec.de -dbuser = raspoc -dbpassword = 080787 -database = bos-tec.de +dbserver = localhost +dbuser = root +dbpassword = root +database = boswatch #tables in the database tableFMS = bos_fms From 475e737a5736851073719de695125474544c0af1 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Tue, 28 Apr 2015 11:29:37 +0200 Subject: [PATCH 3/4] little POC changes --- boswatch.py | 180 +++++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 88 deletions(-) diff --git a/boswatch.py b/boswatch.py index 51397ee..c2793c8 100644 --- a/boswatch.py +++ b/boswatch.py @@ -334,54 +334,56 @@ try: #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:"): + if "Alpha:" in decoded: #check if there is a text message poc_text = decoded.split('Alpha: ')[1].strip().rstrip('').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!") - else: - log("POCSAG512: "+poc_id+" out of filter range!") - else: - log("No valid POCSAG512: "+poc_id) + 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") + else: + log("POCSAG512: "+poc_id+" out of filter range") + else: + log("No valid POCSAG512: "+poc_id) @@ -390,54 +392,56 @@ try: #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:"): + if "Alpha:" in decoded: #check if there is a text message poc_text = decoded.split('Alpha: ')[1].strip().rstrip('').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") - else: - log("POCSAG1200: "+poc_id+" out of filter range") - else: - log("No valid POCSAG1200: "+poc_id) + 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") + else: + log("POCSAG1200: "+poc_id+" out of filter range") + else: + log("No valid POCSAG1200: "+poc_id) except KeyboardInterrupt: From fcd6121b14e265a7bb0b566b84adedba27f7b73f Mon Sep 17 00:00:00 2001 From: Schrolli Date: Tue, 28 Apr 2015 11:34:13 +0200 Subject: [PATCH 4/4] edit readme --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a806541..868b628 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ unless you are developer you can use the develop-Branch - may be unstable! - 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 - 2400 support (need RAW data from multimon-ng) @@ -35,6 +35,7 @@ unless you are developer you can use the develop-Branch - may be unstable! ##### boswatch.py The configuration for the Script you can find in config.ini - You can set the ignore time for double alarms in seconds. +- you can adjust your rangefilter for POCSAG Decode. - to use the script with MySQL Support set "useMySQL = 1" and the Userdata to your local MySQL Database. - to use the script with HTTP request Support set "useHTTPrequest = 1" and set a URL to your destination. @@ -93,9 +94,6 @@ 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