nanoFramework.System.Device.Wifi 1.5.74

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.System.Device.Wifi --version 1.5.74                
NuGet\Install-Package nanoFramework.System.Device.Wifi -Version 1.5.74                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.System.Device.Wifi" Version="1.5.74" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.System.Device.Wifi --version 1.5.74                
#r "nuget: nanoFramework.System.Device.Wifi, 1.5.74"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install nanoFramework.System.Device.Wifi as a Cake Addin
#addin nuget:?package=nanoFramework.System.Device.Wifi&version=1.5.74

// Install nanoFramework.System.Device.Wifi as a Cake Tool
#tool nuget:?package=nanoFramework.System.Device.Wifi&version=1.5.74                

Quality Gate Status Reliability Rating NuGet #yourfirstpr Discord

nanoFramework logo


Document Language: English | 简体中文

Welcome to the .NET nanoFramework System.Device.Wifi Library repository

This repository contains the nanoFramework System.Device.Wifi class library.

Build status

Component Build Status NuGet Package
System.Device.Wifi Build Status NuGet

WifiNetworkHelper usage

The WifiNetworkHelper is mainly dedicated to help you connect automatically to Wifi networks. That said, it can be used as well to check if you have a valid IP address and a valid date on any interface including on ethernet.

Preferred usage

The following code will allow you to connect automatically, wait for a valid IP address and a valid date with specific credentials:

const string Ssid = "YourSSID";
const string Password = "YourWifiPassword";
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.ConnectDhcp(Ssid, Password, requiresDateTime: true, token: cs.Token);
if (!success)
{
    // Something went wrong, you can get details with the ConnectionError property:
    Debug.WriteLine($"Can't connect to the network, error: {WifiNetworkHelper.Status}");
    if (WifiNetworkHelper.HelperException != null)
    {
        Debug.WriteLine($"ex: {WifiNetworkHelper.HelperException}");
    }
}
// Otherwise, you are connected and have a valid IP and date

Note that this function will store the network credentials on the device.

Using stored credentials

You can as well connect to a network with pre stored credentials on the device depending on the type of device you have. Please check for proper support with your device.

// The wifi credentials are already stored on the device
 // Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.Reconnect(requiresDateTime: true, token: cs.Token);
if (!success)
{
    // Something went wrong, you can get details with the ConnectionError property:
    Debug.WriteLine($"Can't connect to the network, error: {WifiNetworkHelper.Status}");
    if (WifiNetworkHelper.HelperException != null)
    {
        Debug.WriteLine($"ex: {WifiNetworkHelper.HelperException}");
    }
}
// Otherwise, you are connected and have a valid IP and date

Scan and join

You can force to scan the network and then join the network. This case can be useful in specific conditions. Be aware, that you may have to use this method with one of the previous method depending the support of rescanning while you are already connected.

const string Ssid = "YourSSID";
const string Password = "YourWifiPassword";
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.ScanAndConnectDhcp(Ssid, Password, requiresDateTime: true, token: cs.Token);
if (!success)
{
    // Something went wrong, you can get details with the ConnectionError property:
    Debug.WriteLine($"Can't connect to the network, error: {WifiNetworkHelper.Status}");
    if (WifiNetworkHelper.HelperException != null)
    {
        Debug.WriteLine($"ex: {WifiNetworkHelper.HelperException}");
    }
}
// Otherwise, you are connected and have a valid IP and date

Note that this function will store the network credentials on the device.

Joining with a static IP address

You join a Wifi network with a static IP address:

const string Ssid = "YourSSID";
const string Password = "YourWifiPassword";
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.ConnectFixAddress(Ssid, Password, new IPConfiguration("192.168.1.7", "255.255.255.0", "192.168.1.1"), requiresDateTime: true, token: cs.Token);

Checking valid IP address and date

The WifiNetworkHelper offers couple of functions to check validity of your IP address, the DateTime and helping setting them up:

var success = IsValidDateTime();
// if success is true, you have a valid DateTime
success = IsValidIpAddress(NetworkInterfaceType.Wireless80211);
// if success is true, you have a valid IP address on the Wireless adapter
// Be aware that a local address like 127.0.0.1 is considered as a valid address for ethernet

