Example #1
0
def decode(freq, decoded):
	"""
	Export FMS Information from Multimon-NG RAW 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 FMS decode failed
	"""
	try:
		fms_service = decoded[19]            # Organisation
		fms_country = decoded[36]            # Bundesland
		fms_location = decoded[61:63]        # Ort
		fms_vehicle = decoded[72:76]         # Fahrzeug
		fms_status = decoded[84]             # Status
		fms_direction = decoded[101]         # Richtung
		fms_directionText = decoded[103:110] # Richtung (Text)
		fms_tsi = decoded[114:117]           # Taktische Kruzinformation

		proceed = True # no CRC-check required - proceed

		# shall we use the CRC-check?
		if (globalVars.config.getboolean("FMS", "CheckCRC")):
			if "CRC correct" not in decoded:
				# if CRC must be checked and is not correct - dont proceed
				proceed = False

		if (proceed == True):
			fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction # build FMS id
			# if FMS is valid
			if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id):
				# check for double alarm
				if doubleFilter.checkID("FMS", fms_id):
					logging.info("FMS:%s Status:%s Richtung:%s TSI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi)
					data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "directionText":fms_directionText, "tsi":fms_tsi, "description":fms_id[0:8]}
					# If enabled, look up description
					if globalVars.config.getint("FMS", "idDescribed"):
						from includes import descriptionList
						data["description"] = descriptionList.getDescription("FMS", fms_id[0:8])
					# processing the alarm
					try:
						from includes import alarmHandler
						alarmHandler.processAlarmHandler("FMS", 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(fms_id)
			else:
				logging.warning("No valid FMS: %s", fms_id)
		else:
			logging.warning("FMS CRC incorrect")
	except:
		logging.error("error while decoding")
		logging.debug("error while decoding", exc_info=True)
Example #2
0
def decode(freq, decoded):
    """
	Export ZVEI Information from Multimon-NG RAW String and call alarmHandler.processAlarm()

	@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 ZVEI decode failed
	"""
    try:
        zvei_id = decoded[7:12]  # ZVEI Code
        zvei_id = removeF(zvei_id)  # resolve F
        if re.search("[0-9]{5}", zvei_id):  # if ZVEI is valid
            # check for double alarm
            if doubleFilter.checkID("ZVEI", zvei_id):
                logging.info("5-Ton: %s", zvei_id)
                data = {"zvei": zvei_id, "description": zvei_id}
                # If enabled, look up description
                if globals.config.getint("ZVEI", "idDescribed"):
                    from includes import descriptionList
                    data["description"] = descriptionList.getDescription(
                        "ZVEI", zvei_id)
                # processing the alarm
                try:
                    from includes import alarmHandler
                    alarmHandler.processAlarm("ZVEI", freq, data)
                except:
                    logging.error("processing alarm failed")
                    logging.debug("processing alarm failed", exc_info=True)
                    pass
            # in every time save old data for double alarm
            doubleFilter.newEntry(zvei_id)
        else:
            logging.warning("No valid ZVEI: %s", zvei_id)
    except:
        logging.error("error while decoding")
        logging.debug("error while decoding", exc_info=True)
Example #3
0
def decode(freq, decoded):
	"""
	Export ZVEI Information from Multimon-NG RAW String and call alarmHandler.processAlarm()

	@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 ZVEI decode failed
	"""
	try:
		zvei_id = decoded[7:12]    # ZVEI Code
		zvei_id = removeF(zvei_id) # resolve F
		if re.search("[0-9]{5}", zvei_id): # if ZVEI is valid
			# check for double alarm
			if doubleFilter.checkID("ZVEI", zvei_id):
				logging.info("5-Ton: %s", zvei_id)
				data = {"zvei":zvei_id, "description":zvei_id}
				# If enabled, look up description
				if globals.config.getint("ZVEI", "idDescribed"):
					from includes import descriptionList
					data["description"] = descriptionList.getDescription("ZVEI", zvei_id)
				# processing the alarm
				try:
					from includes import alarmHandler
					alarmHandler.processAlarm("ZVEI", freq, data)
				except:
					logging.error("processing alarm failed")
					logging.debug("processing alarm failed", exc_info=True)
					pass
			# in every time save old data for double alarm
			doubleFilter.newEntry(zvei_id)
		else:
			logging.warning("No valid ZVEI: %s", zvei_id)
	except:
		logging.error("error while decoding")
		logging.debug("error while decoding", exc_info=True)
Example #4
0
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
	"""
    has_geo = False

    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()
                if globalVars.config.getint("POC", "geo_enable"):
                    try:
                        logging.debug(
                            "Using %s to find geo-tag in %s",
                            globalVars.config.get("POC", "geo_format"),
                            poc_text)
                        m = re.search(
                            globalVars.config.get("POC", "geo_format"),
                            poc_text)
                        if m:
                            logging.debug(
                                "Found geo-tag in message, parsing...")
                            has_geo = True
                            geo_order = globalVars.config.get(
                                "POC", "geo_order").split(',')
                            if geo_order[0].lower == "lon":
                                lat = m.group(1) + "." + m.group(2)
                                lon = m.group(3) + "." + m.group(4)
                            else:
                                lon = m.group(1) + "." + m.group(2)
                                lat = m.group(3) + "." + m.group(4)
                                logging.debug(
                                    "Finished parsing geo; lon: %s, lat: %s",
                                    lon, lat)
                        else:
                            logging.debug("No geo-tag found")
                            has_geo = False
                    except:
                        has_geo = False
                        logging.error("Exception parsing geo-information",
                                      exc_info=true)
                else:
                    has_geo = False
            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):
                        data = {
                            "ric": poc_id,
                            "function": poc_sub,
                            "msg": poc_text,
                            "bitrate": bitrate,
                            "description": poc_id,
                            "has_geo": has_geo
                        }
                        if has_geo == True:
                            data["lon"] = lon
                            data["lat"] = lat
                        # Add function as character a-d to dataset
                        data["functionChar"] = data["function"].replace(
                            "1",
                            "a").replace("2",
                                         "b").replace("3",
                                                      "c").replace("4", "d")
                        data[
                            "ricFuncChar"] = data["ric"] + data["functionChar"]

                        logging.info("POCSAG%s: %s %s %s ", data["bitrate"],
                                     data["ric"], data["function"],
                                     data["msg"])

                        # If enabled, look up description
                        if globalVars.config.getint("POC", "idDescribed"):
                            from includes import descriptionList
                            data[
                                "description"] = descriptionList.getDescription(
                                    "POC", data["ric"] + data["functionChar"])

                        # multicastAlarm processing if enabled and a message without text or delimiter RIC or netIdent_ric received
                        if globalVars.config.getint(
                                "multicastAlarm", "multicastAlarm"
                        ) and data["ric"] != globalVars.config.get(
                                "POC", "netIdent_ric") and (
                                    data["msg"] == ""
                                    or data["ric"] in globalVars.config.get(
                                        "multicastAlarm",
                                        "multicastAlarm_delimiter_ric")):
                            logging.debug(" - multicastAlarm without msg")
                            from includes import multicastAlarm
                            multicastAlarm.newEntrymultiList(data)

                        # multicastAlarm processing if enabled and alarm message has been received
                        elif globalVars.config.getint(
                                "multicastAlarm", "multicastAlarm"
                        ) and data["msg"] != "" and data[
                                "ric"] in globalVars.config.get(
                                    "multicastAlarm", "multicastAlarm_ric"):
                            logging.debug(" - multicastAlarm with message")
                            from includes import multicastAlarm
                            multicastAlarm.multicastAlarmExec(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)
Example #5
0
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)
                        # 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)
Example #6
0
def decode(freq, decoded):
	"""
	Export POCSAG Information from Multimon-NG RAW String and call alarmHandler.processAlarm()

	@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().rstrip('<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 globals.config.getint("POC", "idDescribed"):
							from includes import descriptionList
							data["description"] = descriptionList.getDescription("POC", poc_id)
						# processing the alarm
						try:
							from includes import alarmHandler
							alarmHandler.processAlarm("POC", freq, data)
						except:
							logging.error("processing alarm failed")
							logging.debug("processing alarm failed", exc_info=True)
							pass
					# 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)