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
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

wifi_service.h and wifi_set_sta_power()?

Hi,

 

trying to get wifi_set_sta_power() work on NDK 10.0.9.386.

 

when i try to call it, i get "Permissioned Denied" (according to errno).

 

is the wifi_service (wifi_service.h) working in this version of the NDK?

 

the code is pretty simple.. 

 

int setWifiStatus(bool status) {
int result;
	result = wifi_set_sta_power(status);
	if (result != WIFI_SUCCESS) {
		// function call to wifi_set_sta_power failed
		fprintf(stdout, "%s\n", "call to wifi_set_sta_power failed");
		fprintf(stdout, "%s\n", strerror(errno));
		fflush(stdout);
        }
        return result;
}

----
output:

call to wifi_set_sta_power failed
Permission denied

 

thanks,

 

J

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: wifi_service.h and wifi_set_sta_power()?

Have you tried to call wifi_get_status() ?

 

(And no, I have no idea if this works, I'm just suggesting another thing to try since the results might tell you something useful.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: wifi_service.h and wifi_set_sta_power()?

hey there, yes, the wifi_get_status() works.  the set power doesn't though.

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
borceg
Posts: 671
Registered: ‎03-21-2012
My Device: BlackBerry PlayBook 16GB
My Carrier: Vip

Re: wifi_service.h and wifi_set_sta_power()?

[ Edited ]

Seems that your app is not allowed to change wifi radio power state (on/off). Docs say this:

When the device is in an operational mode other than client STA this function fails, errno is set to EBUSY, and the wifi power remains unchanged. Additional restrictions apply to power off requests if, for example, Wi-Fi is the default route for one of the perimeters, or if an application is explicitly bound to the Wi-Fi interface. In such cases the power off request fails and errno is set to EBUSY.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: wifi_service.h and wifi_set_sta_power()?

oddboy, wifi_get_status() works you say, but what value does it return?

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: wifi_service.h and wifi_set_sta_power()?

Peter, the function returns 0, as in success.

The variable passed to the function comes back as WIFI_STATUS_RADIO_OFF (0) if the radio is off, and WIFI_STATUS_RADIO_ON (1) if the radio is on as expected. It never comes back with WIFI_STATUS_BUSY (2) - radio busy - which is what the documentation says will return if the wifi service is in a state that does not allow it to be shut off.

So wifi_get_status seems to work fine, and rather than EBUSY, I get Permission Denied.

I'm either missing something, or this function wifi_set_sta_power() is not implemented yet.
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: wifi_service.h and wifi_set_sta_power()?

There may be an undocumented permission that's required in the bar-descriptor.xml file for this to work. I seem to recall that Android apps can actually control this, so perhaps they intend to expose it, but just haven't finished up the docs and/or implementation.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: wifi_service.h and wifi_set_sta_power()?

yeah, it must not be fully implemented.  i've tried enabling every visible permission in the bar file and still no luck.

 

it would be nice if the API's for controlling devices were more alike.  the Bluetooth API is pretty straight forward.  the wifi ones is a little more complicated.  i.e.with the BT device you register a callback and watch for events of interest.  with the wifi one, you just call the function and hope it works.

 

ah well, hopefully it gets implemented sooner or later.

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Administrator
MSohm
Posts: 14,309
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: wifi_service.h and wifi_set_sta_power()?

For reference, this is logged in Issue Tracker here:

 

BBTEN-538 calls to wifi_set_sta_power() fail with Permission Denied

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.