mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-03-19 19:24:42 +01:00
little POC changes
This commit is contained in:
parent
139364a41e
commit
475e737a57
180
boswatch.py
180
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('<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!")
|
||||
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('<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")
|
||||
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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue