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 Wi-Fi Service Library

I am learning to use wifi_service.h to turn on or off wifi in my app., but it still some problems. The code is like:

// 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);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    setWifiStatus();
    // set created root object as a scene
    app->setScene(root);
}

int Tttt::setWifiStatus() {
	int result;
	int result1;
	bool status=1;
	wifi_status_t *st;

	if (result != WIFI_SUCCESS) {
		// function call to wifi_set_sta_power failed

		result1=wifi_get_status(st);
		qDebug() << "The result1 is " << result1 ;
		result = wifi_set_sta_power(status);
		qDebug() << "The result is " << result ;

        }
        return result;
}

 The console tell me after the run the app :

The result1 is -1
The result is -1

 

In the Wi-Fi Service Library, I check the typedef enum:

 

WIFI_STATUS_RADIO_OFF = 0,

WIFI_STATUS_RADIO_ON = 1,

WIFI_STATUS_BUSY = 2,

 

so I don't know what meaning about -1...

is there anyone can help me?

 

yours,leon.

 

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: Problems in using Wi-Fi Service Library

seems its not implemented. if you  check errno, you'll probaby see "Permission Denied", or on simulator, "not implemented"

 

 

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Contributor
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Re: Problems in using Wi-Fi Service Library

So is there some ways to fix it and how can I control wifi in my application?
Thank you a lot.
Please use plain text.
Developer
Pumano-
Posts: 215
Registered: ‎11-05-2011
My Device: Z10
My Carrier: Beeline

Re: Problems in using Wi-Fi Service Library

maybe allow permissions into bar-descriptor.xml?

Please use plain text.
Contributor
sanshah90
Posts: 36
Registered: ‎06-28-2012
My Device: BB10
My Carrier: RIM

Re: Problems in using Wi-Fi Service Library

Hi,

 

When i trie to use wifi_service.h and compile it, I am getting undefined reference to `wifi_set_sta_power' error.

I am not able to compile it. 

 

So what should be the problem?? 

 

 

Thanks.

Please use plain text.
New Member
pkool
Posts: 1
Registered: ‎05-07-2013
My Device: Blackberry 10
My Carrier: Fido

Re: Problems in using Wi-Fi Service Library

I am receiving this exact same issue.  Any news on how to fix this?

Please use plain text.
Developer
congdanhqx
Posts: 115
Registered: ‎10-22-2012
My Device: Developer
My Carrier: Mobifone

Re: Problems in using Wi-Fi Service Library

What's problem which you get?
If you get undefined reference to `wifi_set_sta_power'
come to your pro file. Add this line

LIBS += -lwifi

 



Like my answer if it's helpful. Mark as answer if it help you solve the problem.
Please use plain text.
Developer
RikScheffer
Posts: 25
Registered: ‎07-21-2013
My Device: BB Z10 LE, BB DAC, BB PlayBook
My Carrier: Vodafone NL

Re: Problems in using Wi-Fi Service Library

also you shouldn't forget to initialize the wifi service:
with wifi_service_initialize() 

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

---
http://www.heris.nl OR Check out my apps in appworld:
http://appworld.blackberry.com/webstore/vendor/22561/
Please use plain text.