Bluetooth rfcomm server channel problem
Hi,
I´m new on QT and Symbian.
I have to set up a rfcomm server to make my phone avaiable to other bluetooth devices (in this case, a pinpad).
I have already turned on the bluetooth, acquired a sign developer and all QTMobility options are working fine.
But when I try to connect the pinpad, it just don´t work.
I´m using this UUID: "00001101-0000-1000-8000-00805f9b34fb".
I don´t know which channel i have to use. The method (rfcommserver->serverPort()) returns 4. That´s ok?
I´m missing something? Someone can help me?
here is my code:
[CODE]void bluetooth::startServer()
{
QString deviceName;
QBluetoothLocalDevice localDevice;
if (rfcommServer)
return;
localDevice.powerOn();
localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
deviceName = localDevice.name();
rfcommServer = new QRfcommServer(this);
connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(vConectou()));
if( rfcommServer->listen() )
{
emit vShowMsg("Listening");
}
else
{
emit vShowMsg("Error");
return;
}
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
QBluetoothServiceInfo::Sequence classId;
classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Serial Port"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription, tr("COM Port"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, deviceName );
serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
protocolDescriptorList.append(QVariant::fromValue(protocol));
protocol.clear();
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
<< QVariant::fromValue(rfcommServer->serverPort());
protocolDescriptorList.append(QVariant::fromValue(protocol));
serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
if( serviceInfo.registerService() )
{
emit vShowMsg("Waiting for connections...");
}
else
{
emit vShowMsg("Error to create the service");
}
}[/CODE]
Re: Bluetooth rfcomm server channel problem
Hi
I think you try to run some modification of btchat project (C:\QtSDK\Examples\QtMobility\btchat\chatserver.cpp line 60 , void ChatServer::startServer())
btchat is not broken , so i think you have to go through the code difference to hunt the introduced bugs.
but nothing wrong in taking the example core and extend it (without modifications) with your functionality.
Regards,
Igor
Re: Bluetooth rfcomm server channel problem
Hi
Yeah, you are correct.
Its a little modification of btchat project.
Actually, I´m just trying to create a SPP server to connect another device to my phone.
I´m doing exactly the example does, but it still not working.
Today i´m making some tests and discovered (or i think i do) that the service class was not been registered (command below)..
[CODE]QBluetoothServiceInfo::Sequence classId;
classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);[/CODE]
When i try to read the list classId, (QList<QBluetoothUuid>), it´s empty.
It could be a problem from my phone (nokia 500)?
Incompatibility between symbian and qt version?
thx for any help!
Re: Bluetooth rfcomm server channel problem
Hi
I don't think there is any problem or compatibility issue with your devices.
I suggest your to start over from the example.
[LIST][*] verify it is working for you[*] modify the code for your needs. I strongly recommend you to use a version control --- [URL="http://subversion.apache.org/packages.html"]subversion for example[/URL] -- that will speedup your development because you will be able to analyze each and every your step in the code modification.[/LIST]
I've done external GPS device supporting via bt looong time ago , so i am sorry i cannot provide you any details on bt discovery procedure -- follow the example if your target is making software but not academical pursuit :)