nanoFramework.System.Device.Wifi
1.5.51
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.System.Device.Wifi --version 1.5.51
NuGet\Install-Package nanoFramework.System.Device.Wifi -Version 1.5.51
<PackageReference Include="nanoFramework.System.Device.Wifi" Version="1.5.51" />
paket add nanoFramework.System.Device.Wifi --version 1.5.51
#r "nuget: nanoFramework.System.Device.Wifi, 1.5.51"
// Install nanoFramework.System.Device.Wifi as a Cake Addin #addin nuget:?package=nanoFramework.System.Device.Wifi&version=1.5.51 // Install nanoFramework.System.Device.Wifi as a Cake Tool #tool nuget:?package=nanoFramework.System.Device.Wifi&version=1.5.51
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 |
WifiNetworkHelper usage
The WifiNetworkHelper class 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.
if (!WifiNetworkHelper.IsConfigurationStored())
{
Debug.WriteLine("No configuration stored in the device");
}
else
{
// 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
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.14.2)
- nanoFramework.Runtime.Events (>= 1.11.6)
- nanoFramework.System.Net (>= 1.10.52)
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 | 4,867 | 7/29/2024 |
1.5.85 | 3,122 | 5/13/2024 |
1.5.83 | 115 | 5/13/2024 |
1.5.81 | 1,581 | 4/8/2024 |
1.5.79 | 812 | 4/3/2024 |
1.5.76 | 2,565 | 1/29/2024 |
1.5.74 | 793 | 1/26/2024 |
1.5.71 | 6,837 | 11/10/2023 |
1.5.67 | 476 | 11/9/2023 |
1.5.65 | 1,773 | 10/16/2023 |
1.5.54 | 7,575 | 2/16/2023 |
1.5.51 | 1,817 | 12/28/2022 |
1.5.49 | 759 | 12/28/2022 |
1.5.46 | 726 | 12/27/2022 |
1.5.37 | 2,195 | 10/26/2022 |
1.5.35 | 788 | 10/26/2022 |
1.5.33 | 832 | 10/25/2022 |
1.5.31 | 799 | 10/24/2022 |
1.5.29 | 864 | 10/23/2022 |
1.5.27 | 1,117 | 10/10/2022 |
1.5.25 | 821 | 10/8/2022 |
1.5.22 | 945 | 9/22/2022 |
1.5.20 | 1,255 | 9/21/2022 |
1.5.18 | 805 | 9/21/2022 |
1.5.13 | 1,002 | 9/15/2022 |
1.5.8 | 1,795 | 8/4/2022 |
1.5.6 | 823 | 8/4/2022 |
1.5.4 | 780 | 8/3/2022 |
1.5.2 | 872 | 8/3/2022 |
1.4.0.24 | 851 | 8/3/2022 |
1.4.0.22 | 1,613 | 6/13/2022 |
1.4.0.20 | 910 | 6/8/2022 |
1.4.0.16 | 1,082 | 5/26/2022 |
1.4.0.14 | 933 | 5/18/2022 |
1.4.0.12 | 1,619 | 5/4/2022 |
1.4.0.10 | 875 | 5/4/2022 |
1.4.0 | 1,663 | 3/29/2022 |
1.4.0-preview.59 | 168 | 3/28/2022 |
1.4.0-preview.57 | 133 | 3/28/2022 |
1.4.0-preview.55 | 140 | 3/28/2022 |
1.4.0-preview.53 | 131 | 3/28/2022 |
1.4.0-preview.51 | 137 | 3/28/2022 |
1.4.0-preview.48 | 268 | 3/17/2022 |
1.4.0-preview.46 | 189 | 3/16/2022 |
1.4.0-preview.44 | 158 | 3/14/2022 |
1.4.0-preview.42 | 142 | 3/14/2022 |
1.4.0-preview.40 | 145 | 3/14/2022 |
1.4.0-preview.36 | 519 | 2/17/2022 |
1.4.0-preview.34 | 262 | 2/8/2022 |
1.4.0-preview.32 | 242 | 2/4/2022 |
1.4.0-preview.30 | 151 | 2/4/2022 |
1.4.0-preview.28 | 155 | 2/4/2022 |
1.4.0-preview.26 | 213 | 1/28/2022 |
1.4.0-preview.24 | 182 | 1/28/2022 |
1.4.0-preview.21 | 184 | 1/21/2022 |
1.4.0-preview.19 | 147 | 1/21/2022 |
1.4.0-preview.17 | 146 | 1/21/2022 |
1.4.0-preview.15 | 149 | 1/21/2022 |
1.4.0-preview.13 | 147 | 1/21/2022 |
1.4.0-preview.11 | 252 | 1/12/2022 |
1.4.0-preview.6 | 204 | 1/5/2022 |
1.4.0-preview.1 | 374 | 1/4/2022 |
1.3.4-preview.44 | 213 | 1/4/2022 |
1.3.4-preview.43 | 173 | 1/4/2022 |