Problem with QBluetooth library ( Symbian Belle - Nokia 500)
-
Hello
I have a problem with QBluetooth library. My code is based on simple example from this "side":http://qt-project.org/doc/qt-5.0/qtbluetooth-overview.html
@ QBluetoothLocalDevice LocalDevice;
QString LocalDeviceName;if(LocalDevice.isValid()){ LocalDevice.powerOn(); LocalDeviceName=LocalDevice.name(); LocalDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable); } QBluetoothDeviceDiscoveryAgent *DiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(DiscoveryAgent,SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),this,SLOT(deviceDiscovered(const QBluetoothDeviceInfo&))); DiscoveryAgent->start();@
When I use start() method of that class with Bluetooth powered off, the debug console prints this:
bq. [Qt Message] void QtMobility::BluetoothLinkManagerDeviceDiscoverer::setError(int) errorCode= -44
Wątek zakończony błędem: Thread 0x587 has panicked. Category: KERN-EXEC; Reason: 0
Wątek zakończony błędem: Thread 0x588 has panicked. Category: KERN-EXEC; Reason: 0
Proces zakończył się.If manually turn on Bluetooth, compiler display this error:
bq. [Qt Message] void QtMobility::BluetoothLinkManagerDeviceDiscoverer::setError(int) errorCode= -46
Wątek zakończony błędem: Thread 0x552 has panicked. Category: KERN-EXEC; Reason: 0
Wątek zakończony błędem: Thread 0x553 has panicked. Category: KERN-EXEC; Reason: 0
Proces zakończył się.Does anyone know what is wrong? Thanks for your help
-
The first error (-44) indicates that the hardware is not available, it is off. The second error (-46) indicates that you do not have the necessary permissions. You will need to add LocalServices to the TARGET.CAPABILITY variable in your .pro file. As an example the Qt Bluetooth examples declare the following capabilities:
@
symbian {
TARGET.CAPABILITY = LocalServices UserEnvironment ReadUserData WriteUserData NetworkServices NetworkControl ReadDeviceData WriteDeviceData SwEvent
}@ -
Thank You :) now works, but appeared next problem :/ I am trying to establish connection between Phone and BTM222 Module ( BTM222 is it a simple bluetooth adapter with serial port interface ). DeviceDiscoveryAgent had found BTM222
@ QBluetoothDeviceDiscoveryAgent *DiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
connect(DiscoveryAgent,SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),this,SLOT(deviceDiscovered(const QBluetoothDeviceInfo&)));DiscoveryAgent->start();@
bq. [Qt Message] Found new device "SERIAL ADAPTOR" ( "00:12:6F:23:8B:C2" )
but ServiceDiscoveryAgent hadn't found any services. When I turn on Bluetooth in other phone ( Nokia N900 ) ServiceDiscoveryAgent found services. How can I connect to the BTM222 ( or other device) when I do not know his service