Bluetooth - Service not discovered..
-
Hi,
I'm trying to connect to Bluetooth server running on my laptop with Qt_Bluetooth client on phone.But my issue is, though the service published by server running on laptop, it is not discovered by " Qt_Bluetooth client on phone "
And if I try to connect to server using the bluetooth address and port number, it works, I can establish the connection.
can you tell me why I'm not getting service discovered signal. Am I missing anything.Here is the code.
@
//-----------------------------------------------------------------------------------------------------------------------------
#include "Bluetooth_Client.h"Bluetooth_Client::Bluetooth_Client(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
qDebug() << "Create socket";DeviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(DeviceDiscoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(deviceDiscovered(const QBluetoothDeviceInfo&))); connect(ui.pushButton, SIGNAL(clicked()),this,SLOT(ButtonClicked())); connect(socket,SIGNAL(connected()),this,SLOT(ConnectedToServer())); DeviceDiscoveryAgent->start();
}
void Bluetooth_Client::deviceDiscovered(const QBluetoothDeviceInfo& ServiceInfo)
{qDebug() << "~Device discovered"; ui.textEdit->append(ServiceInfo.address().toString()); ui.textEdit->append("\nConnecting to Server....\n"); ServiceDiscoveryAgent = new QBluetoothServiceDiscoveryAgent(this); connect(ServiceDiscoveryAgent,SIGNAL(serviceDiscovered(const QBluetoothServiceInfo &info)),this,SLOT(ServiceDiscovered(const QBluetoothServiceInfo &info))); ServiceDiscoveryAgent->start(); //socket->connectToService(QBluetoothAddress("XX:XX:XX:XX:XX:XX"),1); // Connecting via bluetooth address works.
}
void Bluetooth_Client::ButtonClicked()--
{
qDebug() << "Button CLicked";}
void Bluetooth_Client::ServiceDiscovered(const QBluetoothServiceInfo &info)
{
ui.textEdit->append("Service Discovered...");qDebug() << info.serviceName(); qDebug() << info.device().name(); qDebug() << info.serviceUuid().toString(); qDebug() << info.serviceProvider(); socket->connectToService(info); //QBluetoothAddress address(QString("70:F3:95:34:26:14")); //socket->connectToService(address,0);
}
void Bluetooth_Client::ConnectedToServer()
{
ui.textEdit->append("Connected to server...\n");
ui.textEdit->append(socket->peerName()+"\n");ui.textEdit->append(QString::number(socket->write(QString("Hello Der.. Welcome 1").toUtf8())));
--
}Bluetooth_Client::~Bluetooth_Client()
{}
//---------------------------------------------------------------------------------------------------------------------------
@
Thanks in advance,Regards,
Vijay.Edit: please use @ tags around code sections; Andre
-
Some information on the kind of device you are using might be helpful.
-
Thanks for the reply,
I'm using the latest symbian bell, nokia 701 -
Hi Tobias,
Any updates on this issue.Regards,
Vijay. -
Not from my side: I have never done any serious programming on Symbian.
Maybe the guys over at developer.nokia.com (the experts on the actual devices) might know more here, but unfortunately their site is currently down.
-
I am having the same isuue on N950. If you try to use a service discovery agent and set a uuid on it to filter the service discovery only to the service you are trying to connect it will not find any service. If you set up the service discovery agent with your laptop's bluetooth address and no service uuid filter it will correctly (finally!!!) find all the bluetooth services currently running on the laptop. If in the slot you try to qDebug() print each of the discovered service uuid it will be 0000000 etc. So this is clearly a BUG !!!! The workaround is to use the service info name or description to compare it with a string that you know matches your desired bt service name/description and use it to connect.