BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
boswatch.wildcard Namespace Reference

Functions

def registerWildcard (wildcard, bwPacketField)
 Register a new additional wildcard.
 
def replaceWildcards (message, bwPacket)
 Replace the wildcards in a given message.
 

Variables

dict _additionalWildcards = {}
 

Detailed Description


/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / / __ / / / /__ | | /| / / __ `/ __/ ___/ __ \ /_ < / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / /_____/____//____/ |__/|__/__,_/__/___/_/ /_/ /____/ German BOS Information Script by Bastian Schroll

Function Documentation

◆ registerWildcard()

def boswatch.wildcard.registerWildcard (   wildcard,
  bwPacketField 
)

Register a new additional wildcard.

@param wildcard: New wildcard string with format: '{WILDCARD}'
@param bwPacketField: Field of the bwPacket which is used for wildcard replacement
27def registerWildcard(wildcard, bwPacketField):
28 r"""!Register a new additional wildcard
29
30 @param wildcard: New wildcard string with format: '{WILDCARD}'
31 @param bwPacketField: Field of the bwPacket which is used for wildcard replacement"""
32 if wildcard in _additionalWildcards:
33 logging.error("wildcard always registered: %s", wildcard)
34 return
35 logging.debug("register new wildcard %s for field: %s", wildcard, bwPacketField)
36 _additionalWildcards[wildcard] = bwPacketField
37
38

◆ replaceWildcards()

def boswatch.wildcard.replaceWildcards (   message,
  bwPacket 
)

Replace the wildcards in a given message.

@param message: Message in which wildcards should be replaced
@param bwPacket: bwPacket instance with the replacement information
@return Input message with the replaced wildcards
39def replaceWildcards(message, bwPacket):
40 r"""!Replace the wildcards in a given message
41
42 @param message: Message in which wildcards should be replaced
43 @param bwPacket: bwPacket instance with the replacement information
44 @return Input message with the replaced wildcards"""
45 _wildcards = {
46 # formatting wildcards
47 # todo check if br and par are needed - if not also change config
48 "{BR}": "\r\n",
49 "{LPAR}": "(",
50 "{RPAR}": ")",
51 "{TIME}": time.strftime("%d.%m.%Y %H:%M:%S"),
52
53 # info wildcards
54 # server
55 "{SNAME}": bwPacket.get("serverName"),
56 "{SVERS}": bwPacket.get("serverVersion"),
57 "{SDATE}": bwPacket.get("serverBuildDate"),
58 "{SBRCH}": bwPacket.get("serverBranch"),
59
60 # client
61 "{CNAME}": bwPacket.get("clientName"),
62 "{CIP}": bwPacket.get("clientIP"),
63 "{CVERS}": bwPacket.get("clientVersion"),
64 "{CDATE}": bwPacket.get("clientBuildDate"),
65 "{CBRCH}": bwPacket.get("clientBranch"),
66
67 # boswatch wildcards
68 "{INSRC}": bwPacket.get("inputSource"),
69 "{TIMES}": bwPacket.get("timestamp"),
70 "{FREQ}": bwPacket.get("frequency"),
71 "{MODE}": bwPacket.get("mode"),
72
73 # fms wildcards
74 "{FMS}": bwPacket.get("fms"),
75 "{SERV}": bwPacket.get("service"),
76 "{COUNT}": bwPacket.get("country"),
77 "{LOC}": bwPacket.get("location"),
78 "{VEHC}": bwPacket.get("vehicle"),
79 "{STAT}": bwPacket.get("status"),
80 "{DIR}": bwPacket.get("direction"),
81 "{DIRT}": bwPacket.get("directionText"),
82 "{TACI}": bwPacket.get("tacticalInfo"),
83
84 # pocsag wildcards
85 "{BIT}": bwPacket.get("bitrate"),
86 "{RIC}": bwPacket.get("ric"),
87 "{SRIC}": bwPacket.get("subric"),
88 "{SRICT}": bwPacket.get("subricText"),
89 "{MSG}": bwPacket.get("message"),
90
91 # zvei wildcards
92 "{TONE}": bwPacket.get("tone"),
93
94 # message for MSG packet is done in poc
95 }
96 for wildcard, field in _wildcards.items():
97 if field is not None:
98 message = message.replace(wildcard, field)
99
100 for wildcard, fieldName in _additionalWildcards.items():
101 field = bwPacket.get(fieldName)
102 if field is not None:
103 message = message.replace(wildcard, field)
104
105 return message

Variable Documentation

◆ _additionalWildcards

dict boswatch.wildcard._additionalWildcards = {}
protected