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. Android, (classic) Bluetooth SPP - QBluetoothDeviceInfo - encode ENUMs into Bits
Forum Updated to NodeBB v4.3 + New Features

Android, (classic) Bluetooth SPP - QBluetoothDeviceInfo - encode ENUMs into Bits

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 385 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.
  • ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by
    #1
    QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name, quint32 classOfDevice)
    

    My problem is with encoding classOfDevice into the following format:

    Bits	Size	Description
    0 - 1	2	Unused, set to 0.
    2 - 7	6	Minor device class.
    8 - 12	5	Major device class.
    13 - 23	11	Service class.
    

    I don’t have a Service class, but Minor and Major Device classes. These are the possible values (ENUMs):

    MAJOR CLASS always

    QBluetoothDeviceInfo::ImagingDevice	(6)
    

    MINOR CLASS - one of this:

    QBluetoothDeviceInfo::UncategorizedImagingDevice	(0)	
    QBluetoothDeviceInfo::ImageScanner	(0x10)	
    QBluetoothDeviceInfo::ImagePrinter	(0x20)
    

    Now my question:
    How can I encode those ENUM values into the quint32 classOfDevice ?

    ... I’m always fighting with stuff like this ;-)

    thanks for hints

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.9 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    jsulmJ 1 Reply Last reply
    0
    • ekkescornerE ekkescorner
      QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name, quint32 classOfDevice)
      

      My problem is with encoding classOfDevice into the following format:

      Bits	Size	Description
      0 - 1	2	Unused, set to 0.
      2 - 7	6	Minor device class.
      8 - 12	5	Major device class.
      13 - 23	11	Service class.
      

      I don’t have a Service class, but Minor and Major Device classes. These are the possible values (ENUMs):

      MAJOR CLASS always

      QBluetoothDeviceInfo::ImagingDevice	(6)
      

      MINOR CLASS - one of this:

      QBluetoothDeviceInfo::UncategorizedImagingDevice	(0)	
      QBluetoothDeviceInfo::ImageScanner	(0x10)	
      QBluetoothDeviceInfo::ImagePrinter	(0x20)
      

      Now my question:
      How can I encode those ENUM values into the quint32 classOfDevice ?

      ... I’m always fighting with stuff like this ;-)

      thanks for hints

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ekkescorner Like

      if (deviceInfo == QBluetoothDeviceInfo::ImagingDevice)
           classOfDevice = 0x00000100; // Set bit 8
      else ...
      

      ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J.HilkJ 1 Reply Last reply
      2
      • jsulmJ jsulm

        @ekkescorner Like

        if (deviceInfo == QBluetoothDeviceInfo::ImagingDevice)
             classOfDevice = 0x00000100; // Set bit 8
        else ...
        

        ?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @jsulm or since it's now allowed (since c++17 iirc)

        if (deviceInfo == QBluetoothDeviceInfo::ImagingDevice)
             classOfDevice = 0b00000000000000000000000010000000; // Set bit 8
        else ...
        

        you can see it directly, admittedly for an int32 lot to type but super nice for int16 where I use it regularly


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        2
        • ekkescornerE Offline
          ekkescornerE Offline
          ekkescorner
          Qt Champions 2016
          wrote on last edited by
          #4

          @jsulm @J-Hilk thx - will try it

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps
          5.15 --> 6.9 https://t1p.de/ekkeChecklist
          QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

          1 Reply Last reply
          0
          • ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #5

            @jsulm so I figured it out :)

            classOfDevice = 0x000600; // MAJOR 6, MINOR 0
            classOfDevice = 0x000640; // MAJOR 6, MINOR 16 - 0x10
            classOfDevice = 0x000680; // MAJOR 6, MINOR 32 - 0x20
            

            @J-Hilk soon will switch to 0b.... format - (current project still on C++11)

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.9 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            2

            • Login

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