<?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 tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83363/set-tx-power-with-tx-power-service-on-zephyr</link><description>hello Nordic 
 
 i am using nrf52840, with zephyr 
 i wish to use the nrfConnect Tx power service to read and to SET my Tx power 
 but in ncs in zephyr/subsys/bluetooth/services/tps.c i see implementation only for &amp;quot;read_tx_power_level&amp;quot; 
 does it mean</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 02 Feb 2022 10:19:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83363/set-tx-power-with-tx-power-service-on-zephyr" /><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/350820?ContentTypeID=1</link><pubDate>Wed, 02 Feb 2022 10:19:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d28233a6-af30-42ed-accd-12187b832d19</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi&lt;/p&gt;
&lt;p&gt;i will open a new thread on the ncs update&amp;nbsp; (wish i would have done that 10 days ago)&lt;/p&gt;
&lt;p&gt;currently the &amp;#39;&lt;span&gt;set_tx_power()&amp;#39; does not work for me&amp;nbsp;but i moved to work on something else for the moment .. once the issue will be solved i will close this thread with the solution&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Ziv&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/350710?ContentTypeID=1</link><pubDate>Tue, 01 Feb 2022 14:30:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3888726-1613-47a5-ad53-a24086c301f9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="ziv123"]&lt;p&gt;seems that moving to ncs 1.8 forces me to update to zephyr-sdk-0.13.2 (from 0.12.4)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;is it really a must or am i missing something ?&lt;/p&gt;[/quote]
&lt;p&gt;I&amp;#39;m not sure about this, I&amp;#39;m running Windows, so the Zephyr SDK is not available for my platform. What is forcing you to do this updat?&lt;/p&gt;
[quote user="ziv123"]&lt;p&gt;also, seems that when moving to the new zephyr sdk i have a problem with the dfu (based on the smp service), i use the nrfConnect for the dfu and it seems like its done ok but then after reset the version remains the old version. any ideas on why is that, maybe i need to change some configs ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;do i also need to update the MCUBoot or/and the bootloader version for this to work ?&lt;/p&gt;[/quote]
&lt;p&gt;I would recommend you to post this issue in a new ticket, as it is off topic for this thread. That way, you will also get help from someone more knowledgeable about this topic than me.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/349078?ContentTypeID=1</link><pubDate>Sun, 23 Jan 2022 07:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2837dbb-68c7-4ed8-a454-997751f7f3e7</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi&lt;/p&gt;
&lt;p&gt;seems that moving to ncs 1.8 forces me to update to zephyr-sdk-0.13.2 (from 0.12.4)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;is it really a must or am i missing something ?&lt;/p&gt;
&lt;p&gt;also, seems that when moving to the new zephyr sdk i have a problem with the dfu (based on the smp service), i use the nrfConnect for the dfu and it seems like its done ok but then after reset the version remains the old version. any ideas on why is that, maybe i need to change some configs ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;do i also need to update the MCUBoot or/and the bootloader version for this to work ?&lt;/p&gt;
&lt;p&gt;hope to read from you soon&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/349036?ContentTypeID=1</link><pubDate>Fri, 21 Jan 2022 23:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47ef4288-0b2d-4c51-9871-c6e31aa12099</guid><dc:creator>John</dc:creator><description>&lt;p&gt;When you start using SDK V18, I&amp;#39;ve learned that you need to create the advertising packet before you are allowed to change the power.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/348378?ContentTypeID=1</link><pubDate>Tue, 18 Jan 2022 18:19:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13d53ecb-d442-45e7-b85e-39a61efc0a8f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;0xFC0E&amp;nbsp;is the opcode of&amp;nbsp;BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL. As you can see from the &lt;a href="https://docs.zephyrproject.org/apidoc/latest/hci__vs_8h.html#a29b5fda3541bfd8d69db72e46688d180"&gt;HCI VS API&lt;/a&gt;, this is defined as &lt;a href="https://www.wolframalpha.com/input/?i=%280x000E%29+%7C+%280x3F+%3C%3C+10%29"&gt;((0x000E) | ((0x3F) &amp;lt;&amp;lt; 10))&lt;/a&gt;&amp;nbsp;= 0xFC0E.&amp;nbsp;&lt;/span&gt;&lt;span&gt;As far as I can see, status code 0x42 means&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/apidoc/latest/hci__err_8h.html#a7646bc91f5dbb28c5eeda7e1828f2e30"&gt;BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I tested you code and configs together with the peripheral_lbs example in NCS v1.8.0, and the TX power seems to be changed correctly with the latest addition (actually only &amp;quot;CONFIG_BT_LL_SW_SPLIT=y&amp;quot; is need in my test). Verified that the RSSI is significantly lower with TX output power set to -40 through&amp;nbsp;set_tx_power().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It looks like you are using an older version, can you try with NCS v1.8.0?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/347863?ContentTypeID=1</link><pubDate>Sat, 15 Jan 2022 09:55:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1236163a-97bf-4884-af25-ba8b4c30289a</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Jorgen&lt;/p&gt;
&lt;p&gt;is this on research or something ?&lt;/p&gt;
&lt;p&gt;i have posted a replay more the 5 days ago, re-posted an edited&amp;nbsp;the replay 3 days ago and no replay&lt;/p&gt;
&lt;p&gt;hope to read from you soon&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/347466?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 19:05:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3596b6d4-449e-4cb5-970e-fb5c86c31eb8</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Jorgen&lt;/p&gt;
&lt;p&gt;i am using &amp;quot;Zephyr version: 2.6.99 (/home..), build: v2.6.99-ncs1-1&lt;/p&gt;
&lt;p&gt;i tried to use the implementation of the set_tx_power from the hci_pwr_ctrl example in my code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;{
    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) 
    {
		LOG_ERR(&amp;quot;Unable to allocate command buffer %d&amp;quot;, 0);
		return;
	}
    LOG_INF(&amp;quot;in TX_POWER INIT BUFFER CREATED %d&amp;quot;, 0);
	cp = net_buf_add(buf, sizeof(*cp));
	cp-&amp;gt;handle = sys_cpu_to_le16(0);
	cp-&amp;gt;handle_type = BT_HCI_VS_LL_HANDLE_TYPE_ADV;
    cp-&amp;gt;tx_power_level = 4;

    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;
		LOG_ERR(&amp;quot;Set Tx power err: %d reason 0x%02x\n&amp;quot;, err, reason);
		return;
	}

	rp = (void *)rsp-&amp;gt;data;
	LOG_INF(&amp;quot;Actual Tx Power: %d\n&amp;quot;, rp-&amp;gt;selected_tx_power);

    net_buf_unref(rsp);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;my prf.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# BLE Related Configs
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME=&amp;quot;TX_PWR_Canary&amp;quot;
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=n
CONFIG_BT_DIS_MODEL=&amp;quot;Canary&amp;quot;
CONFIG_BT_DIS_MANUF=&amp;quot;Augury Inc.&amp;quot;
CONFIG_BT_DIS_SERIAL_NUMBER=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_SW_REV=n
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
CONFIG_BT_CTLR_TX_PWR_MINUS_20=y

