Example #1
0
        public void wifiConnect()
        {
            if (WlanIface == null)
            {
                return;
            }

            string profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>none</encryption><useOneX>false</useOneX></authEncryption></security></MSM></WLANProfile>", SSID);

            WlanIface.Disconnect();
            System.Threading.Thread.Sleep(500);
            WlanIface.Connect(Wlan.WlanConnectionMode.TemporaryProfile, Wlan.Dot11BssType.Any, IntPtr.Zero, profileXml);
        }
Example #2
0
        private void TelnetDrone()
        {
            //lock (sync)
            {
                try
                {
                    Status("Establishing Telnet Connection to " + networkDrone.SSID);
                    Socket telnet = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    telnet.Connect("192.168.1.1", 23);

                    if (telnet.Connected == false)
                    {
                        throw new Exception("Failed to connect to 192.168.1.1 on " + networkDrone.profileName);
                    }

                    Status("Telnet connected successfully");

                    String szPassword = "";
                    if (txtPassword.Text.Length > 0)
                    {
                        szPassword = "******" + txtPassword.Text;
                    }
                    //Disable DHCP Server
                    String cmd = "killall udhcpd;";
                    //Connect to Router SSID
                    cmd += "iwconfig ath0 mode managed" + szPassword + " essid " + networkRouter.SSID +
                           " channel 9;";
                    //Configure IP Address and Subnet
                    cmd += " ifconfig ath0 " + txtDroneAddress.Text + " netmask 255.255.255.0 up;";
                    //Configure Router Gateway
                    cmd += " route add default gw " + txtRouterAddress.Text + ";";
                    //End Command
                    cmd += "\n";

                    //Send command to AR Drone
                    byte[] cmdData = new byte[cmd.Length];
                    System.Text.ASCIIEncoding.ASCII.GetBytes(cmd, 0, cmd.Length, cmdData, 0);
                    int sentBytes = telnet.Send(cmdData, cmdData.Length, SocketFlags.None);
                    if (sentBytes != cmdData.Length)
                    {
                        throw new Exception("Failed to send command via telnet: " + sentBytes.ToString() + " of " + cmd.Length + " bytes sent");
                    }
                    Status("Successfully sent configuration\n" + cmd);

                    //Close Telnet connection
                    telnet.Close();
                    Status("Disconnected telnet connection");

                    //Disconnect from AR Drone's ad-hoc network
                    networkInterface.Disconnect();
                    Status("Disconnected from " + networkDrone.SSID);



                    this.Invoke(stoppedBindDelegate);
                }
                catch (Exception e)
                {
                    Status("ERROR: " + e.Message);
                    this.Invoke(stoppedBindDelegate);
                }
            }
        }
Example #3
0
 private void Disconnect(object sender, EventArgs e)
 {
     adapter.Disconnect();
 }
Example #4
0
 private void WifiDisconnect()
 {
     wifiInterface.Disconnect();
 }