Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Bluetooth - Service not discovered..
QtWS25 Last Chance

Bluetooth - Service not discovered..

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 3 Posters 4.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.
  • V Offline
    V Offline
    vijaydandur
    wrote on last edited by
    #1

    Hi,
    I'm trying to connect to Bluetooth server running on my laptop with Qt_Bluetooth client on phone.

    But my issue is, though the service published by server running on laptop, it is not discovered by " Qt_Bluetooth client on phone "

    And if I try to connect to server using the bluetooth address and port number, it works, I can establish the connection.
    can you tell me why I'm not getting service discovered signal. Am I missing anything.

    Here is the code.
    @
    //-----------------------------------------------------------------------------------------------------------------------------
    #include "Bluetooth_Client.h"

    Bluetooth_Client::Bluetooth_Client(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);
    socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
    qDebug() << "Create socket";

    DeviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
    
    connect(DeviceDiscoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),
            this, SLOT(deviceDiscovered(const QBluetoothDeviceInfo&)));
    connect(ui.pushButton, SIGNAL(clicked()),this,SLOT(ButtonClicked()));
    connect(socket,SIGNAL(connected()),this,SLOT(ConnectedToServer()));
    
     DeviceDiscoveryAgent->start();
    

    }

    void Bluetooth_Client::deviceDiscovered(const QBluetoothDeviceInfo& ServiceInfo)
    {

    qDebug() << "~Device discovered";
    ui.textEdit->append(ServiceInfo.address().toString());
    ui.textEdit->append("\nConnecting to Server....\n");
    
    ServiceDiscoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
    connect(ServiceDiscoveryAgent,SIGNAL(serviceDiscovered(const QBluetoothServiceInfo &info)),this,SLOT(ServiceDiscovered(const QBluetoothServiceInfo &info)));
    
    ServiceDiscoveryAgent->start();
    
    //socket->connectToService(QBluetoothAddress("XX:XX:XX:XX:XX:XX"),1); // Connecting via bluetooth address works.
    

    }

    void Bluetooth_Client::ButtonClicked()--
    {
    qDebug() << "Button CLicked";

    }

    void Bluetooth_Client::ServiceDiscovered(const QBluetoothServiceInfo &info)
    {
    ui.textEdit->append("Service Discovered...");

    qDebug() << info.serviceName();
    qDebug() << info.device().name();
    qDebug() << info.serviceUuid().toString();
    qDebug() << info.serviceProvider();
    
    
    
    socket->connectToService(info);
    //QBluetoothAddress address(QString("70:F3:95:34:26:14"));
    //socket->connectToService(address,0);
    

    }
    void Bluetooth_Client::ConnectedToServer()
    {
    ui.textEdit->append("Connected to server...\n");
    ui.textEdit->append(socket->peerName()+"\n");

    ui.textEdit->append(QString::number(socket->write(QString("Hello Der.. Welcome 1").toUtf8())));
    

    --
    }

    Bluetooth_Client::~Bluetooth_Client()
    {

    }
    //---------------------------------------------------------------------------------------------------------------------------
    @
    Thanks in advance,

    Regards,
    Vijay.

    Edit: please use @ tags around code sections; Andre

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Some information on the kind of device you are using might be helpful.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vijaydandur
        wrote on last edited by
        #3

        Thanks for the reply,
        I'm using the latest symbian bell, nokia 701

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vijaydandur
          wrote on last edited by
          #4

          Hi Tobias,
          Any updates on this issue.

          Regards,
          Vijay.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            Not from my side: I have never done any serious programming on Symbian.

            Maybe the guys over at developer.nokia.com (the experts on the actual devices) might know more here, but unfortunately their site is currently down.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deion
              wrote on last edited by
              #6

              I am having the same isuue on N950. If you try to use a service discovery agent and set a uuid on it to filter the service discovery only to the service you are trying to connect it will not find any service. If you set up the service discovery agent with your laptop's bluetooth address and no service uuid filter it will correctly (finally!!!) find all the bluetooth services currently running on the laptop. If in the slot you try to qDebug() print each of the discovered service uuid it will be 0000000 etc. So this is clearly a BUG !!!! The workaround is to use the service info name or description to compare it with a string that you know matches your desired bt service name/description and use it to connect.

              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