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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Contributor
wzl0515
Posts: 25
Registered: ‎08-14-2012
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: 127
Registered: ‎08-24-2011
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!
----------------------------
BlackBerry 10 Developer is looking for a job!
My Apps: Alchemy Game | Jam! | Traffic Signs: USA
My Blog: http://bb10pro.com
Please use plain text.
Developer
Developer
klz
Posts: 127
Registered: ‎08-24-2011
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!
----------------------------
BlackBerry 10 Developer is looking for a job!
My Apps: Alchemy Game | Jam! | Traffic Signs: USA
My Blog: http://bb10pro.com
Please use plain text.
Developer
simon_hain
Posts: 13,791
Registered: ‎07-29-2008
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: 27
Registered: ‎06-28-2012
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: 13,791
Registered: ‎07-29-2008
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: 27
Registered: ‎06-28-2012
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.