예제 #1
0
        static void Main(string[] args)
        {
            MbnInterfaceManager  mbnInfMgr = new MbnInterfaceManager();
            IMbnInterfaceManager infMgr    = (IMbnInterfaceManager)mbnInfMgr;


            MbnConnectionManager  mbnConnectionMgr  = new MbnConnectionManager();
            IMbnConnectionManager ImbnConnectionMgr = (IMbnConnectionManager)mbnConnectionMgr;


            IMbnConnection[] connections = (IMbnConnection[])ImbnConnectionMgr.GetConnections();
            foreach (IMbnConnection conn in connections)
            {
                IMbnInterface      mobileInterface = infMgr.GetInterface(conn.InterfaceID) as IMbnInterface;
                MBN_INTERFACE_CAPS caps            = mobileInterface.GetInterfaceCapability();

                MBN_PROVIDER provider = mobileInterface.GetHomeProvider();
                Console.WriteLine("Device Id :" + caps.deviceID);
                Console.WriteLine("DataClass: " + caps.cellularClass);
                Console.WriteLine("Manufacturer: " + caps.manufacturer);
                Console.WriteLine("Model : " + caps.model);
                Console.WriteLine("Firmware Version: " + caps.firmwareInfo);
                Console.WriteLine("Manufacturer:        " + caps.manufacturer);
                Console.WriteLine("Model:               " + caps.model);
                Console.WriteLine("DeviceID:            " + caps.deviceID);
                Console.WriteLine("FirmwareInfo:        " + caps.firmwareInfo);

                Console.WriteLine("InterfaceID:         " + mobileInterface.InterfaceID);
                Console.WriteLine("Provider:            " + provider.providerName);
                Console.WriteLine("ProviderID:          " + provider.providerID);
                Console.WriteLine("ProviderState:       " + provider.providerState);
            }
            Console.ReadKey(true);
        }
예제 #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;
            }
        }
예제 #3
0
        public string GetMobileNumber()
        {
            IMbnInterfaceManager      interfaceManager = null;
            IMbnInterface             inf        = null;
            IMbnSubscriberInformation subscriber = null;

            try
            {
                interfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager();
                inf        = interfaceManager.GetInterface(InterfaceID);
                subscriber = inf.GetSubscriberInformation();

                foreach (var ob in subscriber.TelephoneNumbers)
                {
                    if (ob != null)
                    {
                        return((string)ob);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Warn(e);
            }
            finally
            {
                if (subscriber != null)
                {
                    Marshal.FinalReleaseComObject(subscriber);
                }
                if (inf != null)
                {
                    Marshal.FinalReleaseComObject(inf);
                }
                if (interfaceManager != null)
                {
                    Marshal.FinalReleaseComObject(interfaceManager);
                }
            }

            return("Unknown");
        }
예제 #4
0
        public void Test()
        {
            IMbnInterfaceManager      interfaceManager = null;
            IMbnInterface             inf        = null;
            IMbnSubscriberInformation subscriber = null;

            try
            {
                interfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager();
                inf        = interfaceManager.GetInterface(InterfaceID);
                subscriber = inf.GetSubscriberInformation();

                uint outCode = 0;
                inf.ScanNetwork(out outCode);

                uint age   = 0;
                var  array = inf.GetVisibleProviders(out age);

                var provider = inf.GetHomeProvider();

                //inf.SetPreferredProviders(new MBN_PROVIDER[] { plusProvider }, out outCode);

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(mobileProfileTemplate);

                xml["MBNProfile"]["SubscriberID"].InnerText = subscriber.SubscriberID;
                xml["MBNProfile"]["SimIccID"].InnerText     = subscriber.SimIccID;

                //Console.WriteLine("Profile: " + xml.OuterXml);

                IMbnConnection conn = null;

                try
                {
                    conn = inf.GetConnection();

                    //MBN_ACTIVATION_STATE state;
                    //string profile;
                    //conn.GetConnectionState(out state, out profile);

                    uint requestId;
                }
                finally
                {
                    if (conn != null)
                    {
                        Marshal.FinalReleaseComObject(conn);
                    }
                }
            }
            finally
            {
                if (subscriber != null)
                {
                    Marshal.FinalReleaseComObject(subscriber);
                }
                if (inf != null)
                {
                    Marshal.FinalReleaseComObject(inf);
                }
                if (interfaceManager != null)
                {
                    Marshal.FinalReleaseComObject(interfaceManager);
                }
            }
        }
예제 #5
0
        void ExecuteAction(ActionType action)
        {
            IMbnInterfaceManager      interfaceManager = null;
            IMbnInterface             inf        = null;
            IMbnSubscriberInformation subscriber = null;

            try
            {
                interfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager();
                inf        = interfaceManager.GetInterface(InterfaceID);
                subscriber = inf.GetSubscriberInformation();

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(mobileProfileTemplate);

                xml["MBNProfile"]["SubscriberID"].InnerText = subscriber.SubscriberID;
                xml["MBNProfile"]["SimIccID"].InnerText     = subscriber.SimIccID;

                //Console.WriteLine("Profile: " + xml.OuterXml);

                IMbnConnection conn = null;

                try
                {
                    conn = inf.GetConnection();

                    //MBN_ACTIVATION_STATE state;
                    //string profile;
                    //conn.GetConnectionState(out state, out profile);

                    uint requestId;

                    if (action == ActionType.Connect)
                    {
                        conn.Connect(MBN_CONNECTION_MODE.MBN_CONNECTION_MODE_TMP_PROFILE, xml.OuterXml, out requestId);
                    }
                    else
                    {
                        conn.Disconnect(out requestId);
                    }
                }
                finally
                {
                    if (conn != null)
                    {
                        Marshal.FinalReleaseComObject(conn);
                    }
                }
            }
            finally
            {
                if (subscriber != null)
                {
                    Marshal.FinalReleaseComObject(subscriber);
                }
                if (inf != null)
                {
                    Marshal.FinalReleaseComObject(inf);
                }
                if (interfaceManager != null)
                {
                    Marshal.FinalReleaseComObject(interfaceManager);
                }
            }
        }