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); }
public void GetConnectionStatus() { try { MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager(); IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager; if (mbnInfMgrInterface == null) { string connectionMessage = "no connection found!"; } if (mbnInfMgrInterface != null) { IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[]; if (mobileInterfaces != null && mobileInterfaces.Length > 0) { // Use the first interface, as there should only be one mobile data adapter IMbnSignal signalDetails = mobileInterfaces[1] as IMbnSignal; Int32.TryParse(signalDetails.GetSignalStrength().ToString(), out PhoneSignal); PhoneSignal = Convert.ToInt32(((float)PhoneSignal / 16) * 100); MBN_PROVIDER provider = mobileInterfaces[0].GetHomeProvider(); PhoneNetwork = provider.providerName.ToString(); if (String.IsNullOrEmpty(SIMNumber)) { try { IMbnSubscriberInformation subInfo = mobileInterfaces[0].GetSubscriberInformation(); if (subInfo != null) { SIMNumber = (subInfo.SimIccID); } else { Console.WriteLine("Unable to read SIM info"); } } catch (Exception) { Console.WriteLine("Unable to read SIM info"); } } else { } } } Console.WriteLine("no good connection"); } catch (Exception ex) { Console.WriteLine(ex); } }
private void mobile_connect_button_Click(object sender, RoutedEventArgs e) { //connect to mobile profile mobile_password_label.Content = "Connected to Mobile Broadband Network"; MBNConnect.MBNConnect allive = new MBNConnect.MBNConnect(); MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager(); IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager; IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[]; IMbnInterface inf = (IMbnInterface)mobileInterfaces[1]; IMbnConnection conn = inf.GetConnection(); allive.KeepConnectionAllive(conn); }
private static void Main() { while (true) { var mbnInfMgr = new MbnInterfaceManager(); var infMgr = (IMbnInterfaceManager)mbnInfMgr; var interfaces = (IMbnInterface[])infMgr.GetInterfaces(); foreach (var mobileInterface in interfaces) { var capabilities = mobileInterface.GetInterfaceCapability(); var provider = mobileInterface.GetHomeProvider(); var readyState = mobileInterface.GetReadyState(); var radio = mobileInterface as IMbnRadio; var signal = mobileInterface as IMbnSignal; var signalStrength = signal.GetSignalStrength(); var signalStrengthDb = -113 + (int)signalStrength * 2; Console.WriteLine("Manufacturer: " + capabilities.manufacturer); Console.WriteLine("Model: " + capabilities.model); Console.WriteLine("DeviceID: " + capabilities.deviceID); Console.WriteLine("FirmwareInfo: " + capabilities.firmwareInfo); Console.WriteLine("Ready State : " + readyState); if (radio != null) { Console.WriteLine("HardwareRadioState: " + radio.HardwareRadioState); Console.WriteLine("SoftwareRadioState: " + radio.SoftwareRadioState); } Console.WriteLine("InterfaceID: " + mobileInterface.InterfaceID); Console.WriteLine("Provider: " + provider.providerName); Console.WriteLine("ProviderID: " + provider.providerID); Console.WriteLine("ProviderState: " + provider.providerState); if (signalStrength != (uint)MBN_SIGNAL_CONSTANTS.MBN_RSSI_UNKNOWN) { Console.WriteLine("Signal Strength: " + signalStrengthDb + " dBm"); } else { Console.WriteLine("Signal Strength: unknown"); } } Console.WriteLine(""); Console.WriteLine("Press enter to scan again, or close the window to exit"); Console.ReadKey(); } }
public MbnInterfaceManagerWrapper(IReynaLogger logger) { _logger = logger; _mbnInterfaceManager = null; _canInitialiseMbnInterfaceManager = true; }
static void Main(string[] args) { var process = new Process { StartInfo = { FileName = "netsh.exe", Arguments = "wlan show interfaces ", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; process.Start(); var output = process.StandardOutput.ReadToEnd(); var MProcess = new Process { StartInfo = { FileName = "netsh.exe", Arguments = "mbn show interface", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; MProcess.Start(); var MOutput = MProcess.StandardOutput.ReadToEnd(); var profileProcess = new Process { StartInfo = { FileName = "netsh.exe", Arguments = "mbn show interface BarningMobiel", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; profileProcess.Start(); var profileOutput = profileProcess.StandardOutput.ReadToEnd(); var wlanEnabled = output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(l => l.Contains("There is no wireless interface on the system.")); var wlanState = output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(l => l.Contains("State")); var mobileState = MOutput.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(l => l.Contains("State")); var mobileEnabled = MOutput.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(l => l.Contains("There is no Mobile Broadband interface")); var mobilePaused = MOutput.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(l => l.Contains("Provider Name")); //get the simcard information try { MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager(); IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager; if (mbnInfMgrInterface != null) { IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[]; if (mobileInterfaces != null && mobileInterfaces.Length > 0) { // Just use the first interface IMbnSubscriberInformation subInfo = mobileInterfaces[0].GetSubscriberInformation(); Console.WriteLine(subInfo); if (subInfo != null) { SIMNumber = subInfo.SimIccID; Console.WriteLine(SIMNumber); // Get the connection profile MbnConnectionProfileManager mbnConnProfileMgr = new MbnConnectionProfileManager(); IMbnConnectionProfileManager mbnConnProfileMgrInterface = mbnConnProfileMgr as IMbnConnectionProfileManager; if (mbnConnProfileMgrInterface != null) { bool connProfileFound = false; string profileName = String.Empty; Console.WriteLine(profileOutput); } } } } } catch (Exception e) { // Console.WriteLine(e); } //check if there is a mobile device if (!MOutput.Contains("Mobile Broadband Service (wwansvc) is not running.")) { //if there is a mobile interface enabled if (!MOutput.Contains("There is no Mobile Broadband interface")) { //check connection status if (mobileState != null) { //check if sim is already known bij the system //compare the device id from the system with the simsccid(emei) of the profile //get the value from the string string deviceIdstring = Regex.Match(SIMNumber, @"\d+").Value; //convert to decimal becouse the value is more than the int.max number(9digits) decimal deviceIdInt = 0; //parse deviceIdInt = Decimal.Parse(deviceIdstring); //do the same with the xml number decimal xml_subscriberIdInt = 0; xml_subscriberIdInt = decimal.Parse(xml_subscriberId()); //if there is a match the continue else create the profile if (deviceIdInt != xml_subscriberIdInt) { ColorTextAlert("simiccid number from mbnapi =" + deviceIdInt + "simicc number from profile =" + xml_subscriberIdInt + " are not the same"); createMobileProfile(); } else { // ColorTextAlert("deviceid number from netsh =" + deviceIdInt + "Imei number from profile =" + xml_subscriberIdInt + "are the same"); //dont change the words if (mobileState.Contains("Not connected")) { ColorTextAlert("Connecting to mobile......."); connectToMobiel(false); } else if (mobileState.Contains("connected")) { ColorText("Connected to mobiel ,you`re welcome. ;-)"); } } } } else if (MOutput.Contains("There is no Mobile Broadband interface")) { ColorTextAlert("enable mobiel interface..."); enableMobiel(); } } //check if there is a wifi connection interface if (output.Contains("There is no wireless interface on the system")) { enableWiFi(); } else { try { //dont change the words if (wlanState.Contains("disconnected")) { ColorTextAlert("connecting to Wi-Fi......"); connectToWifi(false); } else if (wlanState.Contains("connected")) { ColorText("Connected to Wifi ,you re welcome. ;-)"); } } catch (NullReferenceException e) { ColorTextAlert("No Wlan interface found on the system" + e); } } filesystemwatcher_keepconnected(); Console.Read(); }