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. Unknown Exception is not beeing caught in trycatch-Block (Bluetooth Low Energy, ServiceDetailsDiscovery)
Forum Updated to NodeBB v4.3 + New Features

Unknown Exception is not beeing caught in trycatch-Block (Bluetooth Low Energy, ServiceDetailsDiscovery)

Scheduled Pinned Locked Moved Solved General and Desktop
bluetoothbluetooth low eexceptions
25 Posts 6 Posters 7.3k Views 3 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.
  • JonBJ JonB

    @SpaceToon said in Unknown Exception is not beeing caught in trycatch-Block (Bluetooth Low Energy, ServiceDetailsDiscovery):

    Well, if I comment this line, then nothing happens after the service discovery

    I don't understand what that means. Your crash then goes away if this code not executed?? characteristicsList = selectedService->characteristics(); --- could selectedService == nullptr/inavlid? "And the characteristicDiscoveredSignal only tells the UI to show the discovered characteristics on the GUI` --- and could that cause a crash?

    As I said, maybe I'm barking up the wrong tree from the traceback, your call, just trying to see where a "crash" could be....

    S Offline
    S Offline
    SpaceToon
    wrote on last edited by SpaceToon
    #21

    @JonB
    Ohh sorry, I was using a older version of my code and was commenting out the wrong line ;d
    I will try it now with the correct version. I think this will take time ro reproduce this, but I will report here when I'm done.

    EDIT: That was fast. The applications till crashes, although I commented out this line. And I do not think that my characteristicDiscoveredSignal caused a crash because I set up a breakpoint there and it is never reached.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SpaceToon
      wrote on last edited by
      #22

      When I set a breakpoint at selectedService->discoverDetails(); and when I want to jump in the qt function discoverDetails() while debugging, it does not work. I want to now at which point exactly the error appears. Is there another way to debug this qt-own-function?

      JonBJ 1 Reply Last reply
      0
      • S SpaceToon

        When I set a breakpoint at selectedService->discoverDetails(); and when I want to jump in the qt function discoverDetails() while debugging, it does not work. I want to now at which point exactly the error appears. Is there another way to debug this qt-own-function?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #23

        @SpaceToon
        From your earlier stack trace, it looks like you are linking against debug versions of the Qt libraries, but there is a lack of line numbers. Did you compile Qt for debug, and can the debugger see/know the location of the corresponding Qt source files?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SpaceToon
          wrote on last edited by
          #24

          @JonB Yes, I did.

          @KH-219Design : Thank you very much for your suggestion, for using the lowenergy example from Qt. I did this and the same error occurs there! For this reason, I copied the following code from there and paste it in my .cpp file:

                  connect(controller, QOverload<QLowEnergyController::Error>::of(&QLowEnergyController::error),
                          this, &Device::errorReceived);
          

          And in the Slot, I had:

          void BluetoothModel::errorReceived(QLowEnergyController::Error /*error*/)
          {
              qWarning() << "Error: " << controller->errorString();
          }
          

          And after a couple of times of connecting and disconneting, finally the error occurs. My errorReceived said:

          Error:  "Remote device closed the connection"
          

          And in the debugger, I had:
          6e215207-299f-4435-9368-a7843df1ceeb-image.png

          But my "Problem" was, that the LED on my device, that indactes that it is connected (it is a blue LED), was still on, so I did not knew before, that the connection was closed.
          So, it has to do with my device and not with my code. Now, knowing where the error occurs, I can reestablish the connection to the device, before the user can do anything on he GUI, that leads to the crash.

          @All: Thank you very much for your help here, love this community :)

          1 Reply Last reply
          0
          • KH-219DesignK Offline
            KH-219DesignK Offline
            KH-219Design
            wrote on last edited by
            #25

            @SpaceToon said in Unknown Exception is not beeing caught in trycatch-Block (Bluetooth Low Energy, ServiceDetailsDiscovery):

            @KH-219Design : Thank you very much for your suggestion, for using the lowenergy example from Qt. I did this and the same error occurs there! For this reason, I copied the following code from there and paste it in my .cpp file

            @SpaceToon I'm truly happy to hear you are able to make forward progress on this!

            This year marks the first year that I have ventured into BLE using Qt, and I have hit some minor hiccups myself. That is why your post caught my attention in the first place. However, I am working on Android and you are on Windows, which have very different backend/underlying BLE system stacks. So based on the difference in operating systems, I was doubtful if anything I learned would really translate directly here.

            Your watershed moment about QLowEnergyController::Error prompted me to go look at my code again to see what I am doing in case of QLowEnergyController::Error. I noticed that in my slot I have this comment:

                    // The Qt API for QLowEnergyController has some confusing
                    // overlap/ambiguity.  When we get "ConnectionError" I would EXPECT that
                    // the signal QLowEnergyController::disconnected would also be
                    // forthcoming. But it seems (by observation) that this is not how it
                    // works.  So we have to treat BOTH the disconnected signal and the
                    // error signal as signs of a disconnection.
            

            ... so maybe you and I did actually run into a very similar pitfall after all!

            It would be great to know if there is some null-reference bug in Qt BLE itself, but neither you nor I may have time to investigate that further. Since we both seem to have worked around our respective pain points, may we carry on and each deliver a successful project!

            You also asked:

            Did you compile Qt for debug, and can the debugger see/know the location of the corresponding Qt source files?

            Which is a very useful tactic, which I have done many times on Linux Qt.

            I just read some of this: https://stackoverflow.com/questions/5571098/how-can-i-make-msvc-debugger-step-into-qt-library-source-code-again/5576414

            Which refers to compiling the QtCored5.dll DLL(s) for oneself. (This is essentially analogous to how I do it on Linux, but building Qt from source is usually several hours of effort on the first time... and I'm not talking about the additional potential hours of just letting the compiler run!)

            Maybe someone else in this thread has had personal experience with debugging into Qt source files on Microsoft Windows. Or maybe that could be a new thread!

            www.219design.com
            Software | Electrical | Mechanical | Product Design

            1 Reply Last reply
            1

            • Login

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