Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Bluetooth ERROR W libQmlBLE_armeabi-v7a.so: qt.bluetooth.android: Connecting to port is not supported



  • Hi all,

    So I am trying to connect my phone Android with ESP32 arduino ,using this code below, bu I am getting error :W libQmlBLE_armeabi-v7a.so: qt.bluetooth.android: Connecting to port is not supported

    #include "bluetooth.h"
    
    #include <QDebug>
    
    Bluetooth::Bluetooth(QObject *parent) : QObject(parent)
    {
        connect(this,SIGNAL(pairedSignal(QBluetoothAddress)),this,SLOT(connectDevice(QBluetoothAddress)));
    
    
    }
    
    QBluetoothAddress Bluetooth::getMyAdress()
    {
        return deviceLocal->address();
        qDebug()<< "My adress is" << deviceLocal->address();
                
    }
    
    void Bluetooth::setOnBluetooth()
    {
        deviceLocal->powerOn();
        deviceLocal->setHostMode(QBluetoothLocalDevice::HostDiscoverable);
        qDebug()<< deviceLocal->name()<<"Blutooth is ON" ;
    
        qDebug()<<"I am in Mode" <<deviceLocal->hostMode();
        
    }
    
    void Bluetooth::discoveredDevices()
    {
        QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
    
        connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
                    this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
    
    
            discoveryAgent->start();
            qDebug()<< "Starting searchin";
    
    }
    
    void Bluetooth::connectDevicer(const QBluetoothAddress &address)
    {
        //QBluetoothSocket *connectToDevice= new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
        deviceLocal->requestPairing(address, QBluetoothLocalDevice::Paired);
        qDebug()<<"ConnectingDevice"<< connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));;
        connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
        connect(socket, SIGNAL(readyRead()), this, SLOT(dataReady2Read()));
        qDebug()<< "Socket connection";
        socket->connectToService(addressPaired, QIODevice::ReadWrite);
        socket->open(QIODevice::ReadWrite);
        qDebug()<< "Socket connection"<< socket->isOpen();
    
    
    
    }
    
    void Bluetooth::socketConnected()
    {
        qDebug()<< "SocketConnected";
        QString Connection= "I am connected to:"+socket->peerAddress().toString()+":"+socket->peerPort();
    
        socket->write("OFF\n");
    }
    
    void Bluetooth::dataReady2Read()
    {
            QByteArray data;
            data = socket->readAll();
            qDebug()<< data;
    }
    
    
    void Bluetooth::onLed()
    {
    
    
        if (!socket->isOpen() || !socket->isWritable())return;
    
    
         socket->write("ON\n");
    
    
    
    }
    
    void Bluetooth::offLed()
    {
        if (!socket->isOpen() || !socket->isWritable())return;
    
    
         socket->write("OFF\n");
    
    }
    
    void Bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device)
    {
        qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')';
        addressPaired=device.address();
        connectDevicer(device.address());
    
    }
    
    

Log in to reply