Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to connect to bluetooth device
Forum Updated to NodeBB v4.3 + New Features

Unable to connect to bluetooth device

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RohitIti
    wrote on last edited by RohitIti
    #1

    Hello,

    I am using btscanner qt example to connect to other bluetooth device to transfer data.
    Currently the example contains only displaying of bluetooth device and upon selecting the device we will get all the services provided by the remote device.
    I added my code to create an rfcomm connection inside addService function of service.cpp

    Code is as follows:

    socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
    qDebug() << serviceInfo.serviceUuid();
    if(socket != NULL)
    {
    qDebug() << "Create socket" << serviceInfo.device().address().toString();
    socket->connectToService(serviceInfo.device().address(), QBluetoothUuid(QBluetoothUuid::ObexObjectPush));
    qDebug() << "ConnectToService done";

       connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
    

    connect(socket, SIGNAL(connected()), this, SLOT(connected()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
    with this code i am getting proper selected bluetooth device name but the serviceUUid is all zeros.

    and also i get the error saying qt.bluetooth.android: device is offline.

    later i change serviceDiscoveryAgent.start() function to serviceDiscoveryAgent.start(QBluetoothServiceDiiscoveryAgent::DiscoveryMode::FullDiscovery)

    this time i get the same result but the error is " qt.bluetooth.android: unknown host state "

    I am running the code in qt 5.5.
    I am flashing the apk on nexus 7 tablet and samsung mobile. am getting same result.
    I am assuming that i am missing to add certain code but unable to find

    Any solutions ?
    Thank you.

    R 1 Reply Last reply
    0
    • R RohitIti

      Hello,

      I am using btscanner qt example to connect to other bluetooth device to transfer data.
      Currently the example contains only displaying of bluetooth device and upon selecting the device we will get all the services provided by the remote device.
      I added my code to create an rfcomm connection inside addService function of service.cpp

      Code is as follows:

      socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
      qDebug() << serviceInfo.serviceUuid();
      if(socket != NULL)
      {
      qDebug() << "Create socket" << serviceInfo.device().address().toString();
      socket->connectToService(serviceInfo.device().address(), QBluetoothUuid(QBluetoothUuid::ObexObjectPush));
      qDebug() << "ConnectToService done";

         connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
      

      connect(socket, SIGNAL(connected()), this, SLOT(connected()));
      connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
      with this code i am getting proper selected bluetooth device name but the serviceUUid is all zeros.

      and also i get the error saying qt.bluetooth.android: device is offline.

      later i change serviceDiscoveryAgent.start() function to serviceDiscoveryAgent.start(QBluetoothServiceDiiscoveryAgent::DiscoveryMode::FullDiscovery)

      this time i get the same result but the error is " qt.bluetooth.android: unknown host state "

      I am running the code in qt 5.5.
      I am flashing the apk on nexus 7 tablet and samsung mobile. am getting same result.
      I am assuming that i am missing to add certain code but unable to find

      Any solutions ?
      Thank you.

      R Offline
      R Offline
      RohitIti
      wrote on last edited by
      #2

      @RohitIti Can some one provide me qt Bluetooth code which works

      1. search for deceives
      2. pair and connect to selected device using OPP protocol
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved