Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
jimnu
Posts: 12
Registered: ‎06-18-2013
My Device: BlackBerry Z10

QNetworkConfiguration::BearerType returning 2G on 3G connections

When I try and use the following code to determine what type of connection my application is using, it's only providing  QNetworkConfiguration::Bearer2G when the device is connected to a HSPA or HSPA+ connection (I've not been able to test the CDMA or WCDMA connections).

 

QNetworkConfigurationManager mgr;
QNetworkConfiguration _defaultConfig = mgr.defaultConfiguration();
int bt = _defaultConfig.bearerType()

 

It detects WLAN fine, but I need to know whether the user has a 2G or 3G connection when Wi-Fi is not available.

 

I'm developing against the 10.1.0.1720 SDK and my Z10 is OS 10.1.0.1720.

 

Cheers

Please use plain text.
Developer
DrShavargo
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10

Re: QNetworkConfiguration::BearerType returning 2G on 3G connections

According to the QNetworkConfiguration page, it should return QNetworkConfiguration::BearerHSPA (value of 6) when you're connected to 3G.Your call is picking up the first connection, which is 2G in this case. Try searching for HSPA with a call to allConfigurations(), like so:

 

QNetworkConfigurationManager mgr;
QList _allConfig = mgr.allConfigurations(0x000000e /*for active or 0x0000006 for discovered*/);

it'll return a QList<QNetworkConfiguration>, which you can itterate through with a while loop or a few if statements to find a connection on type 6 (HSPA). once you find it:

QNetworkConfiguration _myConfig = _allConfig[/* pointer to the qlist element*/] 
// or however else you want to set it
----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Please use plain text.
Contributor
jimnu
Posts: 12
Registered: ‎06-18-2013
My Device: BlackBerry Z10

Re: QNetworkConfiguration::BearerType returning 2G on 3G connections

[ Edited ]

My thanks.  I've tried using QNetworkConfigurationManager::allConfigurations, with both QNetworkConfiguration::smileyvery-happy:iscovered and QNetworkConfiguration::Active but it is still only detecting a 2G connection when Wi-Fi is turn off.  My code is:

 

QNetworkConfigurationManager mgr;
QList<QNetworkConfiguration> _allConfig = mgr.allConfigurations(QNetworkConfiguration::Discovered);
int length = _allConfig.size();

for (int i = 0; i < length; i++) {
	QNetworkConfiguration _myConfig = _allConfig[i];
	Logging::writeLn("ConnectionUtils::getNetworkBearerType: " + _myConfig.bearerTypeName());
}

 If the device is connected via Wi-Fi then returns WLAN and 2G.

Please use plain text.
Developer
DrShavargo
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10

Re: QNetworkConfiguration::BearerType returning 2G on 3G connections

Then your device is simply not connected to an HSPA type network. According to this Wikipedia page, 

 

"The following common standards comply with the IMT2000/3G standard:

EDGE, a revision by the 3GPP organization to the older 2G GSM based transmission methods;

W-CDMA;

HSPA and HSPA+;

CDMA2000"

 

On the QNetworkConfiguration Cascades API page I linked to in my last post, Bearer2G is for a CSD, GPRS, HSCSD, EDGE or cdmaOne interface. It would seem that your 3G connection is EDGE (Bearer2G) type, and not BearerHSPA, BearerWCDMA or BearerCDMA2000. So it will return a Bearer2G connection type even if you're on a 3G network. At least that's what I seem to gather from it.

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Please use plain text.
Contributor
jimnu
Posts: 12
Registered: ‎06-18-2013
My Device: BlackBerry Z10

Re: QNetworkConfiguration::BearerType returning 2G on 3G connections

[ Edited ]

All I can say to this, at the moment, is that the signal indicator shows an uppercase H and full signal-strength.  I shall try using other mobile providers.

 

Edit: additional information; if I set the Network Mode to 3G in the Mobile Network settings, it still reports 2G.

Please use plain text.