Thursday, March 17, 2022

[SOLVED] What do Flags mean in bluetooth?

Issue

I have been trying out the bluez btmon tool to monitor the bluetooth discovery result on my raspberry pi 4.

The btmon tool returns stdout which is the following:

@ MGMT Event: Device Found (0x0012) plen 42                                    {0x0001} [hci0] 0.207973
        LE Address: 61:E1:E1:49:C8:DC (Resolvable)
        RSSI: -51 dBm (0xcd)
        Flags: 0x00000004
          Not Connectable
        Data length: 28
        16-bit Service UUIDs (complete): 1 entry
          Google (0xfe9f)
        Service Data (UUID 0xfe9f): 0000000000000000000000000000000000000000

@ MGMT Event: Device Found (0x0012) plen 33                                    {0x0001} [hci0] 0.224956
        LE Address: 48:82:8F:DB:5C:65 (Resolvable)
        RSSI: -76 dBm (0xb4)
        Flags: 0x00000000
        Data length: 19
        Flags: 0x1a
          LE General Discoverable Mode
          Simultaneous LE and BR/EDR (Controller)
          Simultaneous LE and BR/EDR (Host)
        TX power: 5 dBm
        Company: Apple, Inc. (76)
          Type: Unknown (16)
          Data: 491faeca8c8638

@ MGMT Event: Device Found (0x0012) plen 43                                    {0x0001} [hci0] 0.298194
        LE Address: 0E:AF:D9:F0:D8:F1 (Non-Resolvable)
        RSSI: -68 dBm (0xbc)
        Flags: 0x00000004
          Not Connectable
        Data length: 29
        Company: Microsoft (6)
          Data: 0109210a065124d7b5c04445534b544f502d44484845413434

@ MGMT Event: Device Found (0x0012) plen 43                                    {0x0001} [hci0] 0.940219
        LE Address: 86:2A:FD:9E:57:0D (OUI 86-2A-FD)
        RSSI: -77 dBm (0xb3)
        Flags: 0x00000000
        Data length: 29
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Service Data (UUID 0xfdf7): 01384a3dd6381b593c74d9369eefaa9b720000000003

Been looking for some official docs on explaining the field "Flags" in each discovered device info (those flag codes: 0x00000004, 0x00000000, 0x1a, 0x06), but I couldn't seem to find one that makes sense.

Would really appreciate if anyone could explain what does the Flags tell, and how to make sense of these codes?

Thanks in advance.


Solution

I don't know what you call "official docs", but the Bluetooth Core Specification and the Supplement to the Bluetooth Core Specification certainly explains it. Have a look at chapter 1.3 FLAGS of CSS

In the log you showed, you can see the advertising data of several Bluetooth LE devices. Each of this advertising data contains one ore more fields called AD Types. One of the AD Types is the "Flags" field. It may be zero or more octets long, with the first octet containing the following information:

Octet Bit Description
0 0 LE Limited Discoverable Mode
0 1 LE General Discoverable Mode
0 2 BR/EDR Not Supported. Bit 37 of LMP Feature Mask Definitions (Page 0)
0 3 Simultaneous LE and BR/EDR to Same Device Capable (Controller). Bit 49 of LMP Feature Mask Definitions (Page 0)
0 4 Previously Used
0 5..7 Reserved for future use

The given information tells you something about the used Bluetooth radio and about the advertising itself. If you are interested in a deeper understanding of this topic, I recommend reading this Bluetooth blog article: Advertising Works, Part 1



Answered By - Risto
Answer Checked By - David Goodson (WPSolving Volunteer)