Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Sending AIROC™ HCI UART and RAW HCI UART commands from host - KBA236831

Sending AIROC™ HCI UART and RAW HCI UART commands from host - KBA236831

Infineon_Team
Moderator
Moderator
Moderator
5 replies posted First solution authored First comment on KBA

Sending AIROC™ HCI UART and RAW HCI UART commands from host - KBA236831

Version: **

Answer:
An AIROC™ HCI UART command starts with a header ‘0x19’, followed by a byte that indicates the command opcode, a byte that indicates the command group, two bytes (lower byte followed by upper byte) indicating the length of the data, and the bytes containing the packet to be sent.

Command format:

The CYWxxxxx uses the following 5-byte packet header for command/event exchanges with the host MCU.

Packet type

Command/event code

Group code

Packet length

HCI_WICED_PKT(0x19)

HCI_CONTROL_COMMAND_...

HCI_CONTROL_GROUP_...

Low byte

High byte

 

The received HCI event has the same format, with the packet bytes containing the received data.

For command opcode and command group byte see https://github.com/Infineon/btsdk-docs/blob/master/docs/BT-SDK/AIROC-HCI-Control-Protocol.pdf

Example 1: Sending reset command:

  • The opcode for reset is ‘01’ and its group number is ‘00’.
  • The packet length will be ‘00’ (lower byte) and ‘00’ (higher byte), as it does not have any packets to be sent.
  • The AIROC™ HCI UART command for reset is ‘0x19 0x01 0x00 0x00 0x00’ (no bytes for packet).
  • If the command is executed successfully, a “device started” event will be received as follows: ‘0x19 0x05 0x00 0x00 0x00’.

Example 2: Read local BD_address:

  • The AIROC™ HCI UART command will be ‘0x10 0x0F 0x00 0x00 0x00’.
  • The corresponding event received will have six-byte BDA, hence the packet length will be ‘0000 0110’, or ‘0x06 0x00’.
  • Thus, the event will be ‘0x19 0x0D 0x00 0x06 0x00 XX XX XX XX XX XX’.

Example 3: Trace enable:

  • The packet has a length of two bytes, ‘0000 0010’, hence the length will be indicated as ‘0x02 0x00’.
  • The first byte is ‘0x01’ (to enable traces) and second byte is ‘0x10’ (to forward HCI traces as RAW text to HCI UART).
  • The command is, ‘0x19 0x02 0x00 0x02 0x00 0x01 0x10’.

Question 2: Sending RAW HCI UART commands.

Answer: An RAW HCI UART command has ‘01’ as prefix, and the corresponding events will have ‘04’ as prefix. The prefix is then followed by an opcode, which contains ‘OGF’ and ‘OCF’ as stated in the below example:

Command        : Set_Transmit_Power  (VS command)
OGF                 : 0x3F    (0011 1111)
OCF                 : 0x026   (0000 0010 0110)
Opcode         : 0xFC26  (0-9 bits OCF & 10-15 bits of OGF)

Opcode formation:

[15OGF 10,  9OCF0]
11 1111 ,  00 0010 0110
1111  1100  0010  0110

    F        C        2         6

=0xFC26

The opcode is followed by the parameter length and the parameters.

Command format:

Infineon_Team_0-1673346382739.png

Reverse process:

Opcode: FC26

1111 1100 0010 0110
[15OGF10 ,  9OCF0]
111111 ,   0000100110
11 1111 ,   00 0010 0110

3       F          0     2        6

=0x3F           = 0x026

  OGF                OCF 

Example 1 Read_BD_ADDR

Command      : 01 09 10 00    (opcode:0x1009,  OGF:0x04, OCF:0x009)

In Cybluetool    : [09 10 00 ]
Event                 : 04 0E 0A 01 09 10 00 95 60 1A 9A 81 20
In Cybluetool    : [0E 0A]: 01 09 10 00 95 60 1A 9A 81 20)

Event details:

04 - prefix  (1 octet)
0E - Event code (1 octet)  (‘0x0E’ is for command complete event)
0A - Parameter length   (1 octet)
01 - Num_HCI_Command_Packets  (1 octet)
09 10 - Command opcode  (2 octet)
00 - Return parameter  (Status of Read_BD_ADDR commad )
95 60 1A 9A 81 20 - Return parameter (BD address of the device)

Example 2: Reset

Command        : 01 03 0C 00    (opcode = 0x0C03, OGF:0x03, OCF:0x003)

In Cybluetool   : [03 0C 00 ]
Event                   : 04 0E 04 01 03 0C 00
In Cybluetool   :[0E 04 ]: 01 03 0C 00

Event details:

04 - Prefix (1 octet)
0E - Event code  (1 octet) (‘0x0E’ is for command complete event)
04 - Parameter Length   (1 octet)
01 - Num_HCI_Command_Packets  (1 octet)
03 0C - Command opcode  (2 octet)
00 - Return_Parameters  (Specific for each command)

Event format:

Infineon_Team_1-1673346497176.png
0 Likes
39 Views
Contributors