nanoFramework.System.Device.Wifi 1.5.76

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package nanoFramework.System.Device.Wifi --version 1.5.76
NuGet\Install-Package nanoFramework.System.Device.Wifi -Version 1.5.76
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.76" />
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.76
#r "nuget: nanoFramework.System.Device.Wifi, 1.5.76"
#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.76

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

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.76 1,919 1/29/2024
1.5.74 577 1/26/2024
1.5.71 4,988 11/10/2023
1.5.67 393 11/9/2023
1.5.65 1,407 10/16/2023
1.5.54 6,493 2/16/2023
1.5.51 1,641 12/28/2022
1.5.49 697 12/28/2022
1.5.46 654 12/27/2022
1.5.37 2,100 10/26/2022
1.5.35 733 10/26/2022
1.5.33 766 10/25/2022
1.5.31 735 10/24/2022
1.5.29 794 10/23/2022
1.5.27 1,048 10/10/2022
1.5.25 747 10/8/2022
1.5.22 871 9/22/2022
1.5.20 1,178 9/21/2022
1.5.18 732 9/21/2022
1.5.13 944 9/15/2022
1.5.8 1,731 8/4/2022
1.5.6 757 8/4/2022
1.5.4 713 8/3/2022
1.5.2 801 8/3/2022
1.4.0.24 775 8/3/2022
1.4.0.22 1,526 6/13/2022
1.4.0.20 835 6/8/2022
1.4.0.16 1,005 5/26/2022
1.4.0.14 851 5/18/2022
1.4.0.12 1,522 5/4/2022
1.4.0.10 820 5/4/2022
1.4.0 1,564 3/29/2022
1.4.0-preview.59 150 3/28/2022
1.4.0-preview.57 122 3/28/2022
1.4.0-preview.55 130 3/28/2022
1.4.0-preview.53 120 3/28/2022
1.4.0-preview.51 126 3/28/2022
1.4.0-preview.48 256 3/17/2022
1.4.0-preview.46 177 3/16/2022
1.4.0-preview.44 146 3/14/2022
1.4.0-preview.42 124 3/14/2022
1.4.0-preview.40 134 3/14/2022
1.4.0-preview.36 505 2/17/2022
1.4.0-preview.34 250 2/8/2022
1.4.0-preview.32 224 2/4/2022
1.4.0-preview.30 137 2/4/2022
1.4.0-preview.28 138 2/4/2022
1.4.0-preview.26 194 1/28/2022
1.4.0-preview.24 163 1/28/2022
1.4.0-preview.21 175 1/21/2022
1.4.0-preview.19 137 1/21/2022
1.4.0-preview.17 138 1/21/2022
1.4.0-preview.15 139 1/21/2022
1.4.0-preview.13 136 1/21/2022
1.4.0-preview.11 243 1/12/2022
1.4.0-preview.6 193 1/5/2022
1.4.0-preview.1 360 1/4/2022
1.3.4-preview.44 202 1/4/2022
1.3.4-preview.43 163 1/4/2022