MeshNet  1.0.0
Static Public Member Functions | Static Public Attributes | Private Member Functions
PingPD Class Reference

Static class, that groups static methods to decode ping packet. More...

#include <meshPacketDecoders.h>

Static Public Member Functions

static bool IsSameType (const MeshPacket &packet)
 Checks if system packet type match decoder type, but does not check its validity. More...
 
static bool IsValid (const MeshPacket &packet)
 Checks if packet is valid. More...
 
static MeshPingFlags GetFlags (const MeshPacket &packet)
 Gets ping packet flags. First flags says, if current packet is response or request. More...
 
static void SetFlags (MeshPacket &packet, MeshPingFlags flags)
 Sets ping packet flags. First flags says, if current packet is response or request. More...
 
static uint32_t GetPingStartTime (const MeshPacket &packet)
 Gets time, when ping was sent. More...
 
static void SetPingStartTime (MeshPacket &packet, uint32_t pingStartTime)
 Sets time, when ping was sent. More...
 
static uint32_t GetPingID (const MeshPacket &packet)
 Gets ping packet ID. More...
 
static void SetPingID (MeshPacket &packet, uint8_t pingID)
 Sets ping packet ID. More...
 
static uint8_t * GetTestDataPtr (const MeshPacket &packet)
 Gets pointer to test data in ping packet. More...
 
static bool GetTestData (const MeshPacket &packet, uint8_t *testData, int16_t &length)
 Copyies test data from ping packet to buffer. More...
 
static int16_t GetTestDataLength (const MeshPacket &packet)
 Gets length of test data. More...
 
static bool SetTestData (MeshPacket &packet, const uint8_t *testData, int16_t length, bool resize=true)
 Sets test data to ping packet. More...
 
static bool SetRandomTestData (MeshPacket &packet, int16_t length, bool resize=true)
 Sets random test data to ping packet. More...
 
static bool Construct (MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshPingFlags flags, uint32_t pingStartTime, int16_t testDataLength=0)
 Constructs packet of current type. More...
 
static bool Construct (MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshPingFlags flags, uint32_t pingStartTime, const uint8_t *testData, int16_t testDataLength)
 Constructs packet of current type. More...
 

Static Public Attributes

const static SystemPacketType Type = SPT_Ping
 Type of system packet, that can be decoded with current decoder. More...
 

Private Member Functions

 PingPD ()
 

Detailed Description

Static class, that groups static methods to decode ping packet.

Constructor & Destructor Documentation

◆ PingPD()

PingPD::PingPD ( )
inlineprivate

Member Function Documentation

◆ Construct() [1/2]

static bool PingPD::Construct ( MeshPacket packet,
uint8_t  sourceAddr,
uint8_t  destAddr,
MeshPingFlags  flags,
uint32_t  pingStartTime,
const uint8_t *  testData,
int16_t  testDataLength 
)
inlinestatic

Constructs packet of current type.

Parameters
sourceAddrSource node address.
destAddrDestination node address.
[in]packetSystem packet to construct.
flagsPing packet flags.
pingStartTimeTime when ping was sent in [ms]. Note, that this is time from program start, that can be get using millis() function.
testDataBuffer containing test data.
testDataLengthLength of test data buffer. Allowed values: 0-500.
Returns
Returns true when packet was constructed successfully.

◆ Construct() [2/2]

static bool PingPD::Construct ( MeshPacket packet,
uint8_t  sourceAddr,
uint8_t  destAddr,
MeshPingFlags  flags,
uint32_t  pingStartTime,
int16_t  testDataLength = 0 
)
inlinestatic

Constructs packet of current type.

Parameters
sourceAddrSource node address.
destAddrDestination node address.
[in]packetSystem packet to construct.
flagsPing packet flags.
pingStartTimeTime when ping was sent in [ms]. Note, that this is time from program start, that can be get using millis() function.
testDataLengthLength of test data. Allowed values: 0-500. Test data are randomly generated.
Returns
Returns true when packet was constructed successfully.

◆ GetFlags()

static MeshPingFlags PingPD::GetFlags ( const MeshPacket packet)
inlinestatic

Gets ping packet flags. First flags says, if current packet is response or request.

Parameters
[in]packetSystem packet to decode.
Returns
Ping packet scan flags.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetPingID()

