Exemple #1
0
        /// <summary>
        /// Connect synchronous to the access point.
        /// </summary>
        public bool Connect(AuthRequest request, bool overwriteProfile = false, int timeout = 6000)
        {
            // No point to continue with the connect if the password is not valid if overwrite is true or profile is missing.
            if (!request.IsPasswordValid && (!HasProfile || overwriteProfile))
            {
                return(false);
            }


            bool result = false;

            // If we should create or overwrite the profile, do so.
            if (!HasProfile || overwriteProfile)
            {
                if (HasProfile)
                {
                    _interface.DeleteProfile(Name);
                }

                request.Process();
            }
            bool connect = false;

            //while (!connect)
            //{
            //result = _interface.ConnectSynchronously(WlanConnectionMode.Profile, _network.dot11BssType, Name, timeout);
            //while (_interface.InterfaceState == WlanInterfaceState.Associating ||
            //        _interface.InterfaceState == WlanInterfaceState.Authenticating)
            //{
            //    Thread.Sleep(10);
            //}
            while (_interface.InterfaceState == WlanInterfaceState.Associating ||
                   _interface.InterfaceState == WlanInterfaceState.Authenticating)
            {
                Thread.Sleep(10);
            }
            Thread.Sleep(2500);
            if (_interface.InterfaceState == WlanInterfaceState.Connected)
            {
                result  = true;
                connect = true;
            }
            //}

            // TODO: Auth algorithm: IEEE80211_Open + Cipher algorithm: None throws an error.
            // Probably due to connectionmode profile + no profile exist, cant figure out how to solve it though.
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Connect synchronous to the access point.
        /// </summary>
        public bool Connect(AuthRequest request, bool overwriteProfile = false)
        {
            // No point to continue with the connect if the password is not valid if overwrite is true or profile is missing.
            if (!request.IsPasswordValid && (!HasProfile || overwriteProfile))
            {
                return(false);
            }

            // If we should create or overwrite the profile, do so.
            if (!HasProfile || overwriteProfile)
            {
                if (HasProfile)
                {
                    _interface.DeleteProfile(Name);
                }

                request.Process();
            }


            // TODO: Auth algorithm: IEEE80211_Open + Cipher algorithm: None throws an error.
            // Probably due to connectionmode profile + no profile exist, cant figure out how to solve it though.
            return(_interface.ConnectSynchronously(WlanConnectionMode.Profile, _network.dot11BssType, Name, 6000));
        }