<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Set &amp;quot;TX Power&amp;quot; of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81796/set-tx-power-of-nrf52833-using-zephyr</link><description>Hi 
 As mentioned in this question: https://devzone.nordicsemi.com/f/nordic-q-a/69533/set-tx-power-on-zephyr-device , there is a sample to change the tx power using some HCI commands. But when &amp;quot;extended advertising&amp;quot; has enabled, the approach that has</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Dec 2021 16:54:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81796/set-tx-power-of-nrf52833-using-zephyr" /><item><title>RE: Set "TX Power" of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/thread/344435?ContentTypeID=1</link><pubDate>Mon, 20 Dec 2021 16:54:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1768c5a-91e9-4ae8-b92a-f2612db90c70</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/saleh"&gt;Saleh&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply. There is a PR posted some days ago that seems to fix this problem: &lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/41133"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/41133&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set "TX Power" of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/thread/343341?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 09:31:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c774cee5-2245-444d-a76e-91cb67714aa5</guid><dc:creator>Saleh</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Is there any update regarding this issue? &lt;a href="https://devzone.nordicsemi.com/members/marjeris-romero"&gt;Marjeris Romero&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set "TX Power" of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/thread/339872?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 15:56:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8af490b-5562-449f-a763-34e9bb76fe62</guid><dc:creator>Saleh</dc:creator><description>&lt;p&gt;Thank you!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here you can find the log that has generated by this example:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/direction_finding_connectionless_rx/README.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/direction_finding_connectionless_rx/README.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It shows the RSSI of each extended advertising packet:&lt;/p&gt;
