Class NetworkHelper
- Namespace
- nanoFramework.Networking
- Assembly
- System.Net.dll
Network helper class providing helper methods to assist on connecting to a network.
public static class NetworkHelper
- Inheritance
-
NetworkHelper
- Inherited Members
Properties
HelperException
Exception that occurred when waiting for the network to become ready.
public static Exception HelperException { get; }
Property Value
NetworkReady
Event signaling that networking it's ready.
public static ManualResetEvent NetworkReady { get; }
Property Value
Remarks
The conditions for this are setup in the call to SetupNetworkHelper(bool). It will be a composition of network connected, IpAddress available and valid system DateTime.
Status
Status of NetworkHelper.
public static NetworkHelperStatus Status { get; }
Property Value
Methods
SetupAndConnectNetwork(CancellationToken, bool)
This will wait for the network connection to be up and optionally for a valid date and time to become available.
public static bool SetupAndConnectNetwork(CancellationToken token = default, bool requiresDateTime = false)
Parameters
token
CancellationTokenA CancellationToken used for timing out the operation.
requiresDateTime
boolSet to true if valid date and time are required.
Returns
- bool
true on success. On failure returns false and details with the cause of the failure are made available in the Status property
SetupAndConnectNetwork(IPConfiguration, CancellationToken, bool)
This will wait for the network connection to be up and optionally for a valid date and time to become available.
public static bool SetupAndConnectNetwork(IPConfiguration ipConfiguration, CancellationToken token = default, bool requiresDateTime = false)
Parameters
ipConfiguration
IPConfigurationThe static IPv4 configuration to apply to the Ethernet network interface.
token
CancellationTokenA CancellationToken used for timing out the operation.
requiresDateTime
boolSet to true if valid date and time are required.
Returns
- bool
true on success. On failure returns false and details with the cause of the failure are made available in the Status property
SetupNetworkHelper(bool)
This method will setup the network configurations so that the NetworkReady event will fire when the required conditions are met. That will be the network connection to be up, having a valid IpAddress and optionally for a valid date and time to become available.
public static void SetupNetworkHelper(bool requiresDateTime = false)
Parameters
Exceptions
- InvalidOperationException
If any of the NetworkHelper methods is called more than once.
- NotSupportedException
There is no network interface configured. Open the 'Edit Network Configuration' in Device Explorer and configure one.
SetupNetworkHelper(IPConfiguration, bool)
This method will setup the network configurations so that the NetworkReady event will fire when the required conditions are met. That will be the network connection to be up, having a valid IpAddress and optionally for a valid date and time to become available.
public static void SetupNetworkHelper(IPConfiguration ipConfiguration, bool requiresDateTime = false)
Parameters
ipConfiguration
IPConfigurationThe static IP configuration you want to apply.
requiresDateTime
boolSet to true if valid date and time are required.
Exceptions
- NotSupportedException
There is no network interface configured. Open the 'Edit Network Configuration' in Device Explorer and configure one.