Example #1
0
        public void OnConnectStateChange(IMbnConnection newConnection)
        {
            MBN_ACTIVATION_STATE activationState;
            string profileName;

            newConnection.GetConnectionState(out activationState, out profileName);
            Console.WriteLine("OnConnectStateChange - " + profileName + " - " + activationState);
        }
Example #2
0
        private void cmbRadio_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedInterfaceId = radios[cmbRadio.SelectedIndex].InterfaceID;
            InitializeEventHandlers();
            uint age = 0;

            lvNetwork.Items.Clear();
            try
            {
                lastScannedNetworks = (MBN_PROVIDER[])m_MbnInterface.GetVisibleProviders(out age);
                PopulateNetworks(lastScannedNetworks);
                lblLastScan.Text = DateTime.Now.AddSeconds(-1 * age).ToShortTimeString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Networks not found.  Please scan to find networks.");
                lblLastScan.Text = "Unknown";
            }

            //Fill In the registration stuff
            IMbnRegistration registrationInterface = m_MbnInterface as IMbnRegistration;

            updateRegistration(registrationInterface);

            //Fill in the IMSI
            try
            {
                string IMSI = m_MbnInterfaceManager.GetInterface(selectedInterfaceId).GetSubscriberInformation().SubscriberID;
                lblIMSI.Text = IMSI;
            } catch (Exception ex)
            {
                lblIMSI.Text = "Unknown";
            }

            //Check if connected
            try
            {
                IMbnConnection       connection = ((IMbnConnection[])m_MbnConnectionManager.GetConnections())[0];
                MBN_ACTIVATION_STATE activationState;
                string profileName;
                connection.GetConnectionState(out activationState, out profileName);
                if (activationState == MBN_ACTIVATION_STATE.MBN_ACTIVATION_STATE_ACTIVATED)
                {
                    btnPcConnect.Enabled = false;
                }
                else
                {
                    btnPcDisconnect.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                btnPcDisconnect.Enabled = false;
            }
        }
Example #3
0
        private void ProcessOnConnectComplete(IMbnConnection connection, uint requestId, int status)
        {
            MBN_ACTIVATION_STATE activationState;
            string profileName;

            connection.GetConnectionState(out activationState, out profileName);
            LogMessage("ProcessOnConnectComplete - " + profileName + " - " + activationState);
            if (activationState == MBN_ACTIVATION_STATE.MBN_ACTIVATION_STATE_ACTIVATED)
            {
                this.Invoke((MethodInvoker) delegate()
                {
                    btnPcConnect.Enabled    = false;
                    btnPcDisconnect.Enabled = true;
                });
            }
        }
        bool IsConnected()
        {
            MBN_ACTIVATION_STATE activationState;
            string profileName;
            bool   connectionState = false;

            m_MbnConnection.GetConnectionState(out activationState, out profileName);

            if (activationState == MBN_ACTIVATION_STATE.MBN_ACTIVATION_STATE_ACTIVATED |
                activationState == MBN_ACTIVATION_STATE.MBN_ACTIVATION_STATE_ACTIVATING)
            {
                connectionState = true;
            }

            return(connectionState);
        }
Example #5
0
        public bool KeepConnectionAllive(IMbnConnection newConnection)
        {
            //check every 30 sec if mobile connection is still active
            MBN_ACTIVATION_STATE activationState;
            string profileName;

            newConnection.GetConnectionState(out activationState, out profileName);

            Console.WriteLine("OnConnectStateChange - " + profileName + " - " + activationState);

            if (activationState.ToString() == "connected")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }