Beispiel #1
0
 public DroneNetworkConnectionStateChangedEventArgs(String currentInterfaceName, DroneNetworkConnectionState state, int currentPingRetries, int maxPingRetries)
 {
     this.currentInterfaceName = currentInterfaceName;
     this.state = state;
     this.currentPingRetries = currentPingRetries;
     this.maxPingRetries     = maxPingRetries;
 }
        private void ScanCurrentNetworkInterface()
        {
            if (currentScanRetries < maxScanRetries)
            {
                currentScanRetries++;

                currentState = DroneNetworkConnectionState.ScanningForNewNetworks;
                UpdateConnectionStatus();

                try
                {
                    currentWifiInterface.Scan();
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    AddFailureReasonForCurrentInterface("Network error during scan ... Is your network adapter disabled?");
                    ScanNextNetworkInterface();
                }
            }
            else
            {
                AddFailureReasonForCurrentInterface("The network scan could not be completed");
                ScanNextNetworkInterface();
            }
        }
 public DroneNetworkConnectionStateChangedEventArgs(String currentInterfaceName, DroneNetworkConnectionState state, int currentPingRetries, int maxPingRetries)
 {
     this.currentInterfaceName = currentInterfaceName;
     this.state = state;
     this.currentPingRetries = currentPingRetries;
     this.maxPingRetries = maxPingRetries;
 }
 private void InvokeConnectionStateChange(DroneNetworkConnectionState state)
 {
     if (ConnectionStateChanged != null)
     {
         String currentInterfaceName = currentWifiInterface != null ? currentWifiInterface.InterfaceName : "";
         ConnectionStateChanged.Invoke(this, new DroneNetworkConnectionStateChangedEventArgs(currentInterfaceName, state, currentPingRetries, maxPingRetries));
     }
 }
        private void ResetProgressVariables()
        {
            currentState = DroneNetworkConnectionState.NotConnected;

            currentPingRetries = 0;
            currentScanRetries = 0;
            currentlyScannedNetworkInterfaceNumber = -1;

            currentWifiInterface = null;
        }
        private void ProcessNetworkConnected()
        {
            if (currentState != DroneNetworkConnectionState.ConnectedToNetwork)
            {
                EndWaitingForConnection();

                currentState = DroneNetworkConnectionState.ConnectedToNetwork;
                UpdateConnectionStatus();

                TryToPingDrone();
            }
        }
 private void ProcessPingResult(PingCompletedEventArgs e)
 {
     if (e.Reply.Status == IPStatus.Success)
     {
         currentState = DroneNetworkConnectionState.PingSuccesful;
         UpdateConnectionStatus();
     }
     else if (currentPingRetries < maxPingRetries)
     {
         TryToPingDrone();
     }
     else
     {
         AddFailureReasonForCurrentInterface("Pinging the drone was not succesful");
         ScanNextNetworkInterface();
     }
 }
        private void DiscoverNetwork()
        {
            currentState = DroneNetworkConnectionState.TryingToConnect;
            UpdateConnectionStatus();

            if (!IsAlreadyConnectedToDroneNetwork())
            {
                if (TryToConnectToAvailableDroneNetwork())
                {
                    StartWaitingForNetworkConnection();
                }
            }
            else
            {
                ProcessNetworkConnected();
            }
        }
Beispiel #9
0
        private void ScanCurrentNetworkInterface()
        {
            if (currentScanRetries < maxScanRetries)
            {
                currentScanRetries++;

                currentState = DroneNetworkConnectionState.ScanningForNewNetworks;
                UpdateConnectionStatus();

                currentWifiInterface.Scan();
            }
            else
            {
                AddFailureReasonForCurrentInterface("The network scan could not be completed");
                ScanNextNetworkInterface();
            }
        }
 private void InvokeConnectionStateChange(DroneNetworkConnectionState state)
 {
     if (ConnectionStateChanged != null)
     {
         String currentInterfaceName = currentWifiInterface != null ? currentWifiInterface.InterfaceName : "";
         ConnectionStateChanged.Invoke(this, new DroneNetworkConnectionStateChangedEventArgs(currentInterfaceName, state, currentPingRetries, maxPingRetries));
     }
 }
 private void ProcessPingResult(PingCompletedEventArgs e)
 {
     if (e.Reply.Status == IPStatus.Success)
     {
         currentState = DroneNetworkConnectionState.PingSuccesful;
         UpdateConnectionStatus();
     }
     else if (currentPingRetries < maxPingRetries)
     {
         TryToPingDrone();
     }
     else
     {
         AddFailureReasonForCurrentInterface("Pinging the drone was not succesful");
         ScanNextNetworkInterface();
     }
 }
        private void ProcessNetworkConnected()
        {
            if (currentState != DroneNetworkConnectionState.ConnectedToNetwork)
            {
                EndWaitingForConnection();

                currentState = DroneNetworkConnectionState.ConnectedToNetwork;
                UpdateConnectionStatus();

                TryToPingDrone();
            }
        }
        private void DiscoverNetwork()
        {
            currentState = DroneNetworkConnectionState.TryingToConnect;
            UpdateConnectionStatus();

            if (!IsAlreadyConnectedToDroneNetwork())
            {
                if (TryToConnectToAvailableDroneNetwork())
                {
                    StartWaitingForNetworkConnection();
                }
            }
            else
            {
                ProcessNetworkConnected();
            }
        }
        private void ScanCurrentNetworkInterface()
        {
            if (currentScanRetries < maxScanRetries)
            {
                currentScanRetries++;

                currentState = DroneNetworkConnectionState.ScanningForNewNetworks;
                UpdateConnectionStatus();

                try
                {
                    currentWifiInterface.Scan();
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    AddFailureReasonForCurrentInterface("Network error during scan ... Is your network adapter disabled?");
                    ScanNextNetworkInterface();
                }
            }
            else
            {
                AddFailureReasonForCurrentInterface("The network scan could not be completed");
                ScanNextNetworkInterface();
            }
        }
        private void ResetProgressVariables()
        {
            currentState = DroneNetworkConnectionState.NotConnected;

            currentPingRetries = 0;
            currentScanRetries = 0;
            currentlyScannedNetworkInterfaceNumber = -1;

            currentWifiInterface = null;
        }
        private void ScanCurrentNetworkInterface()
        {
            if (currentScanRetries < maxScanRetries)
            {
                currentScanRetries++;

                currentState = DroneNetworkConnectionState.ScanningForNewNetworks;
                UpdateConnectionStatus();

                currentWifiInterface.Scan();
            }
            else
            {
                AddFailureReasonForCurrentInterface("The network scan could not be completed");
                ScanNextNetworkInterface();
            }
        }