WirelessPacketCollector
WirelessPacketCollector

Class that sets/matches expected responses, and stores all the wireless packets

Functions
WirelessPacketCollector
WirelessPacketCollector()

The default constructor for the WirelessPacketCollector

WirelessPacketCollector
~WirelessPacketCollector()

The destructor for the WirelessPacketCollector

Variables
m_dataPackets
circular_data_buffer m_dataPackets

A circular buffer that holds WirelessDataPackets

m_nodeDiscoveryPackets
circular_discovery_buffer m_nodeDiscoveryPackets

A circular buffer that holds NodeDiscovery objects

m_currentDataPacket
WirelessDataPacket m_currentDataPacket

The current WirelessDataPacket in the buffer

m_packetMutex
std::mutex m_packetMutex

A mutex used for thread safety when accessing/modifying the m_dataPackets buffer

m_nodeDiscoveryMutex
std::mutex m_nodeDiscoveryMutex

A mutex used for thread safety when accessing/modifying the m_nodeDiscoveryPackets buffer

m_emptyBufferCondition
std::condition_variable m_emptyBufferCondition

Allows the write to buffer thread to tell the reading thread when data is available

Functions
addDataPacket
void addDataPacket(
const WirelessPacket &packet
)

Adds a data packet to the data packets circular buffer.

Parameters
packet

The WirelessPacket to be added to the buffer.

addNodeDiscoveryPacket
void addNodeDiscoveryPacket(
const WirelessPacket &packet
)

Adds a Node Discovery packet to the circular buffer.  The provided WirelessPacket must be a valid Node Discovery packet.

Parameters
packet

The WirelessPacket to be added to the buffer.

getDataSweeps
void getDataSweeps(
std::vector<DataSweep&sweeps,
uint32 timeout 0,
uint32 maxSweeps 0
)

Gets up to the requested amount of data sweeps that have been collected.

Parameters
sweeps
std::vector<DataSweep>&

A vector of DataSweep objects to hold the result.

timeout
uint32

The timeout, in milliseconds, to wait for data if necessary (default of 0).

maxSweeps
uint32

The maximum number of sweeps to return. If this is 0 (default), all sweeps will be returned.

totalSweeps
uint32 totalSweeps()

Gets the total number of data sweeps that are currently in the buffer.

Returns

The total number of data sweeps that are currently in the buffer.

getNodeDiscoveries
NodeDiscoveries getNodeDiscoveries()

Gets a vector of NodeDiscovery objects that were collected

Returns

A NodeDiscoveries object contain all the NodeDiscovery objects that were collected

getNextDataPacket
WirelessDataPacket getNextDataPacket(
int timeout
)

Gets the next WirelessDataPacket in the buffer

Parameters
timeout
int

the timeout, in milliseconds, to wait for the next data packet if necessary

Returns

The next WirelessDataPacket that was collected

Exceptions