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

Java Development

Reply
Developer
Posts: 51
Registered: ‎04-19-2009
My Device: Not Specified

Wifi not available when Mobile Network is off on Blackberry Bold

Hi all,

The application I'm writing is supposed to perform a couple of http requests to be sent to a web server. The main networking requirement states that the application should prefer Wifi connection if available over any other connections.

I've succesfully implemented Wifi detection stuff using service book records the ServiceBook.getSB() returns. So, if there's active and not disabled service book record that represents Wifi - I append ";interface=wifi" to the URL and it works just fine. Otherwise I append ";deviceside=true" to pass it through other available routes.

This works well on Curve8900 and Tour but does not work as expected on Bold. On Bold it does not detect Wifi availability if Mobile Network is turned off. If there is Wifi turned ON in 'Manage Connection' screen and Mobile Network is OFF then the service book does not have Wifi transport record at all.

We get this either on a real devices and in simulator. Did you ever encounter behaiour like that on a Bold device? Is there any walkarounds I would apply to make Wifi work in that case?

Thank you!
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Wifi not available when Mobile Network is off on Blackberry Bold

You are checking for the wrong type of WiFi coverage. I'm not sure what the presence of valid and non-disabled WPTCP WiFi SB records indicates, but it definitely does not fully correlate with the availability of WiFi access. When both CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT) and WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED are true, then you can connect via an WiFi AP. What can happen though is that that the WiFi network does not provide Internet access.

 

It may well be that the presence of valid and non-disabled WPTCP WiFi SB records indicates that the BlackBerry managed to establish a secure tunnel via WiFi to RIM's network.

Developer
Posts: 51
Registered: ‎04-19-2009
My Device: Not Specified

Re: Wifi not available when Mobile Network is off on Blackberry Bold

hey klyubin,

I just tried to implement it the way you suggested and can see now that both
CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT) and WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED are FALSE if Wifi is ON while Mobile Network is OFF. This really looks like there's no Wifi available when Mobile Network is turned off.

Does it work as it's supposed to be? Could anyone please clarify this?
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Wifi not available when Mobile Network is off on Blackberry Bold

Just checking... Is the BlackBerry actually connected to a WiFi access point? It might show that WiFi is ON but is not necessarily connected to an access point. Check whether the SSID of the WiFi network is displayed at the top of the BlackBerry home screen and next to the WiFi checkbox in the Manage Connections popup.
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Wifi not available when Mobile Network is off on Blackberry Bold

FYI, I can use WiFi (;interface=wifi) on my Bold even without a Sim card, so I don't believe that mobile access is required to use WiFi.

New Developer
Posts: 96
Registered: ‎07-26-2008
My Device: Not Specified

Re: Wifi not available when Mobile Network is off on Blackberry Bold

We have seen the samething and yes it is misleading - we just chose to overide that by testing for a connection to a URL of interest to our application when using ;interface=wifi and if that succeeded then we assumed wifi was available for use.

(We only have Bold devices that have WiFi so not sure if this is an issue on non-Bold non-4.6 devices)

Highlighted
Developer
Posts: 21
Registered: ‎01-07-2009
My Device: Not Specified

Re: Wifi not available when Mobile Network is off on Blackberry Bold

[ Edited ]

I think CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT) returns false when the Mobile Network is off (not sure if it's always the case).

 

You can go through the ServiceBook records and check if each record's cid contains "wptcp" and the uid contains "wifi". If both those are true, then check WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED.

 

ServiceBook sb = ServiceBook.getSB();
ServiceRecord[] records = sb.getRecords();
boolean wifiIsAvailable = false;
for (int i = 0; i < records.length; i++) {
ServiceRecord myRecord = records[i];
String cid, uid;

if (myRecord.isValid() && !myRecord.isDisabled()) {
cid = myRecord.getCid().toLowerCase();
uid = myRecord.getUid().toLowerCase();
if (cid.indexOf("wptcp") != -1 && uid.indexOf("wifi") != -1) {
wifiIsAvailable = true;
break;
}
}
}
if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED && wifiIsAvailable) {
// wi-fi is available
}

 I can't remember exactly where I got the above solution from. I think from a KB article maybe?

 

EDIT for clarity: The above is exactly like you've described in your first post, but I've tried this on a couple Bolds from different carriers and the service records do contain a wi-fi transport record even with Mobile Network turned off.

Message Edited by speedwagon on 08-19-2009 02:06 PM
Message Edited by speedwagon on 08-19-2009 02:09 PM