Пример #1
0
 /// <summary>
 /// Add a linux device, this will replace an existing generic device
 /// </summary>
 /// <param name="linuxdevice"></param>
 /// <returns></returns>
 public bool AddLinuxDevice(LinuxDevice linuxdevice)
 {
     for (int i = 0; i < Devices.Count; i++)
     {
         if (Devices[i].MacAddress.Equals(linuxdevice.MacAddress))
         {
             Devices[i] = linuxdevice;
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            SSHManager sshManager = new SSHManager();
            bool       connected  = sshManager.Initialise(txtIpAddress.Text, txtUsername.Text, txtPassword.Text);

            if (!connected)
            {
                MessageBox.Show("Connection Refused");
                return;
            }

            lblDeviceInfo.Text = sshManager.SendCommand("hostnamectl");

            /* Other commands which may be useful:
             *
             * $ lsusb - shows list of USB devices connected
             *
             *
             *
             * */

            lblSerialNumber.Text    = sshManager.GetSerial();
            lblOperatingSystem.Text = sshManager.GetOS();

            gbDeviceInfo.Visible = true;


            var newDevice = new LinuxDevice(selectedDevice);

            newDevice.SetCredentials(txtUsername.Text, txtPassword.Text);
            discoveredDeviceList.AddLinuxDevice(newDevice);
            selectedDevice = newDevice;

            // example of how to iterate over the list and determin which devices are linux devices

            /*
             * foreach(var dev in deviceList.Devices)
             * {
             *  var tmp = dev as LinuxDevice;
             *
             *  Console.WriteLine("type? --> {0}", dev.GetType());
             * }
             */
        }