ARTICLE AD BOX
We use following function to get the mobile network data class(3G, 4G, CDMA)of a SIM card inserted into a laptop. It can get the correct data class for our 4G SIM card, but the data class for a 5G SIM card is "Unknown", Is this API too old to recognize the latest 5G SIM card, or It has not been updated to the latest version? Is there any better way to get the data class information using C++/C#? Thanks.
int GetMobileNetworkInfo(std::vector<MOBILE_NETWORK> &Mbinterfaces) { HRESULT result = E_FAIL; if (interfaceManager == NULL) { // Initialize COM and obtain an accessor to the MBN Interface Manager. //-------------------------------------------------------------------- result = CoCreateInstance(CLSID_MbnInterfaceManager, NULL, CLSCTX_ALL, IID_IMbnInterfaceManager, (void**)&interfaceManager); if (FAILED(result)) { return result; } } SAFEARRAY *mbmInterfaces = NULL; result = interfaceManager->GetInterfaces(&mbmInterfaces); if (FAILED(result)) { return result; } LONG indexOfFirstMbmInterface; LONG indexOfLastMbmInterface; result = SafeArrayGetLBound(mbmInterfaces, 1, &indexOfFirstMbmInterface); if (FAILED(result)) { if (mbmInterfaces != NULL) { ::SafeArrayDestroy(mbmInterfaces); mbmInterfaces = NULL; } return result; } result = SafeArrayGetUBound(mbmInterfaces, 1, &indexOfLastMbmInterface); if (FAILED(result)) { if (mbmInterfaces != NULL) { ::SafeArrayDestroy(mbmInterfaces); mbmInterfaces = NULL; } return result; } CComPtr<IMbnInterface> pMbnInterface = NULL; for (LONG i = indexOfFirstMbmInterface; i <= indexOfLastMbmInterface; i++) { result = SafeArrayGetElement(mbmInterfaces, &i, (void*)(&pMbnInterface)); MOBILE_NETWORK mbn = {MBN_READY_STATE_OFF, MBN_CELLULAR_CLASS_NONE, "UNKOWN", MBN_RSSI_UNKNOWN, MBN_ACTIVATION_STATE_NONE, "UNKOWN"}; if (SUCCEEDED(result)) // Dump some of the Interface's information: { // Get the celluar class and data class MBN_INTERFACE_CAPS interfaceCapabilities; result = pMbnInterface->GetInterfaceCapability(&interfaceCapabilities); if (SUCCEEDED(result)) { mbn.cellularClass = interfaceCapabilities.cellularClass; if (interfaceCapabilities.dataClass&MBN_DATA_CLASS_CUSTOM) { mbn.dataClass = str(interfaceCapabilities.customDataClass); } else { switch (interfaceCapabilities.dataClass) { case MBN_DATA_CLASS_NONE: mbn.dataClass = "NONE"; break; case MBN_DATA_CLASS_GPRS: mbn.dataClass = "GPRS"; break; case MBN_DATA_CLASS_EDGE: mbn.dataClass = "EDGE"; break; case MBN_DATA_CLASS_UMTS: mbn.dataClass = "UMTS"; break; case MBN_DATA_CLASS_HSDPA: mbn.dataClass = "HSDPA"; break; case MBN_DATA_CLASS_LTE: mbn.dataClass = "LTE"; break; case MBN_DATA_CLASS_5G_NSA: mbn.dataClass = "5G NSA"; break; case MBN_DATA_CLASS_5G_SA: mbn.dataClass = "5G SA"; break; case MBN_DATA_CLASS_HSUPA: mbn.dataClass = "HSUPA"; break; case MBN_DATA_CLASS_1XRTT: mbn.dataClass = "1xRTT"; break; case MBN_DATA_CLASS_1XEVDO: mbn.dataClass = "IxEV-DO"; break; case MBN_DATA_CLASS_1XEVDO_REVA: mbn.dataClass = "IxEV-DO RevA"; break; case MBN_DATA_CLASS_1XEVDV: mbn.dataClass = "1xXEV-DV"; break; case MBN_DATA_CLASS_3XRTT: mbn.dataClass = "3xRTT"; break; case MBN_DATA_CLASS_1XEVDO_REVB: mbn.dataClass = "1xEV-DO RevB"; break; case MBN_DATA_CLASS_UMB: mbn.dataClass = "UMB"; break; default: mbn.dataClass = "UNKOWN"; break; } } //free bstr DeallocateBString(interfaceCapabilities.customDataClass); //might need to clean up all the strings from MBN_INTERFACE_CAPS DeallocateBString(interfaceCapabilities.customBandClass); DeallocateBString(interfaceCapabilities.deviceID); DeallocateBString(interfaceCapabilities.manufacturer); DeallocateBString(interfaceCapabilities.model); DeallocateBString(interfaceCapabilities.firmwareInfo); } Mbinterfaces.push_back(mbn); } } if (mbmInterfaces != NULL) { ::SafeArrayDestroy(mbmInterfaces); mbmInterfaces = NULL; } return 0; }