×

Discussion Board

Results 1 to 4 of 4

Hybrid View

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    11

    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");
       }
    }

  2. #2
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    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

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    11

    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);
    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!

  4. #4
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    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.
    • verify it is working for you
    • modify the code for your needs. I strongly recommend you to use a version control --- subversion for example -- that will speedup your development because you will be able to analyze each and every your step in the code modification.


    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

Similar Threads

  1. Replies: 3
    Last Post: 2009-10-30, 15:15
  2. Bluetooth / Change the RFCOMM server channel number
    By olepogam in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-07-31, 11:17
  3. How many RFCOMM connections to the same channel is allowed in JSR-82?
    By art_1979 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2008-04-07, 21:49
  4. Get RFCOMM Channel
    By ced1 in forum Bluetooth Technology
    Replies: 7
    Last Post: 2004-04-30, 13:07
  5. RFCOMM Channel Request
    By dphj in forum Bluetooth Technology
    Replies: 1
    Last Post: 2004-03-17, 10:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×