Esempio n. 1
0
 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("");
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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);
         }
     }
 }
Esempio n. 4
0
 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);
         }
     }
 }