Hello,
The device that we are developing consists of BT modules acting as a client and transmitting data (SPP profile) to a BT server that mirror this data through a virtual COM port to a PC. In order to autoconnect the client to the server and knowing the port number to connect with, I need to implement an SDP connection. I already implemented it on client side and it correcly works. I tested it with a Qt/Android application acting as a server. Now i need to implement the SDP connection server side. Following i posto the C++/Qt code initializing the SDP services. How can i translate it in MSP430 code? Can someone post some code?
I'm using CC2564B+MSP430F5438A and Bluetopia stack.
Qt Code that starts the server and initializes SDP:
void btServer::startServer(const QBluetoothAddress& localAdapter)
{
if (rfcommServer)
return;
//! [Create the server]
rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
bool result = rfcommServer->listen(localAdapter);
qDebug("server is listening to port:%d",rfcommServer->serverPort());
qDebug("server created");
//! [Create the server]
//serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
//! [Class Uuuid must contain at least 1 entry]
QBluetoothServiceInfo::Sequence classId;
classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,classId);
classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid)));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,classId);
//! [Class Uuuid must contain at least 1 entry]
//! [Service name, description and provider]
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Nemesi Server"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,tr("Nemesi SDP"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("LISiN - Politecnic of Turin"));
//! [Service name, description and provider]
//! [Service UUID set]
serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
//! [Service UUID set]
//! [Service Discoverability]
QBluetoothServiceInfo::Sequence publicBrowse;
publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,publicBrowse);
//! [Service Discoverability]
//! [Protocol descriptor list]
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(quint8(rfcommServer->serverPort()));
protocolDescriptorList.append(QVariant::fromValue(protocol));
serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,protocolDescriptorList);
//! [Protocol descriptor list]
//! [Register service]
serviceInfo.registerService(localAdapter);
// serviceInfo.registerService();
//! [Register service]
}
Thanks in advance,
GLC
