Decodes POCSAG.
34 def decode(data):
35 r"""!Decodes POCSAG
36
37 @param data: POCSAG for decoding
38 @return BOSWatch POCSAG packet or None"""
39 bitrate, ric, subric = PocsagDecoder._getBitrateRicSubric(data)
40
41 if re.search("[0-9]{7}", ric) and re.search("[1-4]", subric):
42 if "Alpha:" in data:
43 message = data.split('Alpha: ')[1].strip()
44 message = message.replace('<NUL>', '').replace('<NUL', '').replace('< NUL>', '').replace('<EOT>', '').strip()
45 else:
46 message = ""
47 subricText = subric.replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
48
49 logging.debug("found valid POCSAG")
50
51 bwPacket = Packet()
52 bwPacket.set("mode", "pocsag")
53 bwPacket.set("bitrate", bitrate)
54 bwPacket.set("ric", ric)
55 bwPacket.set("subric", subric)
56 bwPacket.set("subricText", subricText)
57 bwPacket.set("message", message)
58
59 return bwPacket
60
61 logging.warning("no valid POCSAG")
62 return None
63