Created custom telemetry packet report

Modeled off of the PositionReport class, I created a TelemetryReport and
used similar serialization to create a working packet that was uploaded to
aprs.fi for testing.
This commit is contained in:
kb1lqc 2017-03-10 01:14:22 -08:00
parent 9cee09b7a8
commit fa63671ae9
2 changed files with 33 additions and 0 deletions

View File

@ -1 +1,2 @@
from aprslib.packets.position import PositionReport
from aprslib.packets.telemetry import TelemetryReport

View File

@ -0,0 +1,32 @@
from aprslib.packets.base import APRSPacket
class TelemetryReport(APRSPacket):
format = 'raw'
sequenceno = 0
analog1 = 0
analog2 = 0
analog3 = 0
analog4 = 0
analog5 = 0
digitalvalue = ['0']*8
comment = ''
def _serialize_body(self):
# What do we do when len(digitalvalue) != 8?
self.digitalvalue = ''.join(self.digitalvalue)
body = [
'T#', # packet type
str(self.sequenceno).zfill(3),
str(self.analog1).zfill(3),
str(self.analog2).zfill(3),
str(self.analog3).zfill(3),
str(self.analog4).zfill(3),
str(self.analog5).zfill(3),
str(self.digitalvalue),
self.comment,
]
tmpbody = ",".join(body)
# remove static but erroneous comma between T# and sequenceno
return tmpbody[:2] + tmpbody[3:]