nl::Weave::Profiles::NetworkProvisioning::NetworkInfo

#include <src/lib/profiles/network-provisioning/NetworkInfo.h>

A utility class for serializing and deserializing payloads communicated via NetworkProvisioning profile: it encapsulates information pertinent to the detecting and configuring networks.

Summary

The class relies on intermediate storage of network provisioning information (intermediate between the ultimate store of the information and the network payload) and uses dynamic memory management to give the resulting object flexible runtime. As such, this class is not suitable for the most constrained environments, but may be used on larger systems.

Constructors and Destructors

NetworkInfo()
~NetworkInfo()

Public types

@210 enum
@211 enum

Public attributes

Hidden
bool
Whether or not the network is hidden.
NetworkId
int64_t
The network id assigned to the network by the device, -1 if not specified.
NetworkType
The type of network.
ThreadChannel
uint8_t
The current channel (currently [11..26]) on which the Thread network operates, or kThreadChannel_NotSpecified.
ThreadExtendedPANId
uint8_t *
The Thread extended PAN ID.
ThreadNetworkKey
uint8_t *
The Thread master network key , or NULL if not specified.
ThreadNetworkName
char *
The name of the Thread network, or NULL if not specified.
ThreadPANId
uint32_t
The 16-bit Thread PAN ID, or kThreadPANId_NotSpecified.
ThreadPSKc
uint8_t *
Thread pre-shared key for commissioner, or NULL if not specified.
WiFiKey
uint8_t *
The WiFi key, or NULL if not specified.
WiFiKeyLen
uint32_t
The length in bytes of the WiFi key.
WiFiMode
The operating mode of the WiFi network.
WiFiRole
The role played by the device on the WiFi network.
WiFiSSID
char *
The WiFi SSID, or NULL if not specified.
WiFiSecurityType
The WiFi security type.
WirelessSignalStrength
int16_t
The signal strength of the network, or INT16_MIN if not available/applicable.

Public functions

Clear(void)
void
Reset to default and free all values within this NetworkInfo object.
CopyTo(NetworkInfo & dest)
Replace the contents of this NetworkInfo object with the deep copy of the contents of the argument.
Decode(nl::Weave::TLV::TLVReader & reader)
Deserialize the content of this NetworkInfo object from its TLV representation.
Encode(nl::Weave::TLV::TLVWriter & writer, uint8_t encodeFlags) const
Serialize the content of this NetworkInfo object into its TLV representation.
MergeTo(NetworkInfo & dest)
Merge the contents of this NetworkInfo object with the deep copy of the contents of the argument.

Public static functions

DecodeList(nl::Weave::TLV::TLVReader & reader, uint16_t & elemCount, NetworkInfo *& elemArray)
Deserialize a list of NetworkInfo elements from its TLV representation.
EncodeList(nl::Weave::TLV::TLVWriter & writer, uint16_t elemCount, const NetworkInfo *elemArray, uint8_t encodeFlags)
Serialize an array of NetworkInfo objects into its TLV representation.
EncodeList(nl::Weave::TLV::TLVWriter & writer, uint16_t arrayLen, const NetworkInfo *elemArray, ::nl::Weave::Profiles::NetworkProvisioning::NetworkType networkType, uint8_t encodeFlags, uint16_t & encodedElemCount)
Serialize an array of NetworkInfo objects into its TLV representation selecting only networks of a specific type.

Public types

@210

 @210

@211

 @211

Public attributes

Hidden

bool Hidden

Whether or not the network is hidden.

NetworkId

int64_t NetworkId

The network id assigned to the network by the device, -1 if not specified.

NetworkType

::nl::Weave::Profiles::NetworkProvisioning::NetworkType NetworkType

The type of network.

ThreadChannel

uint8_t ThreadChannel

The current channel (currently [11..26]) on which the Thread network operates, or kThreadChannel_NotSpecified.

ThreadExtendedPANId

uint8_t * ThreadExtendedPANId

The Thread extended PAN ID.

It is a dynamically allocated array of 8 octects, owned by the class. Destroyed on any condition that calls Clear() on the object.

ThreadNetworkKey

uint8_t * ThreadNetworkKey

The Thread master network key , or NULL if not specified.

It is a dynamically allocated array of arbitrary octets, owned by the class Destroyed on any condition that calls Clear() on the object.

ThreadNetworkName

char * ThreadNetworkName

The name of the Thread network, or NULL if not specified.

It is a NUL-terminated, dynamically-allocated C-string, owned by the class. Destroyed on any condition that calls Clear() on the object.

ThreadPANId

uint32_t ThreadPANId

The 16-bit Thread PAN ID, or kThreadPANId_NotSpecified.

ThreadPSKc

uint8_t * ThreadPSKc

Thread pre-shared key for commissioner, or NULL if not specified.

It is a dynamically allocated array of arbitrary octets, owned by the class Destroyed on any condition that calls Clear() on the object.

WiFiKey

uint8_t * WiFiKey

The WiFi key, or NULL if not specified.

It is a dynamically allocated array of arbitrary octets, owned by the class, with length specified by WiFiKeyLen. Destroyed on any condition that calls Clear() on the object.

WiFiKeyLen

uint32_t WiFiKeyLen

The length in bytes of the WiFi key.

WiFiMode

::nl::Weave::Profiles::NetworkProvisioning::WiFiMode WiFiMode

The operating mode of the WiFi network.

WiFiRole

::nl::Weave::Profiles::NetworkProvisioning::WiFiRole WiFiRole

The role played by the device on the WiFi network.

WiFiSSID

