<?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>Tx power level change not reflected in Tx Power Service</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66016/tx-power-level-change-not-reflected-in-tx-power-service</link><description>I am changing the Tx power successfully with sd_ble_gap_tx_power_set(). I can see the RSSI value change Nordic Connect to confirm that it really is changing. But I also have the TX Power Service enabled and do not see the power level updating in its characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 20 Sep 2020 15:54:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66016/tx-power-level-change-not-reflected-in-tx-power-service" /><item><title>RE: Tx power level change not reflected in Tx Power Service</title><link>https://devzone.nordicsemi.com/thread/270427?ContentTypeID=1</link><pubDate>Sun, 20 Sep 2020 15:54:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cedaeac1-a36a-4a04-9e83-1d2e7fbd7bc6</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I was not aware, but this sounds like a reasonable workaround yes, you can also set the&amp;nbsp;m_tps.conn_handle = BLE_CONN_HANDLE_INVALID; on the&amp;nbsp;BLE_GAP_EVT_DISCONNECTED event if you want.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Tx power level change not reflected in Tx Power Service</title><link>https://devzone.nordicsemi.com/thread/270215?ContentTypeID=1</link><pubDate>Fri, 18 Sep 2020 06:16:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39c5a72f-1570-47d9-838d-a099282b8d0d</guid><dc:creator>Saxman58</dc:creator><description>&lt;p&gt;You are right.&amp;nbsp; It was returning a BLE_ERROR_INVALID_CONN_HANDLE.&amp;nbsp; This was happening when I changed the power level when unconnected.&lt;br /&gt;&lt;br /&gt;I see that other services prevent this problem by either setting the conn_handle to&amp;nbsp;&lt;span&gt;BLE_CONN_HANDLE_INVALID&lt;/span&gt; in their service init routine, or they call sd_ble_gatts_value_set() with a first parameter of&amp;nbsp;&lt;span&gt;BLE_CONN_HANDLE_INVALID rather than the current service conn_handle.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For example, the Blood Pressure Service init looks like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_bps_init(ble_bps_t * p_bps, ble_bps_init_t const * p_bps_init)
{
...

    p_bps-&amp;gt;conn_handle = BLE_CONN_HANDLE_INVALID;
...
}
&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-left:30px;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The Battery Service takes the other approach in their wrapper around sd_ble_gatts_value_set():&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t ble_bas_battery_level_update(ble_bas_t * p_bas,
                                        uint8_t     battery_level,
                                        uint16_t    conn_handle)
{
    ...
    
    if (battery_level != p_bas-&amp;gt;battery_level_last)
    {
        ...
        
        // Update database.
        err_code = sd_ble_gatts_value_set(BLE_CONN_HANDLE_INVALID,
                                          p_bas-&amp;gt;battery_level_handles.value_handle,
                                          &amp;amp;gatts_value);
    ...
}&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;&lt;span&gt;The Tx Power Level Service ble_tps.c library code does neither, so an error is thrown when setting without a connection.&amp;nbsp; Should the library code be more like the others?&amp;nbsp; My workaround is to set the conn_handle after calling the library ble_tps_init() function:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    err_code = ble_tps_init(&amp;amp;m_tps, &amp;amp;tps_init_obj);
    m_tps.conn_handle = BLE_CONN_HANDLE_INVALID;
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;And when it is connected, setting the gatt value through&amp;nbsp;&lt;span&gt;ble_tps_tx_power_level_set() is indeed reflected in the value the host sees.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Tx power level change not reflected in Tx Power Service</title><link>https://devzone.nordicsemi.com/thread/270065?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 11:51:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:928b83f0-b136-4c35-8dbd-b4b6b73ec6dc</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I suspect that&amp;nbsp;&lt;span&gt;ble_tps_tx_power_level_set() is returning an error code here, and that the error check by&amp;nbsp;APP_ERROR_CHECK() cause the application to assert to the fault handler. It would be good if you can find the error code from&amp;nbsp;ble_tps_tx_power_level_set(). The&amp;nbsp;ble_tps_tx_power_level_set() is basically a wrapper around sd_ble_gatts_value_set(), so I guess it is one of the listed errors:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga2760c51ea71853bd74e2e7e7117ef52a"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga2760c51ea71853bd74e2e7e7117ef52a&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>