Added third-party packet support
This commit is contained in:
parent
94b89a6da4
commit
e7dfd147bb
|
|
@ -41,6 +41,7 @@ from aprslib.parsing.position import *
|
||||||
from aprslib.parsing.mice import *
|
from aprslib.parsing.mice import *
|
||||||
from aprslib.parsing.message import *
|
from aprslib.parsing.message import *
|
||||||
from aprslib.parsing.telemetry import *
|
from aprslib.parsing.telemetry import *
|
||||||
|
from aprslib.parsing.thirdparty import *
|
||||||
from aprslib.parsing.weather import *
|
from aprslib.parsing.weather import *
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,9 +159,14 @@ def _try_toparse_body(packet_type, body, parsed):
|
||||||
# ] - unused
|
# ] - unused
|
||||||
# ^ - unused
|
# ^ - unused
|
||||||
# } - 3rd party traffic
|
# } - 3rd party traffic
|
||||||
if packet_type in '#$%)*<?T[}':
|
if packet_type in '#$%)*<?T[':
|
||||||
raise UnknownFormat("format is not supported")
|
raise UnknownFormat("format is not supported")
|
||||||
|
|
||||||
|
# 3rd party traffic
|
||||||
|
elif packet_type == '}':
|
||||||
|
logger.debug("Packet is third-party")
|
||||||
|
body, result = parse_thirdparty(body)
|
||||||
|
|
||||||
# user defined
|
# user defined
|
||||||
elif packet_type == ',':
|
elif packet_type == ',':
|
||||||
logger.debug("Packet is invalid format")
|
logger.debug("Packet is invalid format")
|
||||||
|
|
|
||||||
|
|
@ -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':'thirdparty'}
|
||||||
|
|
||||||
|
# Parse sub-packet
|
||||||
|
try:
|
||||||
|
subpacket = parse(body)
|
||||||
|
except (UnknownFormat) as ukf:
|
||||||
|
raise
|
||||||
|
|
||||||
|
parsed.update({'subpacket':subpacket})
|
||||||
|
|
||||||
|
return('',parsed)
|
||||||
Loading…
Reference in New Issue