How to Get the Available Wifi Aps and Their Signal Strength in .Net

How do I get the available wifi APs and their signal strength in .net?

It is a wrapper project with managed code in c# at http://www.codeplex.com/managedwifi

It supports Windows Vista and XP SP2 (or later version).

sample code:

using NativeWifi;
using System;
using System.Text;

namespace WifiExample
{
class Program
{
/// <summary>
/// Converts a 802.11 SSID to a string.
/// </summary>
static string GetStringForSSID(Wlan.Dot11Ssid ssid)
{
return Encoding.ASCII.GetString( ssid.SSID, 0, (int) ssid.SSIDLength );
}

static void Main( string[] args )
{
WlanClient client = new WlanClient();
foreach ( WlanClient.WlanInterface wlanIface in client.Interfaces )
{
// Lists all networks with WEP security
Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList( 0 );
foreach ( Wlan.WlanAvailableNetwork network in networks )
{
if ( network.dot11DefaultCipherAlgorithm == Wlan.Dot11CipherAlgorithm.WEP )
{
Console.WriteLine( "Found WEP network with SSID {0}.", GetStringForSSID(network.dot11Ssid));
}
}

// Retrieves XML configurations of existing profiles.
// This can assist you in constructing your own XML configuration
// (that is, it will give you an example to follow).
foreach ( Wlan.WlanProfileInfo profileInfo in wlanIface.GetProfiles() )
{
string name = profileInfo.profileName; // this is typically the network's SSID

string xml = wlanIface.GetProfileXml( profileInfo.profileName );
}

// Connects to a known network with WEP security
string profileName = "Cheesecake"; // this is also the SSID
string mac = "52544131303235572D454137443638";
string key = "hello";
string profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key);

wlanIface.SetProfile( Wlan.WlanProfileFlags.AllUser, profileXml, true );
wlanIface.Connect( Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName );
}
}
}
}

C# - How do I access the WLAN signal strength and others?

hello for WIndows 7 this is a good code wich can detect all AP with MAC adress RSSI SSID :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NativeWifi;

class Program
{

static void Main(string[] args)
{

WlanClient client = new WlanClient();
// Wlan = new WlanClient();
try
{
foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
{

Wlan.WlanBssEntry[] wlanBssEntries = wlanIface.GetNetworkBssList();

foreach (Wlan.WlanBssEntry network in wlanBssEntries)
{
int rss = network.rssi;
// MessageBox.Show(rss.ToString());
byte[] macAddr = network.dot11Bssid;

string tMac = "";

for (int i = 0; i < macAddr.Length; i++)
{

tMac += macAddr[i].ToString("x2").PadLeft(2, '0').ToUpper();

}

Console.WriteLine("Found network with SSID {0}.", System.Text.ASCIIEncoding.ASCII.GetString(network.dot11Ssid.SSID).ToString());

Console.WriteLine("Signal: {0}%.", network.linkQuality);

Console.WriteLine("BSS Type: {0}.", network.dot11BssType);

Console.WriteLine("MAC: {0}.", tMac);

Console.WriteLine("RSSID:{0}", rss.ToString());

}
Console.ReadLine();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}
}
}

i hope it will be helpful enjoy

Get SSID of the wireless network I am connected to with C# .Net on Windows Vista

I resolved using the library. It resulted to be quite easy to work with the classes provided:

First I had to create a WlanClient object

wlan = new WlanClient();

And then I can get the list of the SSIDs the PC is connected to with this code:

Collection<String> connectedSsids = new Collection<string>();

foreach (WlanClient.WlanInterface wlanInterface in wlan.Interfaces)
{
Wlan.Dot11Ssid ssid = wlanInterface.CurrentConnection.wlanAssociationAttributes.dot11Ssid;
connectedSsids.Add(new String(Encoding.ASCII.GetChars(ssid.SSID,0, (int)ssid.SSIDLength)));
}

Detect wifi connectivity in c#

You can't do it in ASP.NET. ASP.NET is a server-side technology which renders client-side browsable code.

In order to do this, you would have to develop something that is embedded in the page (ActiveX, Java, Flash, Silverlight) and even then, you would have to have the appropriate security permissions from the user to access the APIs necessary to access the wifi antenna.

How to scan the wireless devices which exist on the network

if you are ready to invest money then u can use WiFi-Manager/Advanced WiFi-Manager

WiFi-Manager is a developer tool that allows you to manage WiFi connections and settings in Windows XP SP2 and Windows Vista using one set of API functions, although these versions of Windows use absolutely different APIs for wireless network management. Also, WiFi-Manager provides a COM interface for all API functions so you can simply control WiFi settings from VB or such .NET languages as VB.NET or C#.

WiFi-Manager contains functions for enumerating WiFi adapters, enumerating available networks and getting their settings, functions for connecting and disconnecting to networks, functions for working with wireless networks profiles, etc.

Advanced WiFi-Manager is a next-generation tool, it supports all features WiFi-Manager has but also can use NDIS to manage WiFi adapters and works in Windows 2000/2003/XP/Vista/Windows7 and has no dependencies on Service Packs or hotfixes installed!

I hope this is useful

Managing wireless network connection in C#

Managed Wifi API should work.

This might not be ideal - you have XP, which is good, but you would have to deploy a hotfix. I'd go for it, because all the wifi code I've dealt with (for the Compact Framework) is hideous. This code is as simple as could be.

Their sample code doesn't include reading the signal strength, though, and I'm not sure if the Native wifi API provides that. I have written C# code that gets the wireless signal strength, but it did this by PInvoking into a manufacturer-specific DLL available only on their devices. It may be that you'll have to do something similar to get the wireless strength from your PC's wireless card (and that may be why that functionality is not available in an all-purpose API).

Programatically switch betwen WiFi networks in .NET CF?

OpenNETCF has a class for handling wireless networks. Look for the OpenNETCF.Net.NetworkInformation namespace, and the WirelessNetworkInterface class.



Related Topics



Leave a reply



Submit