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, discovering devices' services never ends.
Forum Updated to NodeBB v4.3 + New Features

Bluetooth, discovering devices' services never ends.

Scheduled Pinned Locked Moved Mobile and Embedded
15 Posts 3 Posters 6.2k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Can you create a minimal compilable example that reproduce the behavior ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • X Offline
      X Offline
      XelaG
      wrote on last edited by
      #5

      I made two tests on two different tablets.

      1. Samsung galalxy tab2 with cyanogenmod android 4.2.2
      2. Motoral XOOM with android 4.0.2

      The issue is present with both of them.

      You can download the apk there : https://dl.dropboxusercontent.com/u/1628289/QtApp-debug.apk

      you'll see the main window
      !https://dl.dropboxusercontent.com/u/1628289/main.png!

      If you click on "Create device list", after a while is might display a message with the list of device available nearby the tablet.
      !https://dl.dropboxusercontent.com/u/1628289/device_list.png!

      If you click on 'open device', it will try to initialize the first device in the list. Even an error message box is displayed that means the initialization function is not blocking. If you click 'filter devices', the initialization function will get stuck and no message box with be displayed.

      you don't have a create device list before opening the device. If no device list has been created, a default device will be created using the address entered in the line edit control.

      Thanks for your help.

      "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #6

        Can you share the code so I can built it with my version of Qt ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • X Offline
          X Offline
          XelaG
          wrote on last edited by
          #7

          there :
          https://dl.dropboxusercontent.com/u/1628289/trunk.zip

          "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

          1 Reply Last reply
          0
          • X Offline
            X Offline
            XelaG
            wrote on last edited by
            #8

            Hi SGaist,

            Did you have time to try to reproduce the issue ?
            If so, did you succeed in it ?

            Alex.

            "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Hi,

              Sorry for the delay

              Indeed there's a loop going on when filtering. However you have some typos in your code, at least in BluePort you have quitConnectionLoop rather than quitLoop.

              You should simplify your example and open a report on the "bug report system":http://bugreports.qt-project.org

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • X Offline
                X Offline
                XelaG
                wrote on last edited by
                #10

                [quote author="SGaist" date="1404423551"]Sorry for the delay[/quote]No worries.

                [quote author="SGaist" date="1404423551"]Indeed there's a loop going on when filtering. However you have some typos in your code, at least in BluePort you have quitConnectionLoop rather than quitLoop.[/quote]Shoot, I forgot to rename the slot at this line...

                [quote author="SGaist" date="1404423551"]You should simplify your example and open a report on the "bug report system":http://bugreports.qt-project.org[/quote]I will.

                Thank you very much for your help.

                "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ablasche
                  wrote on last edited by
                  #11

                  Based on my debugging the signals are emitted but QEventLoop is not waking up. If there is a bug in here then it's QEventLoop. I lack the knowledge to determine the cause.

                  In any case (as suggested in my bug comment) I suggest to rewrite your app to not use QEventLoop as it can be a very destablising factor in the app and your app can be written without it.

                  --
                  Alex

                  1 Reply Last reply
                  0
                  • X Offline
                    X Offline
                    XelaG
                    wrote on last edited by
                    #12

                    [quote author="Alex Blasche" date="1404728740"]Based on my debugging the signals are emitted but QEventLoop is not waking up. If there is a bug in here then it's QEventLoop. I lack the knowledge to determine the cause.
                    In any case (as suggested in my bug comment) I suggest to rewrite your app to not use QEventLoop as it can be a very destablising factor in the app and your app can be written without it.[/quote]

                    QEventLoop works fine when discovering bluetooth devices with QBluetoothDeviceDiscoveryAgent. The function is similar to the one searching for bluetooth services with QBluetoothServiceDiscoveryAgent which never ends.

                    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ablasche
                      wrote on last edited by
                      #13

                      That might be a conincedence or just pure luck. The device discovery uses completely different Android API's.

                      My main point is that QBluetoothServiceDiscoveryAgent is working as expected, QEventLoop is not at all recommended to be used if avoidable (which it is here) and can cause spourious crashes. It shouldn't be too difficult to change the relevant code pieces in your application. Believe me when I telll you that I have been where you are with your QEventLoop based implementation and I taking those experiences into account I strongly discourage its use.

                      I leave it up to you if you want to file a bug against QEventLoop on Android.

                      --
                      Alex

                      1 Reply Last reply
                      0
                      • X Offline
                        X Offline
                        XelaG
                        wrote on last edited by
                        #14

                        [quote author="Alex Blasche" date="1404736574"][...]I strongly discourage its use.[/quote]
                        So how can I wait for the end of an asynchronous function. I open a new thread on the forum for those who could help me.
                        "Waiting for an asynchronous function":https://qt-project.org/forums/viewthread/44795/

                        Thanks for having checked why the service discovery never ends.

                        "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          ablasche
                          wrote on last edited by
                          #15

                          I posted a small toy example in the other thread.

                          Mind you threads won't help as the Bluetooth classes are not thread safe unless. You can use them in different threads but you have to build a lot of guards around them. This would make the code more complicated than it should be.

                          --
                          Alex

                          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