Sunday, May 15, 2016

[RR Bluetooth] gatttool - What HCI Commands are Sent by gatttool (1) Connect, Disconnect

It's interested in knowing what kind of HCI command are sent by gatttool.
here are the captures by btmon

remember,

HCI packet type codes
• Command = 0x01
• Data = 0x02
• Event = 0x04
OGF is 6 bits
For the Link Control commands, the OGF is defined as 0x01.
For the LE Controller Commands, the OGF code is defined as 0x08.



connect         [address [address type]]       Connect to a remote device


LE Create Connection:

< HCI Command: LE Create Connec.. (0x08|0x000d) plen 25  [hci0] 23:39:43.092169
        Scan interval: 60.000 msec (0x0060)
        Scan window: 30.000 msec (0x0030)
        Filter policy: White list is not used (0x00)
        Peer address type: Public (0x00)
        Peer address: 34:B1:F7:D5:XX:XX (Texas Instruments)
        Own address type: Public (0x00)
        Min connection interval: 50.00 msec (0x0028)
        Max connection interval: 70.00 msec (0x0038)
        Connection latency: 0x0000
        Supervision timeout: 420 msec (0x002a)
        Min connection length: 0.000 msec (0x0000)
        Max connection length: 0.000 msec (0x0000)
 < 0000: 01 0d 20 19 60 00 30 00  00 00 64 59 d5 f7 b1 34
  0010: 00 28 00 38 00 00 00 2a  00 00 00 00 00  
> HCI Event: Command Status (0x0f) plen 4                [hci0] 23:39:43.110011
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
LE Connection Complete Event: 
> HCI Event: LE Meta Event (0x3e) plen 19                [hci0] 23:39:43.618997
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 71
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: 34:B1:F7:D5:XX:XX (Texas Instruments)
        Connection interval: 70.00 msec (0x0038)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Master clock accuracy: 0x00
> 0000: 04 3e 13 01 00 47 00 00  00 64 59 d5 f7 b1 34 38  .>...G...dY...48
  0010: 00 00 00 2a 00 00    
 LE Read Remote Used Features Command:
< HCI Command: LE Read Remote Us.. (0x08|0x0016) plen 2  [hci0] 23:39:43.619334
        Handle: 71
 < 0000: 01 16 20 02 47 00    
> HCI Event: Command Status (0x0f) plen 4                [hci0] 23:39:43.623836
      LE Read Remote Used Features (0x08|0x0016) ncmd 0
        Status: Success (0x00)
The Num_HCI_Command_Packets event parameter allows the Controller to indicate the number of HCI command packets the Host can send to the Controller. If the Controller requires the Host
to stop sending commands, the Num_HCI_Command_Packets event parameter will be set to zero. To indicate to the Host that the Controller is ready to receive HCI command packets, the Controller generates a Command Status event with Status 0x00 and Command_Opcode 0x0000, and the Num_HCI_Command_Packets event parameter is set to 1 or more. Command_Opcode, 0x0000 is a NOP (No OPeration) and can be used to change the number of outstanding HCI command packets that the Host can send before waiting.

 @ Device Connected: 34:B1:F7:D5:XX:XX (1) flags 0x0000
> HCI Event: Command Status (0x0f) plen 4                [hci0] 23:39:44.067965
      NOP (0x00|0x0000) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 12                [hci0] 23:39:44.210047
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 71
        Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
> 0000: 04 3e 0c 04 00 47 00 01  00 00 00 00 00 00 00  


disconnect                                     Disconnect from a remote device


Disconnect Command



< HCI Command: Disconnect (0x01|0x0006) plen 3           [hci0] 01:30:43.714810
        Handle: 71
        Reason: Remote User Terminated Connection (0x13)
< 0000: 01 06 04 03 47 00 13 

Disconnection Complete Event:

> HCI Event: Disconnect Complete (0x05) plen 4           [hci0] 01:30:45.748097
        Status: Success (0x00)
        Handle: 71
        Reason: Connection Terminated By Local Host (0x16)

> 0000: 04 05 04 00 47 00 16  








No comments:

Post a Comment