//////////////////////////////////////////////////////////////// // // Copyright (c) 2007-2010 MetaGeek, LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.Text; namespace Inssider { /// /// This is a simple data class that holds some basic /// data retrieved from the wireless interface /// public class WirelessDetails : IComparable { /// /// Creaetes a new instance of the WirelessDetails class. /// public WirelessDetails() {} /// /// Creates a new instance. /// /// raw mac address byte array public WirelessDetails(byte[] macAddress) { _macAddress = new MacAddress(macAddress); } /// /// Gets or sets the network privacy information /// public string Privacy { get { return _privacy; } set { _privacy = value; } } private string _privacy; /// /// Gets the MAC address associated with this class /// public MacAddress MacAddress { get { return _macAddress; } } private MacAddress _macAddress; /// /// Gets or sets the network SSID /// public string Ssid { get { return _ssid; } set { _ssid = value; } } private string _ssid; /// /// Gets or sets the network is connected /// public bool Connected { get { return _connected; } set { _connected = value; } } private bool _connected; /// /// Gets or sets the wifi network channel /// public uint Channel { get { return _channel; } set { _channel = value; } } private uint _channel; /// /// Gets or sets the RSSI (receive signal strength indication). /// public int Rssi { get { return _rssi; } set { _rssi = value; } } private int _rssi; /// /// Gets or sets indication of whether network is 802.11n /// public bool isTypeN { get { return _isTypeN; } set { _isTypeN = value; } } private bool _isTypeN = false; /// /// Gets or sets indication of whether the network uses channel bonding /// public bool isChannelBonded { get { return _isChannelBonded; } set { _isChannelBonded = value; } } private bool _isChannelBonded = false; /// /// Gets or sets the signal quality value /// public uint SignalQuality { get { return _signalQuality; } set { _signalQuality = value; } } private uint _signalQuality; /// /// Gets or sets the supported data rates. /// public List Rates { get { return _rates; } } private List _rates = new List(); /// /// Helper function to build a string representing /// the supported data rates. The format is like: /// 1/5.5/11/26/54 /// /// public string BuildRateString() { StringBuilder sb = new StringBuilder(); string separator = ""; foreach (double rate in Rates) { sb.Append(separator); sb.Append(rate); separator = "/"; } return (sb.ToString()); } // End RateString() /// /// Gets or sets the string representation of /// the network type. /// public string NetworkType { get { return _networkType; } set { _networkType = value; } } private string _networkType; /// /// Gets or sets the string representation of the /// infrastructure mode. /// public string InfrastructureMode { get { return _infrastructureMode; } set { _infrastructureMode = value; } } private string _infrastructureMode; #region IComparable Members public int CompareTo(object obj) { WirelessDetails details = (WirelessDetails)obj; if (details == this) { return 0; } else if (details.Channel == _channel) { return ((int)details.Rssi - (int)_rssi); } else { return ((int)_channel - (int)details.Channel); } } #endregion } }