Set/get Tx Power Fail

Environment : nRF52833, NCS v3.1.1

Hi. I evaluate PAwR project in my Solution.

PAwR is Fine. But get/set Tx Power is issue.

before add PAwR, My solution used common Advertising.

In this Time. before start advertising, get/set Tx Power is available. (added prj.conf)

## BLE
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="KKKKKKKK"

CONFIG_BT_BUF_ACL_RX_SIZE=512
#CONFIG_BT_BUF_ACL_TX_COUNT=3
CONFIG_BT_BUF_ACL_TX_SIZE=512
CONFIG_BT_L2CAP_TX_MTU=509

CONFIG_BT_CTLR_DATA_LENGTH_MAX=251


CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

# CONFIG_BT_USER_PHY_UPDATE=y
# CONFIG_BT_DATA_LEN_UPDATE=y

CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

## BLE TX Power Control
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

However, After add PAwR, Issue is happend. (added pri.conf)

## PAWR
CONFIG_BT_OBSERVER=y
CONFIG_BT_BROADCASTER=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_PER_ADV_SYNC=y

CONFIG_BT_MAX_CONN=1
CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER=y
CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER=y

CONFIG_BT_PER_ADV_SYNC_RSP=y
CONFIG_BT_PER_ADV_SYNC_BUF_SIZE=247

before advertising, get/set tx power error. ( bt_hci_core: opcode 0xfc0f status 0x42, err: -5)

when start advertising, get/set tx power is work.

I thought that adding Ext Advertising is problem.

I wanna set/get tx power before starting advertising. (add set/get txpower code)

 struct bt_hci_cp_vs_write_tx_power_level *cp;
	struct bt_hci_rp_vs_write_tx_power_level *rp;
	struct net_buf *buf, *rsp = NULL;

	buf = bt_hci_cmd_alloc(K_FOREVER);
	if (!buf) {
		LOG_INF("Unable to allocate command buffer\n");
		return -2;
	}

	cp = net_buf_add(buf, sizeof(*cp));
	cp->handle = sys_cpu_to_le16(0);
	cp->handle_type = BT_HCI_VS_LL_HANDLE_TYPE_ADV;
	cp->tx_power_level = txPower;

	int err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				   buf, &rsp);
	if (err) {
		LOG_INF("Set Tx power err: %d\n", err);
		return err;
	}

	rp = (void *)rsp->data;
	LOG_INF("Set Tx Power: %d\n", rp->selected_tx_power);

	net_buf_unref(rsp);
    return 0;

is Any Solution?

Thanks.

  • Hi Ben, 

    When PAwR gets enabled, the stack switches over to extended advertising, and that changes how the controller handles the advertising identifiers. In the old setup, legacy advertising always used handle 0 by default, so anything referring to that handle worked without any extra steps.

    With extended advertising, there is no built-in handle anymore. Each advertising set gets its own handle once you create it with bt_le_ext_adv_create(). If the TX power command runs before that set exists, or if it still tries to use handle 0, the controller would not know which advertising set you’re referring to and replies with status 0x42 (“Unknown Advertising Identifier”).

    The fix is to create the extended advertising set first, get the handle that the controller gives you, and use that when setting or reading the TX power.

Related