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

Static class, that groups static methods to decode network scan response 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 bool IsValid (const MeshPacketHeader &packetHeader, const uint8_t *frameData, uint8_t frameDataSize)
 Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder. More...
 
static MeshVersion GetNetVersion (const MeshPacket &packet)
 Gets version of used MeshNet. More...
 
static void SetNetVersion (MeshPacket &packet, MeshVersion version)
 Sets version of used MeshNet. More...
 
static MeshNodeDescFlags GetFlags (const MeshPacket &packet)
 Gets network scan response flags. More...
 
static void SetFlags (MeshPacket &packet, MeshNodeDescFlags flags)
 Sets network scan flags. More...
 
static MeshMAC GetForeignNetBSSID (const MeshPacket &packet)
 Gets BSSID of foreign network, which has to receive this frame. More...
 
static MeshMAC GetForeignNetBSSID (const uint8_t *frameData)
 Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking in MeshPacketBuilder. More...
 
static void SetForeignNetBSSID (MeshPacket &packet, MeshMAC foreignBSSID)
 Sets BSSID of foreign network, which has to receive this frame. More...
 
static uint8_t GetHopsToGateway (const MeshPacket &packet)
 Gets hop count of node to its gateway connection. More...
 
static bool IsDisconnectedNode (const MeshPacket &packet)
 Checks if node is connected to any network or not. If this returns true, the BSSID of network which is it connected to is contained in packet header. MeshPacketHeader does not contains BSSID field, that's why you have to get it from MeshPacketBuilder after building packet. More...
 
static void SetHopsToGateway (MeshPacket &packet, uint8_t hops)
 Sets hop count of node to its gateway connection. More...
 
static char * GetSSIDPtr (const MeshPacket &packet)
 Gets pointer to network SSID. The SSID is not null terminated, that's why you have to check itslength using GetSSIDLength(). If IsDisconnectedNode() method returns true, packet does not contain SSID. More...
 
static bool GetSSID (const MeshPacket &packet, char *SSID, uint8_t &SSID_length)
 Copyies SSID from packet to buffer. The SSID is null terminated here. If IsDisconnectedNode() method returns true, packet does not contain SSID. More...
 
static uint16_t GetSSIDLength (const MeshPacket &packet)
 Gets length of SSID. More...
 
static bool SetSSID (MeshPacket &packet, const char *SSID, uint8_t SSID_length, bool resize=true)
 Sets SSID of network to packet. More...
 
static MeshNetScanResult GetResult (const MeshPacket &packet, MeshMAC BSSID)
 Converts data from packet to MeshNetScanResult. More...
 
static bool Construct (MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshVersion version, MeshNodeDescFlags flags, MeshMAC foreignBSSID, uint8_t hops, const char *SSID, uint8_t SSID_length)
 Constructs packet of current type. Use this method when node is connected to some network. More...
 
static bool Construct (MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, MeshVersion version, MeshNodeDescFlags flags, MeshMAC foreignBSSID, uint8_t hops)
 Constructs packet of current type. Use this method when node is not connected to any network. More...
 
static bool Construct (MeshPacket &packet, uint8_t destAddr, const MeshNetScanResult &result, MeshMAC foreignBSSID)
 Constructs packet of current type. More...
 

Static Public Attributes

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

Private Member Functions

 NetScanRespPD ()
 

Detailed Description

Static class, that groups static methods to decode network scan response packet.

Constructor & Destructor Documentation

◆ NetScanRespPD()

NetScanRespPD::NetScanRespPD ( )
inlineprivate

Member Function Documentation

◆ Construct() [1/3]

static bool NetScanRespPD::Construct ( MeshPacket packet,
uint8_t  destAddr,
const MeshNetScanResult result,
MeshMAC  foreignBSSID 
)
inlinestatic

Constructs packet of current type.

