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

Static class, that groups static methods to decode network connection 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 uint16_t GetFlags (const MeshPacket &packet)
 Gets network connect flags. More...
 
static void SetFlags (MeshPacket &packet, uint16_t flags)
 Sets network connect 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 GetAssignedAddr (const MeshPacket &packet)
 Gets address assigned to node which requested connection. More...
 
static void SetAssignedAddr (MeshPacket &packet, uint8_t address)
 Sets address assigned to node which requested connection. More...
 
static bool IsRefusedConnection (MeshPacket &packet)
 Checks if connection is refused. More...
 
static NetConRespRefuseReason GetRefuseReason (MeshPacket &packet)
 Gets refuse reason when connection was refused. More...
 
static void SetRefuseReason (MeshPacket &packet, NetConRespRefuseReason reason)
 Sets refuse reason when connection was refused. More...
 
static uint16_t GetReservedTime (const MeshPacket &packet)
 Gets reserved time in DHCP table in minutes. More...
 
static void SetReservedTime (MeshPacket &packet, uint16_t time)
 Sets reserved time in DHCP table in minutes. 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 IsRefusedConnection() 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 bool Construct (MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC foreignBSSID, uint8_t address, uint16_t time, const char *SSID, uint8_t SSID_length)
 Constructs packet of current type. More...
 
static bool ConstructRefused (MeshPacket &packet, uint8_t sourceAddr, uint8_t destAddr, uint16_t flags, MeshMAC foreignBSSID, NetConRespRefuseReason reason)
 Constructs refused connection response packet of current type. More...
 

Static Public Attributes

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

Private Member Functions

 NetConRespPD ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ NetConRespPD()

NetConRespPD::NetConRespPD ( )
inlineprivate

Member Function Documentation

◆ Construct()

static bool NetConRespPD::Construct ( MeshPacket packet,
uint8_t  sourceAddr,
uint8_t  destAddr,
uint16_t  flags,
MeshMAC  foreignBSSID,
uint8_t  address,
uint16_t  time,
const char *  SSID,
uint8_t  SSID_length 
)
inlinestatic

Constructs packet of current type.

Parameters
[in]packetSystem packet to construct.
sourceAddrSource node address.
destAddrDestination node address.
flagsNetwork scan flags.
foreignBSSIDBSSID of foreign network, which has to receive this frame.
addressAddress assigned to node which requested connection.
timeReserved time in DHCP table in minutes.
[in]SSIDSSID of network.
SSID_lengthLength of SSID without null terminator.
Returns
Returns true when packet was constructed successfully.

◆ ConstructRefused()

static bool NetConRespPD::ConstructRefused ( MeshPacket packet,
uint8_t  sourceAddr,
uint8_t  destAddr,
uint16_t  flags,
MeshMAC  foreignBSSID,
NetConRespRefuseReason  reason 
)
inlinestatic

Constructs refused connection response packet of current type.

Parameters
[in]packetSystem packet to construct.
sourceAddrSource node address.
destAddrDestination node address.
flagsNetwork scan flags.
foreignBSSIDBSSID of foreign network, which has to receive this frame.
reasonRefuse reason.
Returns
Returns true when packet was constructed successfully.

◆ GetAssignedAddr()

static uint8_t NetConRespPD::GetAssignedAddr ( const MeshPacket packet)
inlinestatic

Gets address assigned to node which requested connection.

Parameters
[in]packetSystem packet to decode.
Returns
Address assigned to node which requested connection.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ GetFlags()

static uint16_t NetConRespPD::GetFlags ( const MeshPacket packet)
inlinestatic

Gets network connect flags.

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

◆ GetForeignNetBSSID() [1/2]

static MeshMAC NetConRespPD::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 NetConRespPD::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, else exception can be thrown.

◆ GetRefuseReason()

static NetConRespRefuseReason NetConRespPD::GetRefuseReason ( MeshPacket packet)
inlinestatic

Gets refuse reason when connection was refused.

Parameters
[in]packetSystem packet to decode.

◆ GetReservedTime()

static uint16_t NetConRespPD::GetReservedTime ( const MeshPacket packet)
inlinestatic

Gets reserved time in DHCP table in minutes.

Parameters
[in]packetSystem packet to decode.
Returns
Reserved time in DHCP table in minutes.
Warning
Always check, if packet is valid using IsValid() method check if IsRefusedConnection() returns false, else exception can be thrown.

◆ GetSSID()

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

Copyies SSID from packet to buffer. The SSID is null terminated here. If IsRefusedConnection() 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 NetConRespPD::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* NetConRespPD::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.

◆ IsRefusedConnection()

static bool NetConRespPD::IsRefusedConnection ( MeshPacket packet)
inlinestatic

Checks if connection is refused.

Parameters
[in]packetSystem packet to decode.

◆ IsSameType()

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

◆ SetAssignedAddr()

static void NetConRespPD::SetAssignedAddr ( MeshPacket packet,
uint8_t  address 
)
inlinestatic

Sets address assigned to node which requested connection.

Parameters
[in]packetSystem packet to decode.
addressAddress assigned to node which requested connection.
Warning
Always check, if packet is valid using IsValid() method, else exception can be thrown.

◆ SetFlags()

static void NetConRespPD::SetFlags ( MeshPacket packet,
uint16_t  flags 
)
inlinestatic

Sets network connect flags.

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

◆ SetForeignNetBSSID()

static void NetConRespPD::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 and if IsForeignNet() returns true, else exception can be thrown.

◆ SetRefuseReason()

static void NetConRespPD::SetRefuseReason ( MeshPacket packet,
NetConRespRefuseReason  reason 
)
inlinestatic

Sets refuse reason when connection was refused.

Parameters
[in]packetSystem packet to decode.
reasonRefuse reason to set.
Note
This method can be called only if packet is set as refused.

◆ SetReservedTime()

static void NetConRespPD::SetReservedTime ( MeshPacket packet,
uint16_t  time 
)
inlinestatic

Sets reserved time in DHCP table in minutes.

Parameters
[in]packetSystem packet to decode.
timeReserved time in DHCP table in minutes.
Warning
Always check, if packet is valid using IsValid() method check if IsRefusedConnection() returns false, else exception can be thrown.

◆ SetSSID()

static bool NetConRespPD::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 NetConRespPD::Type = SPT_Connect
static

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


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