static uint32_t PingPD::GetPingID ( const MeshPacket packet)
inlinestatic

Gets ping packet ID.

Parameters
[in]packetSystem packet to decode.
Returns
Ping packet ID.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetPingStartTime()

static uint32_t PingPD::GetPingStartTime ( const MeshPacket packet)
inlinestatic

Gets time, when ping was sent.

Parameters
[in]packetSystem packet to decode.
Returns
Time when ping was sent in [ms]. Note, that this is time from program start, that can be get using millis() function.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetTestData()

static bool PingPD::GetTestData ( const MeshPacket packet,
uint8_t *  testData,
int16_t &  length 
)
inlinestatic

Copyies test data from ping packet to buffer.

Parameters
[in]packetSystem packet to decode.
[out]testDataBuffer, where test data will be copyied. Buffer has to have minimum size of number that returns GetTestDataLength() in bytes.
[in,out]lengthInput size of buffer first, after calling this method it contains length of test data.
Returns
Returns True when test data were copyied without truncating.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetTestDataLength()

static int16_t PingPD::GetTestDataLength ( const MeshPacket packet)
inlinestatic

Gets length of test data.

Parameters
[in]packetSystem packet to decode.
Returns
Returns length of test data in bytes.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetTestDataPtr()

static uint8_t* PingPD::GetTestDataPtr ( const MeshPacket packet)
inlinestatic

Gets pointer to test data in ping packet.

Parameters
[in]packetSystem packet to decode.
Returns
Returns pointer to ping packet test data or NULL when there are no ping test data.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ IsSameType()

static bool PingPD::IsSameType ( const MeshPacket packet)
inlinestatic

Checks if system packet type match decoder type, but does not check its validity.

Parameters
[in]packetSystem packet to decode.
Returns
True when this decoder should be used to decode current system packet.

◆ IsValid()

static bool PingPD::IsValid ( const MeshPacket packet)
inlinestatic

Checks if packet is valid.

Parameters
[in]packetSystem packet to decode.
Returns
True when packet is valid and can be decoded.
Warning
Invalid packet should not be decoded, because it can cause exception.

◆ SetFlags()

static void PingPD::SetFlags ( MeshPacket packet,
MeshPingFlags  flags 
)
inlinestatic

Sets ping packet flags. First flags says, if current packet is response or request.

Parameters
[in]packetSystem packet to decode.
flagsPing packet scan flags.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ SetPingID()

static void PingPD::SetPingID ( MeshPacket packet,
uint8_t  pingID 
)
inlinestatic

Sets ping packet ID.

Parameters
[in]packetSystem packet to decode.
pingIDPing packet ID. If this is request, this can be unset. If this is response, ID is same as request packet ID.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ SetPingStartTime()

static void PingPD::SetPingStartTime ( MeshPacket packet,
uint32_t  pingStartTime 
)
inlinestatic

Sets time, when ping was sent.

Parameters
[in]packetSystem packet to decode.
pingStartTimeTime when ping was sent in [ms]. Note, that this is time from program start, that can be get using millis() function.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ SetRandomTestData()

static bool PingPD::SetRandomTestData ( MeshPacket packet,
int16_t  length,
bool  resize = true 
)
inlinestatic

Sets random test data to ping packet.

Parameters
lengthLength of test data. Allowed values: 0-500.
resizeSet to true to automatically resize packet payload to fit test data. It is recommended to set it to true. Advanced: Set to false if packet payload can already fit test data without resizing.
Returns
Returns true when random test data was set.

◆ SetTestData()

static bool PingPD::SetTestData ( MeshPacket packet,
const uint8_t *  testData,
int16_t  length,
bool  resize = true 
)
inlinestatic

Sets test data to ping packet.

Parameters
[in]testDataTest data to set.
lengthLength of test data. Allowed values: 0-500.
resizeSet to true to automatically resize packet payload to fit test data. It is recommended to set it to true. Advanced: Set to false if packet payload can already fit test data without resizing.
Returns
Returns true when test data was set.

Field Documentation

◆ Type

const static SystemPacketType PingPD::Type = SPT_Ping
static

Type of system packet, that can be decoded with current decoder.


The documentation for this class was generated from the following file: