Bluetooth modem



  • I have read most of the QBluetooth samples. Unfortunately they are way more then I need. I just need a simple component that will let my application have a conservation with a Teensy processor with a bluetooth slave connected.

    I looked at QIODevice but can't see how to connect it to the specific device.

    Is there a simple bluetooth device that doesn't require a bluetooth socket type device on the other end?



  • I figured out how to loop through the serial ports but I don't know how to tell if it is the bluetooth device. I turned off bluetooth and this echnique seems to report the same values.

    @
    QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
    for(int i = 0; i < ports.size(); i++){
    QSerialPortInfo pInfo = ports.at(i);
    qDebug() << pInfo.portName();
    QSerialPort *thePort = new QSerialPort(pInfo);
    qDebug() << QString::number(thePort->baudRate());
    }
    @
    and the result is
    @
    "ttyS0"
    "9600"
    @

    Is there a better way to do this?
    How can I tell if it is the bluetooth device?



    1. The QSerialPortInfo can show only the bluetooth /dev/rfcomm devices only after pairing between PC and device. I.e. when /dev/rfcomm will be created by udev (by OS).

    2. Also you can use the "QtConnectivity":https://qt.gitorious.org/qt/qtconnectivity/source/de6e3732ab6884e8f650cbbf99380800dd305636: module to talk with BT directly.



  • kuzulis: I think I am using the new QT-project versions of these classes. "QtConnectivity":http://doc-snapshot.qt-project.org/qt-mobility/qtconnectivity.html If they are not the same then I will look at the ones you reference.

    What I have so far is an unknown socket error. That makes it hard to know what to try next.

    My process is to scan for devices. If I find the one I want I pair with it. All this code is from the BTScanner example project. Once I have paired with it, I attempt to create a QBluetoothSocket.

    @
    socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this);
    socket->connectToService(QBluetoothAddress(theDevice.address()),
    QBluetoothUuid(QBluetoothUuid::SerialPort));
    connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)),
    this, SLOT(slSocketError(QBluetoothSocket::SocketError)));
    connect(socket, SIGNAL(connected()), this, SLOT(slSocketConnected()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(slSocketDisconnected()));
    connect(socket, SIGNAL(readyRead()), this, SLOT(slSocketRead()));
    connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(slSocketStateChanged(QBluetoothSocket::SocketState)));
    @
    The slot methods simply use qDebug to show the socket creation process. The result is:
    @
    State: Connecting
    Socket error: QBluetoothSocket::UnknownSocketError
    qt.bluetooth.bluez: void QBluetoothSocketPrivate::_q_readNotify() 20 error: -1 "Resource temporarily unavailable"
    Socket error: QBluetoothSocket::UnknownSocketError
    State:Closing
    State: Unconnected
    Socket Disconnected
    @

    When a socket to a bluetooth is attempting to connect, does the bluetooth device have to respond in some specific way?



  • SO, I hooked up a Sparkfun blueSmirf bluetooth device I had laying around and the code supplied above works correctly. The problem is, I don't need the capabilities of that device. The modem I want to use is a slave only device, HC-06. I am building a set of remote devices and can't spend the money on expensive bluetooth modems.

    Is there anything I can do to make the HC-O6 connect with the QtSocket.connectToService?



  • I went out and bought an HC-05 bluetooth modem and I configured it to run faster, but still it doesn't work. So,

    The linux I am using had the bluez has like a 4.1.xxx version and the current release is 5.2.1 . I thought maybe I should try to upgrade to the latest bluez version. After 3 hours and who knows how many libraries I had to build and install my OS will no longer boot. I have to at least rescue my qt projects from the machine.

    I am willing to try any option that has a later version of the bluez library to see if it will work with these modems. Has anyone successfully used these devices in a Qt application?



  • Hello aodh, have you ever solved your problem in a way? I am dealing with the same problem. QBluetoothSocket.connectToService returns UnknownError or ServiceUnavailable ( HC-06 does not provide any services as it is slave device ).
    HC-06 does not provide any own UUID, and on Android devices dealing with such issue is done by hardcoding UUID to typical SPP UUID: 00001101-0000-1000-8000-00805F9B34FB. It is enough to call sth like 'createSocketForRFCOMM(UUID)' and then open() and it works. On Qt Bluetooth side it does not.
    Any ideas how to solve this problem? It is very popular to use such cheap dongles as wireless UART module, and if QBluetooth does not support such connection type then i would be surprised.



  • Thanks for your reply.

    I have never solved this problem. I think that qtBluetoothSocket does not support thse devices. I went to a different straegy where I only needed onr Bluetooth modem and used it as a relay to a network of nRF24L01+ radio devices. I had a Sparkfun BlueSmirf modem laying around and just used it. And the nRF24 devices have longer range and cost under 2 on ebay. Was way cheaper and more interesting since I got to use some new technology.


Log in to reply
 

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