Ejemplo n.º 1
0
        public static async Task <List <LEDHotspot> > ListHostspotsAsync(string bridgeIP)
        {
            var hostspots = new List <LEDHotspot>();
            var client    = new LEDAdminClient();

            try
            {
                if (await HandshakeAsync(client))
                {
                    await client.SendDataAsync("AT+WSCAN\r\n");

                    await Task.Delay(1000);

                    var data = string.Empty;
                    while (!string.IsNullOrEmpty(data = await client.ReceiveDataAsync()))
                    {
                        foreach (var s in data.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            var ma = _hotspotRegEx.Match(s);
                            if (ma.Success)
                            {
                                var id      = ma.Groups["ssid"].Value;
                                var hotspot = hostspots.Find((h) => { return(h.BSSID == id); });
                                if (hotspot == null)
                                {
                                    hotspot = new LEDHotspot()
                                    {
                                        BSSID    = ma.Groups["ssid"].Value,
                                        Channel  = byte.Parse(ma.Groups["ch"].Value),
                                        DPID     = ma.Groups["dpid"].Value,
                                        ExtCH    = ma.Groups["extch"].Value,
                                        NT       = ma.Groups["nt"].Value,
                                        Security = ma.Groups["security"].Value,
                                        Signal   = byte.Parse(ma.Groups["signal"].Value),
                                        SSID     = ma.Groups["ssid"].Value,
                                        WPS      = ma.Groups["wps"].Value
                                    };
                                    hostspots.Add(hotspot);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                client.Close();
            }
            return(hostspots);
        }
Ejemplo n.º 2
0
 public static async Task<List<LEDHotspot>> ListHostspotsAsync(string bridgeIP)
 {
     var hostspots = new List<LEDHotspot>();
     var client = new LEDAdminClient();
     try
     {
         if (await HandshakeAsync(client))
         {
             await client.SendDataAsync("AT+WSCAN\r\n");
             await Task.Delay(1000);
             var data = string.Empty;
             while (!string.IsNullOrEmpty(data = await client.ReceiveDataAsync()))
             {
                 foreach (var s in data.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                 {
                     var ma = _hotspotRegEx.Match(s);
                     if (ma.Success)
                     {
                         var id = ma.Groups["ssid"].Value;
                         var hotspot = hostspots.Find((h) => { return h.BSSID == id; });
                         if (hotspot == null)
                         {
                             hotspot = new LEDHotspot()
                             {
                                 BSSID = ma.Groups["ssid"].Value,
                                 Channel = byte.Parse(ma.Groups["ch"].Value),
                                 DPID = ma.Groups["dpid"].Value,
                                 ExtCH = ma.Groups["extch"].Value,
                                 NT = ma.Groups["nt"].Value,
                                 Security = ma.Groups["security"].Value,
                                 Signal = byte.Parse(ma.Groups["signal"].Value),
                                 SSID = ma.Groups["ssid"].Value,
                                 WPS = ma.Groups["wps"].Value
                             };
                             hostspots.Add(hotspot);
                         }
                     }
                 }
             }
         }
     }
     finally
     {
         client.Close();
     }
     return hostspots;
 }