Parameters
[in]packetSystem packet to construct.
destAddrDestination node address.
foreignBSSIDBSSID of foreign network, which has to receive this frame.
[in]resultMeshNetScanResult, which contains almost all scan result info. It is used to set Source address, Version, Flags, HopsToGateway and SSID if set. If no SSID is available, set SSID_ptr to NULL and SSID_length to 0.
Returns
Returns true when packet was constructed successfully.

◆ Construct() [2/3]

static bool NetScanRespPD::Construct ( MeshPacket packet,
uint8_t  sourceAddr,
uint8_t  destAddr,
MeshVersion  version,
MeshNodeDescFlags  flags,
MeshMAC  foreignBSSID,
uint8_t  hops 
)
inlinestatic

Constructs packet of current type. Use this method when node is not connected to any network.

Parameters
[in]packetSystem packet to construct.
sourceAddrSource node address.
destAddrDestination node address.
versionVersion of used MeshNet.
flagsNetwork scan response flags.
foreignBSSIDBSSID of foreign network, which has to receive this frame.
hopsHop count of node to its gateway connection or 0 when node is gateway or 255 when node is not connected to any network.
Returns
Returns true when packet was constructed successfully.

◆ Construct() [3/3]

static bool NetScanRespPD::Construct ( MeshPacket packet,
uint8_t  sourceAddr,
uint8_t  destAddr,
MeshVersion  version,
MeshNodeDescFlags  flags,
MeshMAC  foreignBSSID,
uint8_t  hops,
const char *  SSID,
uint8_t  SSID_length 
)
inlinestatic

Constructs packet of current type. Use this method when node is connected to some network.

Parameters
[in]packetSystem packet to construct.
sourceAddrSource node address.
destAddrDestination node address.
versionVersion of used MeshNet.
flagsNetwork scan response flags.
foreignBSSIDBSSID of foreign network, which has to receive this frame.
hopsHop count of node to its gateway connection or 0 when node is gateway or 255 when node is not connected to any network.
[in]SSIDSSID of network.
SSID_lengthLength of SSID without null terminator.
Returns
Returns true when packet was constructed successfully.

◆ GetFlags()

static MeshNodeDescFlags NetScanRespPD::GetFlags ( const MeshPacket packet)
inlinestatic

Gets network scan response flags.

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

◆ GetForeignNetBSSID() [1/2]

static MeshMAC NetScanRespPD::GetForeignNetBSSID ( const MeshPacket packet)
inlinestatic

Gets BSSID of foreign network, which has to receive this frame.

Parameters
[in]packetSystem packet to decode.
Returns
BSSID of foreign network, which has to receive this frame.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetForeignNetBSSID() [2/2]

static MeshMAC NetScanRespPD::GetForeignNetBSSID ( const uint8_t *  frameData)
inlinestatic

Gets BSSID of foreign network, which has to receive this frame. Designed for packet header checking in MeshPacketBuilder.

Parameters
[in]frameDataPointer to data contained in first frame (excluding fields reserved for packet header).
Returns
BSSID of foreign network, which has to receive this frame.
Warning
Always check, if packet is valid using IsValid() method and if IsForeignNet() returns true, else exception can be thrown.

◆ GetHopsToGateway()

static uint8_t NetScanRespPD::GetHopsToGateway ( const MeshPacket packet)
inlinestatic

Gets hop count of node to its gateway connection.

Parameters
[in]packetSystem packet to decode.
Returns
Returns hop count of node to its gateway connection or 0 when node is gateway or 255 when node is not connected to any network.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetNetVersion()

static MeshVersion NetScanRespPD::GetNetVersion ( const MeshPacket packet)
inlinestatic

Gets version of used MeshNet.

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

◆ GetResult()

static MeshNetScanResult NetScanRespPD::GetResult ( const MeshPacket packet,
MeshMAC  BSSID 
)
inlinestatic

Converts data from packet to MeshNetScanResult.

Parameters
[in]packetPacket to convert.
BSSIDBSSID of network, from which response was received. Has to be set manually, because packet header does not contains it.
Warning
If IsValid() method returns false, invalid MeshNetScanResult will be returned.

