Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Stopping Bluetooth Service discovery crashes the App

    Mobile and Embedded
    1
    1
    521
    Loading More Posts
    • 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.
    • G
      GoodMorninSunshine last edited by

      Hi All,

      Im trying to do a bluetooth service discovery in an android phone using the Bluetooth Service Discovery Agent. My problem is that if I stop the bluetooth scan mid-way, my app crashes. Does anyone have any idea why? Or how to stop an ongoing bluetooth service discovery?

      Some of my code is as below:
      @

      void BtScan:: localDeviceInfo()
      {
      QBluetoothLocalDevice localBluetoothDevice;
      QString localBluetoothDeviceName;

      void BtScan::startDiscovery() {
      if(localBluetoothDevice.isValid())
      {
      localBluetoothDevice.setHostMode(QBluetoothLocalDevice::HostConnectable);
      }
      serviceDiscoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
      serviceDiscoveryAgent->clear();
      serviceDiscoveryAgent->setUuidFilter(QBluetoothUuid(QBluetoothUuid::SerialPort));
      serviceDiscoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);

      }
      void BtScan :: stopDiscovery()
      {
      if(serviceDiscoveryAgent->isActive())
      {
      serviceDiscoveryAgent->stop();
      }
      }
      @

      If I comment out the serviceDiscoveryAgent->stop(); line, the program works fine , discovers bluetooth devices etc, (but obviously the scanning continues even after I have pressed stop). If I include the line, when i press stop, the app crashes.

      Does anyone have any idea why? Or another way to stop an ongoing bluetooth service discovery?

      Thanks

      1 Reply Last reply Reply Quote 0
      • First post
        Last post