Esempio n. 1
0
        public IReadOnlyList <SimCard> GetSimCards()
        {
            var results = new List <SimCard>();

            var modem = MobileBroadbandModem.GetDefault();

            if (modem == null)
            {
                return(results.AsReadOnly());
            }

            var account = modem.CurrentAccount;

            if (account == null)
            {
                return(results.AsReadOnly());
            }
            var simCard = new SimCard();

            simCard.ICCID  = account.CurrentDeviceInformation.SimIccId;
            simCard.IMSI   = account.CurrentDeviceInformation.SubscriberId;
            simCard.MSISDN = modem.DeviceInformation.TelephoneNumbers;

            simCard.MCC  = ExtractMCC(simCard.IMSI);
            simCard.MNC  = ExtractMNC(simCard.IMSI);
            simCard.MSID = ExtractMSID(simCard.IMSI);

            results.Add(simCard);

            return(results.AsReadOnly());
        }
Esempio n. 2
0
 private void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var           modem = MobileBroadbandModem.GetDefault();
         StringBuilder sb    = new StringBuilder();
         sb.AppendLine("Cellular Class: " + modem.DeviceInformation.CellularClass.ToString());
         sb.AppendLine("Current Radio Powerstate: " + modem.DeviceInformation.CurrentRadioState.ToString());
         sb.AppendLine("Custom Data Class: " + modem.DeviceInformation.CustomDataClass.ToString());
         sb.AppendLine("Supported Data Classes: " + modem.DeviceInformation.DataClasses.ToString());
         sb.AppendLine("Device ID: " + modem.DeviceInformation.DeviceId.ToString());
         sb.AppendLine("Device Type: " + modem.DeviceInformation.DeviceType.ToString());
         sb.AppendLine("Firmware Information: " + modem.DeviceInformation.FirmwareInformation);
         sb.AppendLine("Manufacturer: " + modem.DeviceInformation.Manufacturer);
         sb.AppendLine("IMEI (Mobile Equipment ID): " + modem.DeviceInformation.MobileEquipmentId);
         sb.AppendLine("Device Model: " + modem.DeviceInformation.Model);
         sb.AppendLine("Device Status: " + modem.DeviceInformation.NetworkDeviceStatus.ToString());
         sb.AppendLine("Suppported PINs: " + CheckForNullOrEmptyField(modem.DeviceInformation.PinManager.SupportedPins.ToString()));
         sb.AppendLine("Revision: " + modem.DeviceInformation.Revision);
         sb.AppendLine("Serial Number: " + modem.DeviceInformation.SerialNumber);
         sb.AppendLine("SIM ICCID: " + modem.DeviceInformation.SimIccId);
         sb.AppendLine("Subscriber ID: " + modem.DeviceInformation.SubscriberId);
         sb.AppendLine("Telephone Numbers: " + CheckForNullOrEmptyField(modem.DeviceInformation.TelephoneNumbers.ToString()));
         txtModemInformation.Text = sb.ToString();
         rootPage.NotifyUser("Success: Modem information loaded", NotifyType.StatusMessage);
     }
     catch (Exception ex)
     {
         rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage);
     }
 }
        private async void btnGetUICC_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var modem = MobileBroadbandModem.GetDefault();
                MobileBroadbandModemConfiguration modemCfg = await modem.GetCurrentConfigurationAsync();

                MobileBroadbandUicc uicc = modemCfg.Uicc;
                if (uicc != null)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("SIM Card ICCID:" + uicc.SimIccId);

                    sb.AppendLine("Application on SIM Card");
                    MobileBroadbandUiccAppsResult appsResult = await uicc.GetUiccAppsAsync();

                    foreach (var uiccApp in appsResult.UiccApps)
                    {
                        sb.AppendLine("Kind: " + uiccApp.Kind);
                    }
                    txtSIMInformation.Text = sb.ToString();
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage);
            }
        }
