1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
// HelloCoreWlanSample.cs
// Ashok Gelal
// Thanks to Duane Wandless
using System;
using MonoMac.CoreLocation;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.CoreWlan;
using System.Runtime.InteropServices;
namespace HelloCoreWlan
{
public class HelloCoreWlanSample
{
static void Main (string[] args)
{
NSApplication.Init();
using(new NSAutoreleasePool())
{
string[] interfaces = CWInterface.SupportedInterfaces;
if(interfaces.Length<1){
Console.WriteLine("No supported interface is available in this computer");
return;
}
CWInterface selectedIntface = CWInterface.FromName (interfaces[0]);
// print interface information
Console.WriteLine("\nInterface Information:\nName: {0}, Active SSID: {1}, Active BSSID: {2}\n", selectedIntface.Name, selectedIntface.Ssid, selectedIntface.Bssid);
NSError error;
CWNetwork[] data = selectedIntface.ScanForNetworksWithParameters(null, out error);
if(error!=null){
Console.Error.WriteLine("An error occurred while scanning for available networks");
return;
}
foreach(CWNetwork d in data)
{
Console.Write("SSID: {0}, BSSID: {1}\n", d.Ssid, d.Bssid);
}
}
}
}
}
|