This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2340R5:BLE 控制器示例工程的 HCI 命令

Guru**** 2466550 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1550797/cc2340r5-hci-command-for-ble-controller-example-project

器件型号:CC2340R5


工具/软件:

尊敬的专家:

我是否可以使用 bluez hcitool 通过 HCI 命令设置和读取 TX 功率并发送到 BLE_controller 示例工程?

下面有用于读取和设置 TX 功率的 BLE 特定 HCI 命令、如下所示。 它可以在  BLE_controller 示例工程中提供支持吗?

用于 LE 的 BT 命令

ogf

OCF

操作码

读取传输功率级别

3.

45

0x0C2D

 

供应商特定命令

ogf

CSG

命令

操作码

HCI_EXT_SetTxPowerCmd

63

0

1.

0xFC01

HCI_EXT_SetMaxDtmTxPowerCmd

63

0

17

0xFC11

如何发送 hcitool 命令? 下面是正确的?

root@OpenWrt:/tmp# hcitool -i hci0 cmd 0x03 0x002D
< HCI 命令:ogf 0x03、ocf 0x002d、PLEN 0
> HCI 事件:0x0E PLEN 7
01 2D 0C 00 02 00
root@OpenWrt:/tmp#
root@OpenWrt:/tmp# hcitool -I hci0 cmd 0x3F 0x0011 0x00 0x02
< HCI 命令:ogf 0x3f、ocf 0x0011、PLEN 2
00 02
> HCI 事件:0x0E PLEN 4
01 11 FC 01
root@OpenWrt:/tmp#
root@OpenWrt:/tmp#
root@OpenWrt:/tmp#
root@OpenWrt:/tmp# hcitool -i hci0 cmd 0x03 0x002D
< HCI 命令:ogf 0x03、ocf 0x002d、PLEN 0
> HCI 事件:0x0E PLEN 7
01 2D 0C 00 02 00

BR、

Frank

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Frank、

    您可以将仅控制器解决方案与 BTool 或 BlueZ (Linux) 等主机应用一起使用。 用途是射频/BLE 测试还是主机控制器完整解决方案?

    您可以使用 BTool 尝试以下命令: C:\ti\simplelink_lowpower_f3_SDK_9_11_00_18\tools\ble\btool  

    您也可以只需使用一个脚本来将 TX 转储从主机(例如 PC)传输到控制器、例如:

    import serial
    import time
    
    # === CONFIGURE UART ===
    UART_PORT = "COM177"  # Adjust based on your system (e.g., COM3 on Windows)
    BAUD_RATE = 115200 # High baud rate for fast communication
    
    # Open UART connection
    uart = serial.Serial(UART_PORT, BAUD_RATE)
    
    def send_hci_command(command_hex):
        """Send an HCI command to the CC23xx over UART."""
        command_bytes = bytes.fromhex(command_hex)
        uart.write(command_bytes)
        time.sleep(0.05)
        response = uart.read(uart.in_waiting)
        print(f"HCI Response: {response.hex()}")
    
    # === SETUP HCI TEST ===
    def test_hci_ble():
        print("Testing HCI Commands")
    
        # Clear Adv Sets
        # Send_HCI_LE_ClearAdvSetCmd
        # Wait_HCI_Command_Complete_LE_ClearAdvSetCmd_Event 5000, any, HCI_LE_ClearAdvSetCmd, 0x00
        send_hci_command("01 02 20 00")
    
        # BD_ADDR = "DD:9A:78:56:34:12"
        # Create Adv Set 0
        # Send_HCI_LE_SetExtAdvParamsCmd 0, 0x0013, 50, 50, 0x07, 0x00, 0x00, BD_ADDR, 0x00, 127, 0x01, 0x0, 0x01, 0x00, 0x00
        # Wait_HCI_Command_Complete_LE_SetExtAdvParamsCmd_Event 5000, any, HCI_LE_SetExtAdvParamsCmd, 0x00, 
        send_hci_command("01 36 20 19 00 13 00 32 00 00 32 00 00 07 00 00 12 34 56 78 9a dd 00 7f 01 00 01 00 00")
    
        # Set Adv Data 0
        # Send_HCI_LE_SetExtAdvDataCmd 0x00, 0x03, 0x00, 0x10, "00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F"
        # Wait_HCI_Command_Complete_LE_SetExtAdvDataCmd_Event 5000, any, HCI_LE_SetExtAdvDataCmd, 0x00
        send_hci_command("01 37 20 14 00 03 00 10 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f")
    
        # Enable advertising
        # Send_HCI_LE_SetExtAdvEnableCmd 0x01, 0x01, 0, "00:00", 0
        # Wait_HCI_Command_Complete_LE_SetExtAdvEnableCmd_Event 5000, any, HCI_LE_SetExtAdvEnableCmd, 0x00
        send_hci_command("01 39 20 06 01 01 00 00 00 00")
    
        # Send_HCI_EXT_NumComplPktsLimitCmd 2, 0
        #send_hci_command("01 1f fc 02 01 00")
    
        # Send_HCI_LE_Read_Buffer_Size
        send_hci_command("01 02 20 00")
    
        time.sleep(4)
    
        #HCI_LE_SetPhy
        send_hci_command("01 32 20 07 00 00 00 02 02 00 00")
    
        while (1):
            time.sleep(0)
            send_hci_command("02 00 00 78 00 00 11 22 33 44 00 11 22 33 44 00 11 22 33 44 00 11 22 33 44 00 11 22 33 44 00 11 22 33 44")
    
    # === MAIN EXECUTION ===
    test_hci_ble()

    BR、

    David