char * WiFiSSID

The WiFi SSID, or NULL if not specified.

It is a NUL-terminated, dynamically-allocated C-string, owned by the class. Destroyed on any condition that calls Clear() on the object.

WiFiSecurityType

::nl::Weave::Profiles::NetworkProvisioning::WiFiSecurityType WiFiSecurityType

The WiFi security type.

WirelessSignalStrength

int16_t WirelessSignalStrength

The signal strength of the network, or INT16_MIN if not available/applicable.

Public functions

Clear

void Clear(
  void
)

Reset to default and free all values within this NetworkInfo object.

CopyTo

WEAVE_ERROR CopyTo(
  NetworkInfo & dest
)

Replace the contents of this NetworkInfo object with the deep copy of the contents of the argument.

Details
Parameters
[in] dest
NetworkInfo object containing information to be copied into this object.
Return Values
WEAVE_NO_ERROR
On success.
WEAVE_ERROR_NOT_IMPLEMENTED
When the platform does not support malloc or free.
WEAVE_ERROR_NO_MEMORY
On memory allocation failures.

Decode

WEAVE_ERROR Decode(
  nl::Weave::TLV::TLVReader & reader
)

Deserialize the content of this NetworkInfo object from its TLV representation.

Details
Parameters
[in] reader
TLVReader positioned to the structure element containing network info.
Returns
WEAVE_NO_ERROR On success, WEAVE_ERROR_INVALID_TLV_ELEMENT on any element not conforming to the network provisioning profile, any of the TLV reader errors on incorrect decoding of elements.

Encode

WEAVE_ERROR Encode(
  nl::Weave::TLV::TLVWriter & writer,
  uint8_t encodeFlags
) const 

Serialize the content of this NetworkInfo object into its TLV representation.

Details
Parameters
[in] writer
TLVWriter positioned at the place where the object will be serialized to. The function emits an anonymous tag for this object when this object is a part of array of elements or a profile tag for kTag_NetworkInformation when emitted as a standalone element.
[in] encodeFlags
Flags controlling whether the credentials of the NetworkInfo should be serialized.
Returns
WEAVE_NO_ERROR On success, WEAVE_ERROR_INVALID_TLV_ELEMENT on any element not conforming to the network provisioning profile, any of the TLV reader errors on incorrect decoding of elements.

MergeTo

WEAVE_ERROR MergeTo(
  NetworkInfo & dest
)

Merge the contents of this NetworkInfo object with the deep copy of the contents of the argument.

All the non-default values from the argument object replace the values in this object.

Details
Parameters
[in] dest
NetworkInfo object containing information to be copied into this object.
Return Values
WEAVE_NO_ERROR
On success.
WEAVE_ERROR_NOT_IMPLEMENTED
When the platform does not support malloc or free.
WEAVE_ERROR_NO_MEMORY
On memory allocation failures.

NetworkInfo

 NetworkInfo()

~NetworkInfo

 ~NetworkInfo()

Public static functions

DecodeList

WEAVE_ERROR DecodeList(
  nl::Weave::TLV::TLVReader & reader,
  uint16_t & elemCount,
  NetworkInfo *& elemArray
)

Deserialize a list of NetworkInfo elements from its TLV representation.

Details
Parameters
[in] reader
TLVReader positioned at the array start. On successful return, the writer is positioned after the end of the array.
[in,out] elemCount
On input, maximum number of elements to deserialize from the TLVReader. On output, the number of elements actually deserialized from the stream.
[in,out] elemArray
A reference to the array of NetworkInfo elements that will contain the deserialized NetworkInfo objects. When the array is NULL, it is allocated internally by the function below, otherwise it is assumed that the externally allocated array contains at least elemCount objects.
Return Values
WEAVE_NO_ERROR
On success.
WEAVE_ERROR_NOT_IMPLEMENTED
on platforms that do not support dynamic memory management.
other
Errors returned from the Decode() function.

EncodeList

WEAVE_ERROR EncodeList(
  nl::Weave::TLV::TLVWriter & writer,
  uint16_t elemCount,
  const NetworkInfo *elemArray,
  uint8_t encodeFlags
)

Serialize an array of NetworkInfo objects into its TLV representation.

The array will be an anonymous element in the TLV representation.

Details
Parameters
[in] writer
Appropriately positioned TLVWriter
[in] elemCount
Number of elements in the elemArray.
[in] elemArray
The array of NetworkInfo objects to be serialized.
[in] encodeFlags
Flags controlling whether the credentials of the NetworkInfo should be serialized.
Return Values
WEAVE_NO_ERROR
On success.
Other
Errors returned from the Encode() function.

EncodeList

WEAVE_ERROR EncodeList(
  nl::Weave::TLV::TLVWriter & writer,
  uint16_t arrayLen,
  const NetworkInfo *elemArray,
  ::nl::Weave::Profiles::NetworkProvisioning::NetworkType networkType,
  uint8_t encodeFlags,
  uint16_t & encodedElemCount
)

Serialize an array of NetworkInfo objects into its TLV representation selecting only networks of a specific type.

Details
Parameters
[in] writer
Appropriately positioned TLVWriter
[in] arrayLen
Number of elements in the elemArray.
[in] elemArray
The array of NetworkInfo objects to be serialized.
[in] networkType
The type of NetworkInfo objects to serialize
[in] encodeFlags
Flags controlling whether the credentials of the NetworkInfo should be serialized.
[out] encodedElemCount
The number of elements actually serialized.
Return Values
WEAVE_NO_ERROR
On success.
Other
Errors returned from the Encode() function.