You can as well wait for a valid IP address and date time:

// Give 60 seconds to check if we have a valid IP and a valid DateTime
CancellationTokenSource cs = new(60000);
var success = WaitForValidIPAndDate(true, NetworkInterfaceType.Ethernet, cs.Token);
// if success is true then you are connected

Feedback and documentation

For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.

Join our Discord community here.

Credits

The list of contributors to this project can be found at CONTRIBUTORS.

License

The nanoFramework Class Libraries are licensed under the MIT license.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on nanoFramework.System.Device.Wifi:

Package Downloads
MakoIoT.Device.Services.ConfigurationManager

Configuration mode manager for MAKO-IoT

MakoIoT.Device.Services.WiFi.AP

WiFi Access Point library for MAKO-IoT

MakoIoT.Device.Services.ConfigurationApi

REST API for configuration with MAKO-IoT

MakoIoT.Device.Services.WiFi

WiFi connectivity library for MAKO-IoT

MakoIoT.Device.Platform.LocalConfig

MAKO-IoT Platform local configuration library. On-device web server, WiFi AP

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on nanoFramework.System.Device.Wifi:

Repository Stars
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
Version Downloads Last updated
1.5.91 5,122 7/29/2024
1.5.85 3,144 5/13/2024
1.5.83 116 5/13/2024
1.5.81 1,585 4/8/2024
1.5.79 815 4/3/2024
1.5.76 2,571 1/29/2024
1.5.74 794 1/26/2024
1.5.71 6,855 11/10/2023
1.5.67 477 11/9/2023
1.5.65 1,780 10/16/2023
1.5.54 7,588 2/16/2023
1.5.51 1,820 12/28/2022
1.5.49 760 12/28/2022
1.5.46 727 12/27/2022
1.5.37 2,196 10/26/2022
1.5.35 789 10/26/2022
1.5.33 833 10/25/2022
1.5.31 800 10/24/2022
1.5.29 865 10/23/2022
1.5.27 1,118 10/10/2022
1.5.25 822 10/8/2022
1.5.22 949 9/22/2022
1.5.20 1,256 9/21/2022
1.5.18 806 9/21/2022
1.5.13 1,003 9/15/2022
1.5.8 1,796 8/4/2022
1.5.6 824 8/4/2022
1.5.4 781 8/3/2022
1.5.2 873 8/3/2022
1.4.0.24 852 8/3/2022
1.4.0.22 1,614 6/13/2022
1.4.0.20 911 6/8/2022
1.4.0.16 1,083 5/26/2022
1.4.0.14 934 5/18/2022
1.4.0.12 1,620 5/4/2022
1.4.0.10 876 5/4/2022
1.4.0 1,664 3/29/2022
1.4.0-preview.59 169 3/28/2022
1.4.0-preview.57 134 3/28/2022
1.4.0-preview.55 141 3/28/2022
1.4.0-preview.53 132 3/28/2022
1.4.0-preview.51 138 3/28/2022
1.4.0-preview.48 269 3/17/2022
1.4.0-preview.46 190 3/16/2022
1.4.0-preview.44 159 3/14/2022
1.4.0-preview.42 143 3/14/2022
1.4.0-preview.40 146 3/14/2022
1.4.0-preview.36 521 2/17/2022
1.4.0-preview.34 263 2/8/2022
1.4.0-preview.32 243 2/4/2022
1.4.0-preview.30 152 2/4/2022
1.4.0-preview.28 156 2/4/2022
1.4.0-preview.26 216 1/28/2022
1.4.0-preview.24 183 1/28/2022
1.4.0-preview.21 185 1/21/2022
1.4.0-preview.19 148 1/21/2022
1.4.0-preview.17 147 1/21/2022
1.4.0-preview.15 150 1/21/2022
1.4.0-preview.13 148 1/21/2022
1.4.0-preview.11 253 1/12/2022
1.4.0-preview.6 205 1/5/2022
1.4.0-preview.1 375 1/4/2022
1.3.4-preview.44 214 1/4/2022
1.3.4-preview.43 174 1/4/2022