Qt and Bluetooth



  • So, I created server by this tutorial - http://doc.qt.io/qt-5/qtbluetooth-btchat-example.html.

    When, I'm trying to connect to my mac with BLE iPhone application I only see unknown service with system information about mac.

    System: Ubuntu 15.04
    Console output:

    Starting bluetooth server!
    "28:CF:E9:1F:2C:D8"
    Bluetooth server started!
    

    I also tried to launch this application on Mac OS X with Qt 5.5. Same result.

    Code:

    QBluetoothLocalDevice localDevice;
    QBluetoothAddress adapterAddress = localDevice.address();
    
    qWarning() << "Starting bluetooth server!";
    qWarning() << adapterAddress;
    
    rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
    connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
    bool result = rfcommServer->listen(adapterAddress);
    if (!result) {
        qWarning() << "Cannot bind chat server to " << adapterAddress.toString();
        return;
    }
    
    qWarning() << "Bluetooth server started!";
    
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Bt Chat Server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
                             tr("Example bluetooth chat server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("qt-project.org"));
    
    static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
    serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
    
    QBluetoothServiceInfo::Sequence publicBrowse;
    publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
    serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse);
    
    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);
    
    serviceInfo.registerService(adapterAddress);


  • I think that there is no bluetooth support for the Mac OS (as far as I understood, you are running Qt on Mac OS).


  • Lifetime Qt Champion

    @nedo99 There is starting with Qt 5.5, see the new feature list


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.