WirelessParser
WirelessParser

Parses all wireless data and stores it in a corresponding container

Types
DuplicateCheckMap

A typedef for a map of NodeAddresses to a timestamp or tick value to check for packet duplication

ParsePacketResult
parsePacketResult_completePacket

The packet has been verified as a complete ASPP packet

parsePacketResult_invalidPacket

The packet is not a valid ASPP packet, at least one byte was incorrect

parsePacketResult_badChecksum

The packet looks like a valid ASPP packet, but the checksums do not match

parsePacketResult_notEnoughData

There is not enough data in the DataBuffer to determine if this is a valid/invalid ASPP packet

parsePacketResult_duplicate

The packet was a duplicate data packet of the last received packet

Functions
WirelessParser
WirelessParser(
WirelessPacketCollector &packetCollector,
std::weak_ptr<ResponseCollectorresponseCollector
)

Constructor for WirelessParser

Parameters
packetCollector

the WirelessPacketCollector to be associated with this parser

responseCollector
std::weak_ptr<ResponseCollector>

the ResponseCollector to be associated with this parser

Variables
m_packetCollector
WirelessPacketCollector& m_packetCollector

The WirelessPacketCollector associated with this parser and it's parent base station

m_responseCollector
std::weak_ptr<ResponseCollector> m_responseCollector

The ResponseCollector associated with this parser and it's parent base station

m_lastPacketMap
DuplicateCheckMap m_lastPacketMap

A DuplicateCheckMap containing node addresses and their uniqueId values

Functions
processPacket
void processPacket(
const WirelessPacket &packet,
std::size_t lastReadPos
)

Takes a WirelessPacket, adds it to the data container if it is a data packet, or adds it to the appropriate handler depending on the packet type

Parameters
packet

A verified, valid WirelessPacket

lastReadPos
std::size_t

The last read position where the packet was parsed from.

findMatchingResponse
bool findMatchingResponse(
DataBuffer &data
)

Takes a DataBuffer of bytes and checks if the packet collector has any responses it is waiting on.  If it does, and the bytes match the expected response, the bytes are "given" to the packet collector and the read position is moved.

Parameters
data

A DataBuffer containing bytes to parse

Returns

true if the bytes matched an expected response, false otherwise

findMatchingResponse
bool findMatchingResponse(
const WirelessPacket &packet,
std::size_t lastReadPos
)

Takes a WirelessPacket and checks if the packet collector has any responses it is waiting on.  If it does, and the packet matches the expected response, the packet is "given" to the packet collector.

Parameters
packet

A WirelessPacket to match against expected responses

lastReadPos
std::size_t

The last read position where the packet was parsed from.

Returns

true if the packet matched an expected response, false otherwise

isDuplicate
bool isDuplicate(
const WirelessPacket &packet
)

Checks whether the passed in packet is a duplicate of the previous packet that came in.

Parameters
packet

The WirelessPacket to check for duplicate.

Returns

true if the packet is a duplicate, false otherwise.

parseAsPacket
WirelessParser::ParsePacketResult parseAsPacket(
DataBuffer &data,
WirelessPacket &packet,
WirelessTypes::Frequency freq
)

Takes a DataBuffer that has had its read position moved to the start of a packet and verifies that the bytes form a valid ASPP packet.

Parameters
data

A DataBuffer with its read position at the start of a packet (0xAA).

packet

A WirelessPacket to hold all the packet information if the packet is verified from the DataBuffer.

freq

A WirelessTypes::Frequency representing the frequency that this data was collected on.

Returns

A ParsePacketResult describing if the packet was verified, or why it failed verification.

findPacketInBytes
bool findPacketInBytes(
DataBuffer &data,
WirelessTypes::Frequency freq
)

Checks for packets after the current bytes buffer's read position (starting at the next byte, not the current one).  If a packet is found, the packet is processed and the byte buffer's read position is moved.  If a packet is not found, nothing changes in the byte buffer

Parameters
data

The bytes to look through for a packet

freq

The WirelessTypes::Frequency that this data was collected on

Returns

true if an ASPP packet is found, false otherwise

parse
void parse(
DataBuffer &data,
WirelessTypes::Frequency freq
)

Takes a DataBuffer and finds the next ASPP Wireless Packet, or the next command response that is expected by the base station.

If an ASPP packet is found, the packet will be stored in the WirelessPacketCollector.  If a command response is found and is expected, it will be handled and passed to the base station directly.

Parameters
data

A DataBuffer containing bytes that should be parsed for MicroStrain packets.

freq

The WirelessTypes::Frequency representing the radio frequency that this data was collected on.