Results 1 to 4 of 4

Thread: qtconnectivity / btscanner discussion ?

  1. #1
    Join Date
    Aug 2020
    Posts
    18
    Qt products
    Qt5

    Default qtconnectivity / btscanner discussion ?

    I would like to connect with someone who actually , physically coded bluetooth application using Qt "examples" qtconnectivity.
    I am not looking for "RTFM" advises, I like to talk to somebody who especially used / cloned the "btscanner" example.

    After few weeks of using QtCreator (and RTFM) I feel pretty confident I finally have the QtCreator / QtDesigner concept.

    Now I am ready to actually implement my version of "btscanner" and could use somebody real experience understanding specifics.

    For starters

    After starting the bluetooth inquiry - discover near-by devices - I IMMEDIATELY receive first signal "device discovered " then after EXPECTED delay I receive second signal " scan completed".
    That makes no sense - the "device discovered" should be received AFTER scan in completed.
    This implies that "device discovered" signal is not emitted from after the actual scan is finished , but from some yet unknown data base filled previously.

    This is just one starting "problem" I could use some assistance with , if it is a real issue. I do not know.
    I am not asking for assistance with a specific code.

    Cheers

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,689
    Thanks
    257
    Thanked 748 Times in 738 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: qtconnectivity / btscanner discussion ?

    I am not looking for "RTFM" advises
    You've been told to RTFM because the questions you have been asking about Qt slots, signals, UI programming and other aspects of Qt have demonstrated that you haven't grasped some really fundamental concepts that only RTFM and studying the many, many examples and tutorials can teach you.

    I have tried to give you suggestions and written example code on how to accomplish most of the things you have asked about. If that hasn't been appreciated, then too bad. I've wasted a few hours of my time. Fool me once, shame on you. I won't be fooled twice. Maybe someone else will be foolish enoungh to jump in instead.

    As for your current questions, it makes perfect sense that a scan would return intermediate results as it discovers them before it announces that it is finished. These are hardware devices, each of which might take a different amount of time to respond to a "who's out there?" broadcast. As each one responds, "I am", the scanner reports that. Some might be fast and discovered immediately, some the operating system might already have identified for other purposes and can report immediately as well. I would imagine that at the OS level, it is frequently pinging devices that are paired wirelessly, so has a good idea which ones are still in range and connected. Others it might have to ping again to make sure. After a certain time has elapsed and no more devices have responded, the scanner quits looking and reports it is finished.

    But then, I haven't RTFM either, so I'm just making stuff up.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,668
    Thanks
    13
    Thanked 1,595 Times in 1,523 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qtconnectivity / btscanner discussion ?

    Quote Originally Posted by anneranch View Post
    After starting the bluetooth inquiry - discover near-by devices - I IMMEDIATELY receive first signal "device discovered " then after EXPECTED delay I receive second signal " scan completed".
    That makes no sense - the "device discovered" should be received AFTER scan in completed.
    This implies that "device discovered" signal is not emitted from after the actual scan is finished , but from some yet unknown data base filled previously.
    To quote the friendly manual,
    To retrieve results asynchronously, connect to the deviceDiscovered() signal. To get a list of all discovered devices, call discoveredDevices() after the finished() signal.
    and in regards to deviceDiscovered() :
    The signal is emitted as soon as the most important device information has been collected. However, as long as the finished() signal has not been emitted the information collection continues even for already discovered devices.
    If you ask for the asynchronous signal, as the btscanner example does, then the process runs something like this:
    Qt Code:
    1. Scan starts
    2. While (scan not complete)
    3. If a device is discovered (i.e. an inquiry response received)
    4. emit a deviceDiscovered() signal as soon as enough information is known
    5. add device to discovered list
    6. keep scanning
    7. emit finished() signal
    To copy to clipboard, switch view to plain text mode 
    So, it is perfectly logical for the discovery signal to appear before the finished signal... (It seems illogical to expected reports of new devices after it is finished looking)
    It is also possible the same device might be discovered twice but I do not know if that leads to more deviceDiscovered() signals for the same device.

    The time from the start of scan (Bluetooth inquiry out) to the first detected device (inquiry response) might be measured in milliseconds, more than fast enough to be considered "IMMEDIATELY", or it may be coming from an operating system maintained list of active devices. Either way the device exists.

    If you want a single consolidated list then wait only on the finished signal (after about 10.24 seconds I guess) and use the discoveredDevices() to list all discovered devices in one hit. You should watch the error signal too.

    Quote Originally Posted by anneranch
    This is just one starting "problem" I could use some assistance with , if it is a real issue. I do not know.
    Does not seem like problem at all.

  4. #4
    Join Date
    Aug 2020
    Posts
    18
    Qt products
    Qt5

    Default Re: qtconnectivity / btscanner discussion ?

    As I said in original post - this is first time I am actually analysing the Qt (btscanner) bluetooth process.
    I still have some basic issues with Qt, but working on that.

    The bluetooth process starts with "scan" and from the point it is up to the "discovery process", not something I can control.
    Having used HCI directly before I am aware that the actual "scan for nearby devices " takes time , again controlled by HCI or "bluez" .
    Hence the already mentioned sequence of Qt signals scan - list discovered devices - scan completed is NOT under my control.

    At this point I suspect that Qt bluetooth process is using something similar to

    bluetoothctl list
    Qt Code:
    1. z@z-desktop:~$ bluetoothctl list
    2. [NEW] Controller 00:15:83:15:A2:CB z-desktop [default]
    3. [NEW] Device B8:27:EB:11:3F:82 ARM
    4. [NEW] Device 98:D3:31:F8:39:33 SPP-CA
    5. [NEW] Device 00:50:B6:80:4D:5D z-desktop
    6. [bluetooth]#
    To copy to clipboard, switch view to plain text mode 

    That command DOES not perform actual "scan for nearby devices" - no observable delay - outputs immediately.

    Yes, it is a MY problem because my objective is to identify working, powered-up etc. bluetooth devices.

    btsanner "masks" this "problem" by listing ALL previously identified devices , BUT fails to "pair" with device which is not active.

    That is OK , but somewhat silly , after the fact - why allowing to "pair" non existent device ?

    I do appreciate your comments , and I am not blaming anything on Qt process.

    But I would like to empathize that until I check the Qt bluetooth source code this is just an academic " best guess / what if" discussion .
    Since it appears that Qt bluetooth process is NOT doing what I like to have done - the solution is obviously to write my own code .




    I should be good after I get more Qt experience.

Similar Threads

  1. Discussion on GUI and Program-Solver Interaction
    By Omid123 in forum Qt Programming
    Replies: 4
    Last Post: 23rd February 2015, 22:54
  2. QtConnectivity supported on S60 ?
    By Qting in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2012, 20:07
  3. Discussion about developing an onscreen keyboard in Qt
    By montylee in forum Qt Programming
    Replies: 6
    Last Post: 2nd January 2009, 20:09
  4. brief discussion IProjectcomponent
    By ramakrishnach in forum General Discussion
    Replies: 3
    Last Post: 1st May 2006, 08:19
  5. [DevQt] General discussion
    By GreyGeek in forum Qt-based Software
    Replies: 40
    Last Post: 25th April 2006, 08:24

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.