added invalid & user-defined parsing

This commit is contained in:
Rossen Georgiev 2016-01-21 05:00:41 +00:00
parent 25dc1c0577
commit 88a15770ff
2 changed files with 38 additions and 3 deletions

View File

@ -148,7 +148,6 @@ def _try_to_parse_body(packet_type, body, parsed):
# ) - item report
# * - complete weather report
# + - reserved
# , - invalid/test format
# - - unused
# . - reserved
# < - station capabilities
@ -158,11 +157,22 @@ def _try_to_parse_body(packet_type, body, parsed):
# \ - unused
# ] - unused
# ^ - unused
# { - user defined
# } - 3rd party traffic
if packet_type in '#$%)*,<?T[{}':
if packet_type in '#$%)*<?T[}':
raise UnknownFormat("format is not supported")
# user defined
elif packet_type == ',':
logger.debug("Packet is invalid format")
body, result = _parse_invalid(body)
# user defined
elif packet_type == '{':
logger.debug("Packet is user-defined")
body, result = _parse_user_defined(body)
# Status report
elif packet_type == '>':
logger.debug("Packet is just a status message")

View File

@ -4,6 +4,8 @@ from aprslib.parsing.common import _parse_timestamp
__all__ = [
'_parse_status',
'_parse_invalid',
'_parse_user_defined',
]
@ -20,3 +22,26 @@ def _parse_status(packet_type, body):
})
return (body, result)
# INVALID
#
# ,.........................
def _parse_invalid(body):
return ('', {
'format': 'invalid',
'body': body
})
# USER DEFINED
#
# {A1................
# {{.................
def _parse_user_defined(body):
return ('', {
'format': 'user-defined',
'id': body[0],
'type': body[1],
'body': body[2:],
})