Esempio n. 4
0
        private async void btnGetUICC_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var modem = MobileBroadbandModem.GetDefault();
                MobileBroadbandModemConfiguration modemCfg = await modem.GetCurrentConfigurationAsync();

                MobileBroadbandUicc uicc = modemCfg.Uicc;
                if (uicc != null)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("SIM Card ICCID:" + uicc.SimIccId);


                    MobileBroadbandUiccAppsResult appsResult = await uicc.GetUiccAppsAsync();

                    System.Collections.ObjectModel.ObservableCollection <object> AppList = new System.Collections.ObjectModel.ObservableCollection <object>();
                    foreach (var uiccApp in appsResult.UiccApps)
                    {
                        ListBoxItem item = new ListBoxItem();
                        item.Name    = uiccApp.Kind.ToString();
                        item.Content = uiccApp;
                        AppList.Add(item);
                    }

                    listUiccApps.ItemsSource = AppList;
                    if (AppList.Count > 0)
                    {
                        listUiccApps.SelectedIndex = 0;
                    }
                    else
                    {
                        sb.AppendLine("No UICC app found.");
                    }

                    txtUICCInformation.Text = sb.ToString();
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage);
            }
        }
        private void btnDeviceService_Click(object sender, RoutedEventArgs e)
        {
            var modem         = MobileBroadbandModem.GetDefault();
            var deviceService = modem.DeviceServices;

            if (deviceService != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var d in deviceService)
                {
                    sb.AppendLine(String.Format("DeviceService ID:{0}, Read Allowed:{1}, Write Allowed:{2}", d.DeviceServiceId.ToString(), d.IsDataReadSupported.ToString(), d.IsDataWriteSupported.ToString()));
                }
                txtModemInformation.Text = sb.ToString();
            }
            else
            {
                rootPage.NotifyUser("No Device Services found.", NotifyType.ErrorMessage);
            }
        }
        void GetCurrentDeviceInfo(string accountId)
        {
            try
            {
                // Test touching new TH objectq
                var modem    = MobileBroadbandModem.GetDefault();
                var deviceId = modem.DeviceInformation.DeviceId;

                var mobileBroadbandAccount = MobileBroadbandAccount.CreateFromNetworkAccountId(accountId);

                ProviderName.Text     = mobileBroadbandAccount.ServiceProviderName;
                ProviderGuid.Text     = mobileBroadbandAccount.ServiceProviderGuid.ToString();
                NetworkAccountId.Text = mobileBroadbandAccount.NetworkAccountId;

                var currentNetwork = mobileBroadbandAccount.CurrentNetwork;

                if (currentNetwork != null)
                {
                    string accessPointName = currentNetwork.AccessPointName;
                    if (String.IsNullOrEmpty(accessPointName))
                    {
                        accessPointName = "(not connected)";
                    }

                    NetRegister.Text            = currentNetwork.NetworkRegistrationState.ToString();
                    NetRegError.Text            = NetErrorToString(currentNetwork.RegistrationNetworkError);
                    PacketAttachError.Text      = NetErrorToString(currentNetwork.PacketAttachNetworkError);
                    ActivateError.Text          = NetErrorToString(currentNetwork.ActivationNetworkError);
                    AccessPointName.Text        = accessPointName;
                    NetworkAdapterId.Text       = currentNetwork.NetworkAdapter.NetworkAdapterId.ToString();
                    NetworkType.Text            = currentNetwork.NetworkAdapter.NetworkItem.GetNetworkTypes().ToString();
                    RegisteredProviderId.Text   = currentNetwork.RegisteredProviderId;
                    RegisteredProviderName.Text = currentNetwork.RegisteredProviderName;
                    RegisteredDataClass.Text    = currentNetwork.RegisteredDataClass.ToString();
                }
                else
                {
                    NetRegister.Text            = "";
                    NetRegError.Text            = "";
                    PacketAttachError.Text      = "";
                    ActivateError.Text          = "";
                    AccessPointName.Text        = "";
                    NetworkAdapterId.Text       = "";
                    NetworkType.Text            = "";
                    RegisteredProviderId.Text   = "";
                    RegisteredProviderName.Text = "";
                    RegisteredDataClass.Text    = "";
                }

                var deviceInformation = mobileBroadbandAccount.CurrentDeviceInformation;

                if (deviceInformation != null)
                {
                    string mobileNumber = "";
                    if (deviceInformation.TelephoneNumbers.Count > 0)
                    {
                        mobileNumber = deviceInformation.TelephoneNumbers[0];
                    }

                    DeviceManufacturer.Text = deviceInformation.Manufacturer;
                    DeviceModel.Text        = deviceInformation.Model;
                    Firmware.Text           = deviceInformation.FirmwareInformation;
                    CellularClasses.Text    = deviceInformation.CellularClass.ToString();
                    DataClasses.Text        = deviceInformation.DataClasses.ToString();
                    if (deviceInformation.DataClasses.HasFlag(Windows.Networking.NetworkOperators.DataClasses.Custom))
                    {
                        DataClasses.Text += " (custom is " + deviceInformation.CustomDataClass + ")";
                    }
                    MobileNumber.Text        = mobileNumber;
                    SimId.Text               = deviceInformation.SimIccId;
                    DeviceType.Text          = deviceInformation.DeviceType.ToString();
                    DeviceId.Text            = deviceInformation.DeviceId.ToString();
                    NetworkDeviceStatus.Text = deviceInformation.NetworkDeviceStatus.ToString();

                    if (deviceInformation.CellularClass == CellularClass.Gsm)
                    {
                        MobEquipIdLabel.Text = "IMEI:";
                        MobEquipIdValue.Text = deviceInformation.MobileEquipmentId;

                        SubIdLabel.Text = "IMSI:";
                        SubIdValue.Text = deviceInformation.SubscriberId;
                    }
                    else if (deviceInformation.CellularClass == CellularClass.Cdma)
                    {
                        MobEquipIdLabel.Text = "ESN/MEID:";
                        MobEquipIdValue.Text = deviceInformation.MobileEquipmentId;

                        SubIdLabel.Text = "MIN/IRM:";
                        SubIdValue.Text = deviceInformation.SubscriberId;
                    }
                    else
                    {
                        MobEquipIdLabel.Text = "";
                        MobEquipIdValue.Text = "";
                        SubIdLabel.Text      = "";
                        SubIdValue.Text      = "";
                    }
                }
                else
                {
                    DeviceManufacturer.Text = "";
                    DeviceModel.Text        = "";
                    Firmware.Text           = "";
                    CellularClasses.Text    = "";
                    DataClasses.Text        = "";
                    MobileNumber.Text       = "";
                    SimId.Text               = "";
                    DeviceType.Text          = "";
                    DeviceId.Text            = "";
                    NetworkDeviceStatus.Text = "";
                    MobEquipIdLabel.Text     = "";
                    MobEquipIdValue.Text     = "";
                    SubIdLabel.Text          = "";
                    SubIdValue.Text          = "";
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage);

                ProviderName.Text       = "";
                ProviderGuid.Text       = "";
                NetworkAccountId.Text   = "";
                NetRegister.Text        = "";
                NetRegError.Text        = "";
                PacketAttachError.Text  = "";
                ActivateError.Text      = "";
                AccessPointName.Text    = "";
                NetworkAdapterId.Text   = "";
                NetworkType.Text        = "";
                DeviceManufacturer.Text = "";
                DeviceModel.Text        = "";
                Firmware.Text           = "";
                CellularClasses.Text    = "";
                DataClasses.Text        = "";
                MobileNumber.Text       = "";
                SimId.Text                  = "";
                DeviceType.Text             = "";
                DeviceId.Text               = "";
                NetworkDeviceStatus.Text    = "";
                MobEquipIdLabel.Text        = "";
                MobEquipIdValue.Text        = "";
                SubIdLabel.Text             = "";
                SubIdValue.Text             = "";
                RegisteredProviderId.Text   = "";
                RegisteredProviderName.Text = "";
                RegisteredDataClass.Text    = "";
            }
        }