Added support for third-party packets

This commit is contained in:
Bill Mitchell 2018-02-07 13:56:28 -06:00
parent 1f485bf968
commit abe71698d4
2 changed files with 29 additions and 3 deletions

View File

@ -42,6 +42,7 @@ from aprslib.parsing.mice import *
from aprslib.parsing.message import *
from aprslib.parsing.telemetry import *
from aprslib.parsing.weather import *
from aprslib.parsing.thirdparty import *
def _unicode_packet(packet):
@ -157,7 +158,6 @@ def _try_toparse_body(packet_type, body, parsed):
'\\':'unused',
']':'unused',
'^':'unused',
'}':'3rd party traffic'
}
# NOT SUPPORTED FORMATS
#
@ -178,10 +178,15 @@ def _try_toparse_body(packet_type, body, parsed):
# \ - unused
# ] - unused
# ^ - unused
# } - 3rd party traffic
if packet_type in '#$%)*<?T[}':
if packet_type in '#$%)*<?T[':
raise UnknownFormat('format is not supported: {0}'.format(unsupported_formats[packet_type]))
# third party
elif packet_type == '}':
logger.debug("Packet is third-party")
body, result = parse_thirdparty(body)
# user defined
elif packet_type == ',':
logger.debug("Packet is invalid format")

View File

@ -0,0 +1,21 @@
import re
from aprslib.parsing.__init__ import parse
from aprslib.exceptions import UnknownFormat
from aprslib.exceptions import ParseError
__all__ = [
'parse_thirdparty',
]
def parse_thirdparty(body):
parsed = {'format':'Third party'}
# Parse sub-packet
try:
subpacket = parse(body)
except (UnknownFormat) as ukf:
subpacket = ukf.parsed
parsed.update({'subpacket':subpacket})
return('',parsed)