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. Stopping Bluetooth Service discovery crashes the App

Stopping Bluetooth Service discovery crashes the App

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 745 Views 1 Watching
  • 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 Offline
    G Offline
    GoodMorninSunshine
    wrote on last edited by
    #1

    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
    0

    • Login

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