◆ GetSSID()

static bool NetScanRespPD::GetSSID ( const MeshPacket packet,
char *  SSID,
uint8_t &  SSID_length 
)
inlinestatic

Copyies SSID from packet to buffer. The SSID is null terminated here. If IsDisconnectedNode() method returns true, packet does not contain SSID.

Parameters
[in]packetSystem packet to decode.
[out]SSIDBuffer, where SSID will be copyied. Buffer has to have minimum size GetSSIDLength()+1 bytes.
[in,out]SSID_lengthInput size(including null terminator) of buffer first, after calling this method it contains length of SSID without null terminator.
Returns
Returns True when SSID was copyied without truncating.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetSSIDLength()

static uint16_t NetScanRespPD::GetSSIDLength ( const MeshPacket packet)
inlinestatic

Gets length of SSID.

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

◆ GetSSIDPtr()

static char* NetScanRespPD::GetSSIDPtr ( const MeshPacket packet)
inlinestatic

Gets pointer to network SSID. The SSID is not null terminated, that's why you have to check itslength using GetSSIDLength(). If IsDisconnectedNode() method returns true, packet does not contain SSID.

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

◆ IsDisconnectedNode()

static bool NetScanRespPD::IsDisconnectedNode ( const MeshPacket packet)
inlinestatic

Checks if node is connected to any network or not. If this returns true, the BSSID of network which is it connected to is contained in packet header. MeshPacketHeader does not contains BSSID field, that's why you have to get it from MeshPacketBuilder after building packet.

Parameters
[in]packetSystem packet to decode.
Returns
Returns true when node is connected to any network.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ IsSameType()

static bool NetScanRespPD::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() [1/2]

static bool NetScanRespPD::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.

◆ IsValid() [2/2]

static bool NetScanRespPD::IsValid ( const MeshPacketHeader packetHeader,
const uint8_t *  frameData,
uint8_t  frameDataSize 
)
inlinestatic

Checks if packet is valid. Designed for packet header checking in MeshPacketBuilder.

Parameters
[in]packetHeaderReceived packet header.
[in]frameDataPointer to data contained in first frame (excluding fields reserved for packet header).
[in]frameDataSizeSize of frame data in bytes.
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 NetScanRespPD::SetFlags ( MeshPacket packet,
MeshNodeDescFlags  flags 
)
inlinestatic

Sets network scan flags.

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

◆ SetForeignNetBSSID()

static void NetScanRespPD::SetForeignNetBSSID ( MeshPacket packet,
MeshMAC  foreignBSSID 
)
inlinestatic

Sets BSSID of foreign network, which has to receive this frame.

Parameters
[in]packetSystem packet to decode.
foreignBSSIDBSSID of foreign network, which has to receive this frame.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ SetHopsToGateway()

static void NetScanRespPD::SetHopsToGateway ( MeshPacket packet,
uint8_t  hops 
)
inlinestatic

Sets hop count of node to its gateway connection.

Parameters
[in]packetSystem packet to decode.
hopsHop count of node to its gateway connection or 0 when node is gateway or 255 when node is not connected to any network.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ SetNetVersion()

static void NetScanRespPD::SetNetVersion ( MeshPacket packet,
MeshVersion  version 
)
inlinestatic

Sets version of used MeshNet.

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

◆ SetSSID()

static bool NetScanRespPD::SetSSID ( MeshPacket packet,
const char *  SSID,
uint8_t  SSID_length,
bool  resize = true 
)
inlinestatic

Sets SSID of network to packet.

Parameters
[in]SSIDSSID of network to set.
SSID_lengthLength of SSID without terminator.
resizeSet to true to automatically resize packet payload to fit SSID. It is recommended to set it to true. Advanced: Set to false if packet payload can already fit SSID without resizing.
Returns
Returns true when SSID was set.

Field Documentation

◆ Type

const static SystemPacketType NetScanRespPD::Type = SPT_NetScan
static

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


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