/// <summary> /// Constructor /// </summary> /// <param name="netData">los datos de red</param> /// <param name="wifiInformation">el manejador de eventos</param> public WifiHandler(NetData netData, WifiInformationDelegate wifiInformation) { this.netData = netData; this.wifiInformation = wifiInformation; //inicializa los objetos Wlan wLanClient = new WlanClient(); wlanConnectionNotificationEventHandler = new WlanClient.WlanInterface.WlanConnectionNotificationEventHandler(WlanConnectionAction); wlanAdhocNetworkNotificationEventHandler = new WlanClient.WlanInterface.WlanAdhocNetworkNotificationEventHandler(WlanAdhocNetworkAction); connectionState = WifiConnectionState.DISCONNECTED; syncPoint = new Object(); }
/// <summary> /// Busca el adaptador de red WIFI /// </summary> /// <returns>El adaptador de red Wifi</returns> public static NetworkAdapter getWifiAdapter() { try { WlanClient wLanClient = new WlanClient(); foreach (WlanClient.WlanInterface wlanIface in wLanClient.Interfaces) { if (wlanIface.NetworkInterface != null) { NetworkAdapter adapter = new NetworkAdapter(); adapter.Id = wlanIface.NetworkInterface.Id; adapter.Description = wlanIface.InterfaceDescription; ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection objMOC = objMC.GetInstances(); foreach (ManagementObject objMO in objMOC) { String id = (String)objMO["SettingID"]; if(adapter.Id.Equals(id)) { adapter.Index = (UInt32)objMO["Index"]; return adapter; } } } } return null; } catch (ThreadAbortException e) { throw e; } catch (Exception e) { throw e; } }
internal WlanInterface(WlanClient client, Wlan.WlanInterfaceInfo info) { this.client = client; this.info = info; }