Other Parts Discussed in Thread: CC2340R5
器件型号: CC2340R5
您好:
如何在 Zephyr 中更改 CC2340 的 TX 功率? 是否有配置选项?
Munan
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.
您好!
与设置 TX 功率不同、读取 TX 功率不是特定于供应商的 HCI 命令。 这是一个常规蓝牙 HCI 命令。 这意味着您可以发送值为 BT_HCI_OP_READ_TX_POWER_LEVEL 的 HCI 命令、方式与发送 VS HCI 命令相同。 您可以在“Zephyr\include\Zephyr\Bluetooth\HCI_types.h“中看到请求和响应结构的格式:
#define BT_HCI_OP_READ_TX_POWER_LEVEL BT_OP(BT_OGF_BASEBAND, 0x002d) /* 0x0c2d */
struct bt_hci_cp_read_tx_power_level {
uint16_t handle;
uint8_t type;
} __packed;
struct bt_hci_rp_read_tx_power_level {
uint8_t status;
uint16_t handle;
int8_t tx_power_level;
} __packed;
然后、您将能够从 rsp 结构读取 TX 功率、该结构由 bt_HCI_cmd_send_sync 填写。 您需要 通过添加“rp =(void *) rsp->data;“、将 rsp 转换为 bt_HCI_rp_read_tx_power_level 结构体。 您可以查看下面链接的示例、了解如何完成该操作。
关于内存分配问题、 使用供应商特定 HCI 命令的 Zephyr 示例 不会释放 buf 指针、但会在使用后通过调用“net_buf_unref (rsp);“释放 rsp 指针。 我假设 buf 指针被 bt_HCI_cmd_send_sync 释放。
此致、
Lea