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
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Problems in using function "wifi_set_sta_power" which is from wifi_service.h

Hi,

    I am learning about how to turn on/off wifi in my app. I have found the API about wifi_service.h and use the function from it like this:

 

// Default empty project template
#include "Tttt.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <wifi/wifi_service.h>
#include <stdbool.h>

using namespace bb::cascades;

Tttt::Tttt(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    app->setScene(root);
}

int Tttt::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");

        }
        return result;
}

  But it have some problems in error:

src/Tttt.cpp:30: undefined reference to `wifi_set_sta_power'

  Could you tell me how to deal with it?

 

cheers,

 

Please use plain text.
Developer
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

Hello,

 

Did you find a solution? If so please provide it. 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.
Developer
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

Found a ticket in Jira. This functionality is not available yet. 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.
Developer
simon_hain
Posts: 15,870
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

if you check the capabilities
http://developer.blackberry.com/cascades/reference/qnetworkconfigurationmanager.html#capabilities
CanStartAndStopInterfaces is not set.

i would also love to have an application like autowifi on my old BB that enables/disables wifi based on your location and save battery.
would write it myself, but alas the functionality is not there.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
sanshah90
Posts: 36
Registered: ‎06-28-2012
My Device: BB10
My Carrier: RIM

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

Hi,

 

I am also getting same kind of error.

Did anyone find solution? If so, provide it.

 

Because in this post they successfully compiled the code.

 

What should be the problem... Does it related to the sdk version?? I am using 10.0.10.261 version...

 

Thanks

 

 

Please use plain text.
Developer
simon_hain
Posts: 15,870
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

maybe you should re-read the thread you have linked...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
sanshah90
Posts: 36
Registered: ‎06-28-2012
My Device: BB10
My Carrier: RIM

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

Hi,

 

I am not getting.

 

Can you please provide some sample code so that i can successfully compile it and make it work..

 

Thanks

Please use plain text.
Developer
BB_shi
Posts: 89
Registered: ‎03-15-2011
My Device: Blackberry 9800
My Carrier: developer

Re: Problems in using function "wifi_set_sta_power" which is from wifi_service.h

Hi wzl0515,

 

please let me know if you have resolved the issue. i have requirement to on/off wi-fi programmatically so using the api wifi_set_sta_power but getting error on console: undefined reference to `wifi_set_sta_power' at compilation time.

Please use plain text.