// Initialize the MBN interfaces public void InitializeManagers() { try { // Get MbnInterfaceManager if (m_MbnInterfaceManager == null) { m_MbnInterfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager(); } // Get MbnConnectionManager if (m_MbnConnectionManager == null) { m_MbnConnectionManager = (IMbnConnectionManager) new MbnConnectionManager(); } // Get MbnDeviceServicesManager if (m_MbnDeviceServicesManager == null) { m_MbnDeviceServicesManager = (IMbnDeviceServicesManager) new MbnDeviceServicesManager(); } } catch (Exception e) { MessageBox.Show(ParseExceptionCode(e)); } }
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 PinWrapper(JSCallback jsCallback) { m_jsCallback = jsCallback; if (m_MbnInterfaceManager == null) { // Get MbnInterfaceManager m_MbnInterfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager(); } // Get the mbn interface m_MbnInterface = GetFirstInterface(); if (m_PinManagerEventsSink == null) { // Advise for pin manager events m_PinManagerEventsSink = new PinManagerEventsSink(this.OnGetPinStateCompleteHandler, GetMbnPinManagerEventsConnectionPoint()); } if (m_PinEventsSink == null) { // Advise for pin events m_PinEventsSink = new PinEventsSink(this.OnPinEnterComplete, GetMbnPinEventsConnectionPoint()); } }
public PinWrapper(JSCallback jsCallback) { m_jsCallback = jsCallback; if (m_MbnInterfaceManager == null) { // Get MbnInterfaceManager m_MbnInterfaceManager = (IMbnInterfaceManager)new MbnInterfaceManager(); } // Get the mbn interface m_MbnInterface = GetFirstInterface(); if (m_PinManagerEventsSink == null) { // Advise for pin manager events m_PinManagerEventsSink = new PinManagerEventsSink(this.OnGetPinStateCompleteHandler, GetMbnPinManagerEventsConnectionPoint()); } if (m_PinEventsSink == null) { // Advise for pin events m_PinEventsSink = new PinEventsSink(this.OnPinEnterComplete, GetMbnPinEventsConnectionPoint()); } }
public void InitializeManagers() { lock (syncRoot) { try { // Get MbnInterfaceManager if (m_MbnInterfaceManager == null) { m_MbnInterfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager(); } // Get MbnConnectionManager if (m_MbnConnectionManager == null) { m_MbnConnectionManager = (IMbnConnectionManager) new MbnConnectionManager(); } // Get MbnDeviceServicesManager if (m_MbnDeviceServicesManager == null) { m_MbnDeviceServicesManager = (IMbnDeviceServicesManager) new MbnDeviceServicesManager(); } // Register for notifications RegisterForNotifications(); } catch (Exception e) { rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage); } } }
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); }
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"); }
// Initialize the MBN interfaces public void InitializeManagers() { lock (syncRoot) { try { // Get MbnInterfaceManager if (m_MbnInterfaceManager == null) { m_MbnInterfaceManager = (IMbnInterfaceManager)new MbnInterfaceManager(); } // Get MbnConnectionManager if (m_MbnConnectionManager == null) { m_MbnConnectionManager = (IMbnConnectionManager)new MbnConnectionManager(); } // Get MbnDeviceServicesManager if (m_MbnDeviceServicesManager == null) { m_MbnDeviceServicesManager = (IMbnDeviceServicesManager)new MbnDeviceServicesManager(); } // Register for notifications RegisterForNotifications(); } catch (Exception e) { rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage); } } }
static void RefreshRunningProxies() { List <string> infIdList = new List <string>(); IMbnInterfaceManager interfaceManager = null; try { interfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager(); foreach (var obj in interfaceManager.GetInterfaces()) { try { IMbnInterface inf = (IMbnInterface)obj; infIdList.Add(inf.InterfaceID); Marshal.FinalReleaseComObject(inf); } catch { } } } finally { if (interfaceManager != null) { Marshal.FinalReleaseComObject(interfaceManager); } } foreach (var qproxy in quadplayProxyList) { if (!infIdList.Contains(qproxy.InterfaceID)) { qproxy.InvalidateInterface(); } } foreach (string infId in infIdList) { bool exists = false; foreach (var qproxy in quadplayProxyList) { if (qproxy.InterfaceID == infId) { exists = true; break; } } if (!exists) { bool added = false; lock (quadplayProxyList) { foreach (var qproxy in quadplayProxyList.OrderBy(el => random.Next())) { if (qproxy.InterfaceID == null) { qproxy.SetToInterface(infId); logger.Info($"Binded Proxy: {qproxy.ID} To Interface: {qproxy.InterfaceID}"); added = true; break; } } } if (!added) { var qproxy = new QuadplayProxy(nextID++); qproxy.SetToInterface(infId); qproxy.Start(); lock (quadplayProxyList) { quadplayProxyList.Add(qproxy); } } } } }
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); } } }
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); } } }
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(); }