File: HelloCoreWlanSample.cs

package info (click to toggle)
monodevelop 3.0.3.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 153,256 kB
  • sloc: cs: 1,020,242; xml: 751,053; makefile: 9,596; sh: 1,529; objc: 302; sql: 129; ansic: 96
file content (48 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download | duplicates (3)
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);
				}
			}
		}
	}
}