Currently, the Packet class is a poor abstraction. It holds all possible parameters for each implemented different type of APRS packet. This approach of a single class for all packets leads to bloated code (the file is currently over 400 lines), difficulty of displaying relevant fields (all fields are nullable and leaves the UI to find what isn't null), and difficulty of plugging in new packet decode types (long switch statements, difficult test cases, etc.)
This PR breaks the Packet abstraction up by introducing a separate family of classes to represent the APRS info field. The Packet class is now meant to hold information all packets will provide in the network layer (i.e., TNC2 or AX.25) (path, sender, received time, etc.) plus an information field, which holds relevant information in encoded in the packet.
The InfoField class is abstract and extended by classes representing each group of APRS packets, grouped by logical similarity of use, encoding, and data. The InfoField classes take either the encoded string to decode or the specific arguments to encode, which makes encoding new packets much easier.
The result is classes that are well-normalized and no files over 175 lines. Packet.cs is now at only 41 lines, which is under 10% of its original length.
This is a large PR, but remember that nearly 90% of line changes have the same logic moved to new files being validated by the same test.
Resolves #77
Changes
Separate APRS information field parsing in to a new InfoField class
Implement logic for position, status, and maidenhead beacon (the three groups of packets which were already implemented)
Added very basic TNC2 parsing out by just splitting on the character used to separate TNC2 fields from the APRS info field (to allow for manual validation using APRS-IS packets)
Updated unit tests. Same logic was used for this change, just updated to match refactors.
Validation
Build, unit tests, and linting pass
dotnet run in src/APRSsharp pulls and decodes real packets from APRS-IS and appears to be working well. Example output below.
Description
Currently, the
Packet
class is a poor abstraction. It holds all possible parameters for each implemented different type of APRS packet. This approach of a single class for all packets leads to bloated code (the file is currently over 400 lines), difficulty of displaying relevant fields (all fields are nullable and leaves the UI to find what isn't null), and difficulty of plugging in new packet decode types (long switch statements, difficult test cases, etc.)This PR breaks the
Packet
abstraction up by introducing a separate family of classes to represent the APRS info field. ThePacket
class is now meant to hold information all packets will provide in the network layer (i.e., TNC2 or AX.25) (path, sender, received time, etc.) plus an information field, which holds relevant information in encoded in the packet.The
InfoField
class is abstract and extended by classes representing each group of APRS packets, grouped by logical similarity of use, encoding, and data. TheInfoField
classes take either the encoded string to decode or the specific arguments to encode, which makes encoding new packets much easier.The result is classes that are well-normalized and no files over 175 lines. Packet.cs is now at only 41 lines, which is under 10% of its original length.
This is a large PR, but remember that nearly 90% of line changes have the same logic moved to new files being validated by the same test.
Resolves #77
Changes
InfoField
classValidation
dotnet run
insrc/APRSsharp
pulls and decodes real packets from APRS-IS and appears to be working well. Example output below.