Moin, moin,
so, bei mir läuft jetzt alles wie gewünscht.
Hier meine Code-Änderungen:
1.) config.ini
Code:
[Module]
useMySQL = 1
#useAudiorecord = 0
useHTTPrequest = 0
useBosMon = 1
Code:
[BosMon]
#Server without http://, as IP oder DNS-Name
bosmon_server = 192.168.0.1
bosmon_port = 80
bosmon_user = user
bosmon_password = password
#Channel of type "Web Telegramme"
bosmon_kanal = kanal
2.) boswatch.py
Code:
import urllib #for the HTTP request and BosMon with parameters
import base64 #for the HTTP request and BosMon with User/Password
Code:
#BosMon config
useBosMon = int(config.get("Module", "useBosMon")) #use BosMon support?
if useBosMon: #only if BosMon is active
bosmon_server = config.get("BosMon", "bosmon_server")
bosmon_port = config.get("BosMon", "bosmon_port")
bosmon_user = config.get("BosMon", "bosmon_user")
bosmon_password = config.get("BosMon", "bosmon_password")
bosmon_kanal = config.get("BosMon", "bosmon_kanal")
Code:
if useBosMon: #only if BosMon is active
log("POC512 to BosMon")
try:
#BosMon-Telegramin expected "a-d" as RIC-sub/function
bosmon_poc_sub = poc_sub.replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
params = urllib.urlencode({'type':'pocsag', 'address':poc_id, 'flags':'0', 'function':bosmon_poc_sub, 'message':poc_text})
headers = {}
headers['Content-type'] = "application/x-www-form-urlencoded"
headers['Accept'] = "text/plain"
if bosmon_user:
headers['Authorization'] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(bosmon_user, bosmon_password)))
httprequest = httplib.HTTPConnection(bosmon_server, bosmon_port)
httprequest.request("POST", "/telegramin/"+bosmon_kanal+"/input.xml", params, headers)
httpresponse = httprequest.getresponse()
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
log("BosMon response: "+str(httpresponse.status)+" - "+str(httpresponse.reason))
else:
log("BosMon response: "+str(httpresponse.status)+" - "+str(httpresponse.reason),"error")
except:
log("POCSAG512 to BosMon failed","error")
BosMon erwartet kein XML, es reicht ein einfacher Get/Post-Aufruf.
Die Parametrisierung ist aber schon speziell (z.B. Funktion a-d)
Was in der BosMon-Schnittstelle "Flags" bedeutet, entzieht sich meiner Kenntnis, bezieht sich evtl. auf andere Protokolle, ich habe nur POCSAG berücksichtigt.
Viel Spaß beim Einbauen ;)
Grüße
Jens