title: Create a RFCOMM Server using Qt for symbian
body: <p>I´m new on Qt, Symbian devices and Bluetooth.</p>
  
  <p>I have to set up a RFCOMM server to receive connection from a bluetooth device (its a pinpad) that only support SPP profile. </p>
  
  <p>I searched on google and found some examples, like this: <a href="http://doc.qt.nokia.com/qtmobility/btchat.html" rel="nofollow">http://doc.qt.nokia.com/qtmobility/btchat.html</a></p>
  
  <p>Tried everything but I can´t connect them. Both devices was paired, but when I try to connect it fails.</p>
  
  <p>When I asked to the manufacturer, they said that it was happening because the SPP Server on my celphone was not avaiable to listen for incoming connections. </p>
  
  <p>I´m creating the RFCOMM server and registering the service just like the example, but it still not working. </p>
  
  <p>Someone can help me? </p>
  
  <p>I'm using Qt with QtMobility 1.2.0 and my cellphone is a Nokia 500 (Symbian^3).</p>
  
  <p>Here is my code:</p>
  
  <pre><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-&gt;listen(localDevice.address(), 
                               quint16(rfcommServer-&gt;serverPort()) ) )
        emit vExibeMsg("Listening"); 
     else
        emit vExibeMsg("Error"); 
  
     serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, 
                               (uint)0x00010010);
  
     QBluetoothServiceInfo::Sequence classId;
  
     classId &lt;&lt; QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
  
     serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
  
     serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Test Server"));
     serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription, 
                               tr("Test Bluetooth"));
     serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, deviceName );
  
     serviceInfo.setServiceUuid(QBluetoothUuid(QBluetoothUuid::Rfcomm));
  
     serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, 
                               QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));       
  
     QBluetoothServiceInfo::Sequence protocolDescriptorList;
     QBluetoothServiceInfo::Sequence protocol;
  
    /* 
     protocol &lt;&lt; QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
     protocolDescriptorList.append(QVariant::fromValue(protocol));
  
     protocol.clear();
  
     protocol &lt;&lt; QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
              &lt;&lt; QVariant::fromValue(quint8(rfcommServer-&gt;serverPort()));
  
     protocolDescriptorList.append(QVariant::fromValue(protocol));
  
     protocol.clear();
  
     protocol &lt;&lt; QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
  
     protocolDescriptorList.append(QVariant::fromValue(protocol));
    */ 
  
     protocol &lt;&lt; QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
              &lt;&lt; QVariant::fromValue(quint8(rfcommServer-&gt;serverPort()));
  
     protocolDescriptorList.append(QVariant::fromValue(protocol));
  
     serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, 
                                protocolDescriptorList);
  
     if( serviceInfo.registerService() )
     {
        emit vExibeMsg("Waiting for connections...");
     }
     else
     {
        emit vExibeMsg("Error to create the service");
     }
  }
  </code></pre>