added invalid & user-defined parsing
This commit is contained in:
parent
25dc1c0577
commit
88a15770ff
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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:],
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue