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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
My Carrier: BlackBerry

Is it currently possible to toggle wifi state programmatically?

I can't seem to be able to change the wifi state. I can read the state of the wifi though. I saw in a previous post that this was not possible.

http://supportforums.blackberry.com/t5/Native-Development/Turn-off-Wifi-programmatically/m-p/2296363...

 

Is it still impossible?

Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Is it currently possible to toggle wifi state programmatically?

[ Edited ]

This seems to imply that it will turn the wifi on

 

https://developer.blackberry.com/native/reference/core/com.qnx.doc.wifi_service.lib_ref/topic/wifi_s...

 

I'm not sure if it will work as it says it starts it in STA mode and I have no idea what that means but It's the only thing I noticed about turning the wifi on and off

 

here's other wifi related info

Wi-Fi Service Library

 

If this doesnt do the trick I would suggest submitting a Jira ticket

 

https://www.blackberry.com/jira/secure/Dashboard.jspa

Developer
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
My Carrier: BlackBerry

Re: Is it currently possible to toggle wifi state programmatically?

Actually that's an enum to know the status of the wifi radio. This


http://developer.blackberry.com/native/reference/core/com.qnx.doc.wifi_service.lib_ref/topic/wifi_se...

 

Will let you change the status of the wifi. My code is

#include "WifiController.hpp"
#include <wifi/wifi_service.h>
#include "GeoNotification.hpp"
WifiController::WifiController() {}
WifiController::~WifiController() {}

int WifiController::toggleWifiState(bool state)
{
	getWifiState();
	int status = wifi_set_sta_power(state);
	if(status==WIFI_SUCCESS)
		qDebug()<<"WIFI ENABLE SUCCESS CURRENT STATE: "<<state;
	else qDebug()<<"WIFI ENABLE FAILURE CURRENT STATE: "<<state;
	return status;

}
int WifiController::getWifiState()
{
	wifi_status_t status;
	wifi_get_status(&status);
	if(status == WIFI_STATUS_BUSY)
	{
		return 2;
	}
	if(status == WIFI_STATUS_RADIO_ON)
	{
		return 1;
	}
	if(status == WIFI_STATUS_RADIO_OFF)
	{
		return 0;
	}
	return 0;
}

 

I call the toggleWifiState() function to change the wifi state. But it doesn't work Smiley Sad I am stuck on this problem for a long time.

 

 

 

 

 

Highlighted
Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Is it currently possible to toggle wifi state programmatically?

That would be the code from the link I posted, appears that it does work

 

=)

Developer
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
My Carrier: BlackBerry

Re: Is it currently possible to toggle wifi state programmatically?

It is not working for me though Smiley Sad Doesn't toggle the state. Only can give the state. What am I doing wrong here? Thanks.
Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Is it currently possible to toggle wifi state programmatically?

That would likely mean that STA mode isn't regular wifi, and your best bet would be to file a feature request ticket on jira