public static void switchWirelessChannel() { string[] channels = new string[] { "36", "40", "44", "48", "149", "153", "157", "161", "165" }; string currentChannel = ChannelUtil.getWirelessChannel(); if (!string.IsNullOrEmpty(currentChannel)) { string ranChannel; do { int ranIndex = new Random().Next(0, channels.Length - 1); ranChannel = channels[ranIndex]; }while (ranChannel.Equals(currentChannel)); ChannelUtil.setWirelessChannel(ranChannel); } }
private void setWifiThreadStart(object obj) { if (obj is RouterDialog.WifiConfig) { RouterDialog.log.Trace("setWifiThreadStart"); RouterDialog.WifiConfig expr_20 = (RouterDialog.WifiConfig)obj; string SSID = expr_20.SSID; string password = expr_20.password; RouterDialog.log.Trace("before set"); ChannelUtil.setWifi(SSID, password); RouterDialog.log.Trace("after set"); RouterDialog.log.Trace("before getssid"); string newSSID = ChannelUtil.getWifiSSID(); RouterDialog.log.Trace("after getssid"); string newPassword = ChannelUtil.getWifiPassword(); RouterDialog.log.Trace("old ssid = " + SSID); RouterDialog.log.Trace("old pass = "******"new ssid = " + newSSID); RouterDialog.log.Trace("new pass = " + newPassword); if (!string.IsNullOrEmpty(SSID) && !string.IsNullOrEmpty(newPassword) && SSID.Equals(newSSID) && password.Equals(newPassword)) { this.setWifiFinish(true); return; } this.setWifiFinish(false); } }
private void getWifiInfoThreadStart() { string SSID = ChannelUtil.getWifiSSID(); string password = ChannelUtil.getWifiPassword(); if (!string.IsNullOrEmpty(SSID) && !string.IsNullOrEmpty(password)) { this.wifiInfoAvailable(SSID, password); } }
public static int isHostConnected() { if (!ChannelUtil.pingRouterConnect()) { return(-1001); } if (UsbIPUtil.isHostLinked()) { return(0); } return(-1002); }
public static string getWifiPassword() { ChannelUtil.log.Trace("getWifiPassword"); using (SshClient client = new SshClient(ChannelUtil.getDefaultConnectInfo())) { try { client.Connect(); SshCommand expr_2B = client.CreateCommand("user_tool show wl5g_info"); expr_2B.CommandTimeout = TimeSpan.FromSeconds(1.0); string result = expr_2B.Execute(); client.Disconnect(); ChannelUtil.log.Trace("result = " + result); string[] outputs = result.Split(new string[] { "\n" }, StringSplitOptions.None); if (outputs != null) { string[] array = outputs; for (int i = 0; i < array.Length; i++) { string entry = array[i]; ChannelUtil.log.Trace("entry = " + entry); if (entry.StartsWith("Security_key")) { string[] passwordInfo = entry.Split(new string[] { ":" }, StringSplitOptions.None); if (passwordInfo != null && passwordInfo.Count <string>() > 1) { return(passwordInfo[1]); } } } } } catch (Exception e) { ChannelUtil.log.Error("getWifiPassword " + e.Message + "\r\n" + e.StackTrace); } } return(""); }
public static string getWirelessChannel() { using (SshClient client = new SshClient(ChannelUtil.getDefaultConnectInfo())) { try { client.Connect(); SshCommand expr_1C = client.CreateCommand("user_tool show wl5g_info"); expr_1C.CommandTimeout = TimeSpan.FromSeconds(1.0); string arg_4A_0 = expr_1C.Execute(); client.Disconnect(); string[] outputs = arg_4A_0.Split(new string[] { "\n" }, StringSplitOptions.None); if (outputs != null) { string[] array = outputs; for (int i = 0; i < array.Length; i++) { string entry = array[i]; ChannelUtil.log.Trace("entry = " + entry); if (entry.StartsWith("Channel")) { string[] channnelInfo = entry.Split(new string[] { ":" }, StringSplitOptions.None); if (channnelInfo != null && channnelInfo.Count <string>() > 1) { return(channnelInfo[1]); } } } } } catch (Exception e) { ChannelUtil.log.Error("getWirelessChannel " + e.Message + "\r\n" + e.StackTrace); } } return(null); }
public static void setWirelessChannel(string channel) { ChannelUtil.log.Trace("setWirelessChannel"); using (SshClient client = new SshClient(ChannelUtil.getDefaultConnectInfo())) { try { client.Connect(); SshCommand expr_31 = client.CreateCommand("user_tool wl5g_set Channel " + channel); expr_31.CommandTimeout = TimeSpan.FromSeconds(1.0); expr_31.Execute(); client.Disconnect(); } catch (Exception e) { ChannelUtil.log.Error("setWirelessChannel " + e.Message + "\r\n" + e.StackTrace); } } }
private void setWifiThreadStart(object obj) { if (obj is ControlDialog.WifiConfig) { ControlDialog.WifiConfig expr_11 = (ControlDialog.WifiConfig)obj; string SSID = expr_11.SSID; string password = expr_11.password; ChannelUtil.setWifi(SSID, password); string newSSID = ChannelUtil.getWifiSSID(); string newPassword = ChannelUtil.getWifiPassword(); ControlDialog.log.Trace("old ssid = " + SSID); ControlDialog.log.Trace("old pass = "******"new ssid = " + newSSID); ControlDialog.log.Trace("new pass = " + newPassword); if (!string.IsNullOrEmpty(SSID) && !string.IsNullOrEmpty(newPassword) && SSID.Equals(newSSID) && password.Equals(newPassword)) { this.setWifiFinish(true); return; } this.setWifiFinish(false); } }
public static void setWifi(string SSID, string password) { ChannelUtil.log.Trace("setWifi"); using (SshClient client = new SshClient(ChannelUtil.getDefaultConnectInfo())) { try { client.Connect(); ChannelUtil.log.Trace("setWifi ssid = " + SSID); SshCommand expr_46 = client.CreateCommand("user_tool wl5g_set SSID " + SSID); expr_46.CommandTimeout = TimeSpan.FromSeconds(1.0); expr_46.Execute(); client.Disconnect(); } catch (Exception e) { ChannelUtil.log.Trace(e.Message); } } using (SshClient client2 = new SshClient(ChannelUtil.getDefaultConnectInfo())) { try { client2.Connect(); ChannelUtil.log.Trace("setWifi pass = "******"user_tool wl5g_set Security " + password); expr_BC.CommandTimeout = TimeSpan.FromSeconds(1.0); expr_BC.Execute(); client2.Disconnect(); } catch (Exception e2) { ChannelUtil.log.Trace(e2.Message); } } }