# Below is setup to let DIS information be read from settings
CONFIG_SETTINGS_RUNTIME=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NONE=y
CONFIG_BT_SETTINGS=y
CONFIG_BT_DIS_SETTINGS=y
CONFIG_BT_DIS_STR_MAX=50
CONFIG_BT_GATT_CACHING=n
CONFIG_BT_HCI_VS_EXT=y


# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;strangely i got an error that i could not find in the my ncs directory&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;lt;wrn&amp;gt; bt_hci_core: opcode 0xfc0e status 0x42&amp;quot; what does this error mean, (also why the use of opcode 0xFC0E which is not if i understand for production tests) ?&lt;/p&gt;
&lt;p&gt;and the &amp;quot;bt_hci_cmd_send_sync(..) returns err num -5, with reason 0x00&lt;/p&gt;
&lt;p&gt;if i add the following to my prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_MAIN_STACK_SIZE=2048
CONFIG_BT_LL_SOFTDEVICE=n
CONFIG_BT_LL_SW_SPLIT=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;then i get success from the function but in fact the tx_power does not change at all, not in advertising and not in connection&lt;/p&gt;
&lt;p&gt;would be happy to understand what does the stack size and the sw split configs contribute, and also what am i missing or doing wrong that prevent the change to the tx power (stays on default &amp;#39;0&amp;#39; all the time)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;also i wonder why setting CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y, in the prj.conf, prevent&amp;nbsp; using the&amp;nbsp;effect of&amp;nbsp; CONFIG_BT_CTLR_TX_PWR_MINUS_20=y,&amp;nbsp; for example ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;hope to read from you soon, i actually re-edit and re-entered my replay since i did not see any message indication that my replay was received and.. i hope i get some now&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/346540?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 15:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26ed234b-e209-431f-a94b-dc4bfa01ce02</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="ziv123"]i saw there is&amp;nbsp;an example in zephyr/samples/bluetooth/hci_pwr_ctrl , i wanted to make sure&amp;nbsp;i understand it right then .. is it just for the nrf52840 peripheral side and it is actually not showing how to set the tx power from&amp;nbsp;a central side, after connection has been established and the nrf52840 peripheral is configured to by it self try save on tx power via the analysing of the RSSI ?[/quote]
&lt;p&gt;Yes, that is correct.&lt;/p&gt;
[quote user="ziv123"]is it actually possible to change the tx power within an already established ble connection via&amp;nbsp;some custom service[/quote]
&lt;p&gt;Yes, you you create a custom service, you can change the TX power when the set TX power characteristics is written, just like the sample changes the power dynamically based on RSSI.&lt;/p&gt;
[quote user="ziv123"]is there some service that already contain this feature?[/quote]
&lt;p&gt;I&amp;#39;m not aware of any such service, but you can follow &amp;quot;&lt;a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/getting-started/posts/ncs-ble-tutorial-part-1-custom-service-in-peripheral-role"&gt;nRF Connect SDK Bluetooth Low Energy tutorial part 1: Custom Service in Peripheral role&lt;/a&gt;&amp;quot; to create your own custom service in nRF Connect SDK.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/346411?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 10:25:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aed8aa3b-e841-4259-92a0-32ab5f5dbd24</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;Hi Jorgen&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i saw there is&amp;nbsp;an example in zephyr/samples/bluetooth/hci_pwr_ctrl , i wanted to make sure&amp;nbsp;i understand it right then .. is it just for the nrf52840 peripheral side and it is actually not showing how to set the tx power from&amp;nbsp;a central side, after connection has been established and the nrf52840 peripheral is configured to by it self try save on tx power via the analysing of the RSSI ?&lt;/p&gt;
&lt;p&gt;is it actually possible to change the tx power within an already established ble connection via&amp;nbsp;some custom service (is there some service that already contain this feature? ) ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;hope to read from you soon&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: set tx power with tx power service on zephyr</title><link>https://devzone.nordicsemi.com/thread/346088?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 09:47:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5a645db-04f6-4197-a2d0-44fa590c0491</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The Tx Power Service (TPS) is a Bluetooth defined service, you can find the specification on &lt;a href="https://www.bluetooth.com/specifications/specs/tx-power-service-1-0/"&gt;this page&lt;/a&gt;. If you look at chapter 3 of the specification, you can see that only Read property is mandatory, while other properties are marked&amp;nbsp;‘X’ (excluded/not permitted).&lt;/p&gt;
&lt;p&gt;If you want to set the TX power, you need to create a custom service for this.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>