&lt;p&gt;TX side log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-1442-gf527a81dcf35  ***
Starting Direction Finding periodic advertising Beacon Demo
Bluetooth initialization...success
Advertising set create...success
Update CTE params...success
Periodic advertising params set...success
Enable CTE...success
Periodic advertising enable...success
Extended advertising enable...success
Started extended advertising as FA:6B:09:33:B5:E6 (random)
Set Tx power level to -20
Get Tx power level -&amp;gt; TXP = -20 &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;RX side log (a long history, only a section has copied, other lines are similar):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;...
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -320                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -30, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -300                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -30, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -300                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -33, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -330                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -32, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -320                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -34, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -340                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -33, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -330 
...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then after switching to a higher power of tx (after one minute)&lt;/p&gt;
&lt;p&gt;TX side log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-1442-gf527a81dcf35  ***
Starting Direction Finding periodic advertising Beacon Demo
Bluetooth initialization...success
Advertising set create...success
Update CTE params...success
Periodic advertising params set...success
Enable CTE...success
Periodic advertising enable...success
Extended advertising enable...success
Started extended advertising as FA:6B:09:33:B5:E6 (random)
Set Tx power level to -20
Get Tx power level -&amp;gt; TXP = -20                                                                                             
Set Tx power level to 8                                                                                                     
Get Tx power level -&amp;gt; TXP = 8&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;RX side log (a long history, only a section has copied, other lines are similar):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;...
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -37, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -370                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -31, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -310                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -33, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -330                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -31, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -310                          
PER_ADV_SYNC[0]: [DEVICE]: 0A:12:31:86:77:93 (random), tx_power 127, RSSI -33, CTE AOD 2 [us], data length 0, data:             
CTE[0]: samples count 45, cte type AOD 2 [us], slot durations: 2 [us], packet status CRC OK, RSSI -330
...&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set "TX Power" of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/thread/339821?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 12:56:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:228a56a4-c2fd-4e34-a3a2-019732b9b7ec</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply. I wonder if you have a corresponding RSSI logs together with the debug output logs you could attach as well?&lt;/p&gt;
&lt;p&gt;I need some time to try to test doing the same on my end so I can see if I manage to change the tx power dynamically on this example, so it&amp;#39;s better if I can come back to you on Monday after I have tried this myself.&lt;/p&gt;
&lt;p&gt;Have a nice weekend.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set "TX Power" of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/thread/339510?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 17:28:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:466ef117-6bd5-4cc3-ba8e-6fff2ae0d161</guid><dc:creator>Saleh</dc:creator><description>&lt;p&gt;Thanks for your reply!&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve made these changes to the &amp;quot;direction finding tx&amp;quot; example:&lt;/p&gt;
&lt;p&gt;Appending configuration needed for dynamic tx.&lt;/p&gt;
&lt;p&gt;prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;....
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And appending these lines of code to the source of the project, it switches the tx power from +8 to -20 repeatedly every 60 seconds:&lt;/p&gt;
&lt;p&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;...
#include &amp;lt;bluetooth/hci_vs.h&amp;gt;
...
void main(void)
{
    ...
    printk(&amp;quot;Started extended advertising as %s\n&amp;quot;, addr_s);
    
    int8_t txp_get = 0;
	while (1)
	{
		/* set power to -20 dBm */
		printk(&amp;quot;Set Tx power level to -20\n&amp;quot;);
		set_tx_power(BT_HCI_VS_LL_HANDLE_TYPE_ADV,
					0, -20);

		printk(&amp;quot;Get Tx power level -&amp;gt; &amp;quot;);
		get_tx_power(BT_HCI_VS_LL_HANDLE_TYPE_ADV,
					0, &amp;amp;txp_get);
		printk(&amp;quot;TXP = %d\n&amp;quot;, txp_get);

		k_sleep(K_SECONDS(60));

		/* set power to 8 dBm */
		printk(&amp;quot;Set Tx power level to 8\n&amp;quot;);
		set_tx_power(BT_HCI_VS_LL_HANDLE_TYPE_ADV,
					0, 8);
		printk(&amp;quot;Get Tx power level -&amp;gt; &amp;quot;);
		get_tx_power(BT_HCI_VS_LL_HANDLE_TYPE_ADV,
					0, &amp;amp;txp_get);
		printk(&amp;quot;TXP = %d\n&amp;quot;, txp_get);

		k_sleep(K_SECONDS(60));

	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And &amp;quot;set_tx_power&amp;quot; and &amp;quot;get_tx_power&amp;quot; are defined as (it has been copied from hci_pwr_ctrl sample):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void set_tx_power(uint8_t handle_type, uint16_t handle, int8_t tx_pwr_lvl)
{
	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;
	int err;

	buf = bt_hci_cmd_create(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				sizeof(*cp));
	if (!buf) {
		printk(&amp;quot;Unable to allocate command buffer\n&amp;quot;);
		return;
	}

	cp = net_buf_add(buf, sizeof(*cp));
	cp-&amp;gt;handle = sys_cpu_to_le16(handle);
	cp-&amp;gt;handle_type = handle_type;
	cp-&amp;gt;tx_power_level = tx_pwr_lvl;

	err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,
				   buf, &amp;amp;rsp);
	if (err) {
		uint8_t reason = rsp ?
			((struct bt_hci_rp_vs_write_tx_power_level *)
			  rsp-&amp;gt;data)-&amp;gt;status : 0;
		printk(&amp;quot;Set Tx power err: %d reason 0x%02x\n&amp;quot;, err, reason);
		return;
	}

	rp = (void *)rsp-&amp;gt;data;

	net_buf_unref(rsp);
}

static void get_tx_power(uint8_t handle_type, uint16_t handle, int8_t *tx_pwr_lvl)
{
	struct bt_hci_cp_vs_read_tx_power_level *cp;
	struct bt_hci_rp_vs_read_tx_power_level *rp;
	struct net_buf *buf, *rsp = NULL;
	int err;

	*tx_pwr_lvl = 0xFF;
	buf = bt_hci_cmd_create(BT_HCI_OP_VS_READ_TX_POWER_LEVEL,
				sizeof(*cp));
	if (!buf) {
		printk(&amp;quot;Unable to allocate command buffer\n&amp;quot;);
		return;
	}

	cp = net_buf_add(buf, sizeof(*cp));
	cp-&amp;gt;handle = sys_cpu_to_le16(handle);
	cp-&amp;gt;handle_type = handle_type;

	err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_TX_POWER_LEVEL,
				   buf, &amp;amp;rsp);
	if (err) {
		uint8_t reason = rsp ?
			((struct bt_hci_rp_vs_read_tx_power_level *)
			  rsp-&amp;gt;data)-&amp;gt;status : 0;
		printk(&amp;quot;Read Tx power err: %d reason 0x%02x\n&amp;quot;, err, reason);
		return;
	}

	rp = (void *)rsp-&amp;gt;data;
	*tx_pwr_lvl = rp-&amp;gt;tx_power_level;

	net_buf_unref(rsp);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When the application is running, I can see that it reports changes of the tx power:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-1442-gf527a81dcf35  ***                                                           
Starting Direction Finding periodic advertising Beacon Demo                                                           
Bluetooth initialization...success                                                                                    
Advertising set create...success                                                                                      
Update CTE params...success                                                                                           
Periodic advertising params set...success                                                                             
Enable CTE...success                                                                                                  
Periodic advertising enable...success                                                                                 
Extended advertising enable...success                                                                                 
Started extended advertising as FA:6B:09:33:B5:E6 (random)                                                            
Set Tx power level to -20                                                                                             
Get Tx power level -&amp;gt; TXP = -20                                                                                       
Set Tx power level to 8                                                                                               
Get Tx power level -&amp;gt; TXP = 8                                                                                         
Set Tx power level to -20                                                                                             
Get Tx power level -&amp;gt; TXP = -20                                                                                       
Set Tx power level to 8                                                                                               
Get Tx power level -&amp;gt; TXP = 8                                                                                         
Set Tx power level to -20                                                                                             
Get Tx power level -&amp;gt; TXP = -20                                                                                       
Set Tx power level to 8                                                                                               
Get Tx power level -&amp;gt; TXP = 8                                                                                         
Set Tx power level to -20                                                                                             
Get Tx power level -&amp;gt; TXP = -20                                                                                       
Set Tx power level to 8                                                                                               
Get Tx power level -&amp;gt; TXP = 8&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But using the &amp;quot;nRF Connect&amp;quot; application on an Android phone, I can&amp;#39;t see any noticeable changes at the measured RSSI.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;To ensure the problem is not from Android mobile&amp;#39;s side, I set the static tx power to the values same as what was used in the above code.&lt;/p&gt;
&lt;p&gt;First I&amp;#39;d set it to -20 dBm by using this config:&lt;/p&gt;
&lt;p&gt;prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;...
CONFIG_BT_CTLR_TX_PWR_MINUS_20=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then it was set to +8 dBm:&lt;/p&gt;
&lt;p&gt;prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;...
CONFIG_BT_CTLR_TX_PWR_PLUS_8=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Obviously, different values were reported for each of them by &amp;quot;nRF Connect&amp;quot; application.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Saleh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set "TX Power" of nRF52833, using Zephyr</title><link>https://devzone.nordicsemi.com/thread/339498?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 16:21:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:870e976c-95e2-4291-a3b0-5deeb1c1b0cd</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi, &lt;br /&gt;&lt;br /&gt;The DF samples hasn&amp;#39;t got enabled CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL by default. Could you check if you are able to control the TX power via Kconfig?&lt;/p&gt;
[quote user=""]But when &amp;quot;extended advertising&amp;quot; has enabled, the approach that has used in the above example doesn&amp;#39;t work[/quote]
&lt;p&gt;From an implementation perspective you should be able to use HCI commands to set the TX power both for extended and periodic advertising if enabled. If its still isn&amp;#39;t working, could you explain more in detail what have tried and what are you having problems with specifically? &lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>