<?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>BLE questions characteristics</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80443/ble-questions-characteristics</link><description>Hi, 
 I&amp;#39;m using nrf52840 and connect to a PC with BLE, using Nordic Uart Service (Rx and Tx characteristics). 
 When sending messages, I need to know how much data I&amp;#39;m writing to the characteristics and how fast. Can you please tell me how can I know</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Oct 2021 10:53:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80443/ble-questions-characteristics" /><item><title>RE: BLE questions characteristics</title><link>https://devzone.nordicsemi.com/thread/333455?ContentTypeID=1</link><pubDate>Mon, 11 Oct 2021 10:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e576f01-cafa-42d7-b33e-38fb42004975</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Notifications are used by the server to send data instantly to the client, while write and write_wo_resp is used by the client to send data to the server.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The difference between write and write_wo_resp is that the first is a request, while the second is a command. Requests need to be replied to from the application, which makes them slower, so normally write_wo_resp is used.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The terms &amp;quot;TX&amp;quot; and &amp;quot;RX&amp;quot; characteristic are a bit misleading, but makes sense if you look at it from the server (peripheral) side.&amp;nbsp;&lt;br /&gt;When the server sends notifications to the client it is using the TX characteristic, while data coming from the client to the server is handled by the RX characteristic.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE questions characteristics</title><link>https://devzone.nordicsemi.com/thread/333277?ContentTypeID=1</link><pubDate>Fri, 08 Oct 2021 13:14:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d839988-2fc6-4290-9b98-18cd3eefb7d4</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Thanks you very much!&lt;/p&gt;
&lt;p&gt;I have another question regarding&amp;nbsp;ble_gatt_char_props_t.&lt;/p&gt;
&lt;p&gt;I can see that Tx characteristic defines notification only, but Rx defines&amp;nbsp;write and&amp;nbsp;write_wo_resp. Does it mean that the other sides has the permissions to write to the Rx, so I will be able to read the bytes?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE questions characteristics</title><link>https://devzone.nordicsemi.com/thread/333247?ContentTypeID=1</link><pubDate>Fri, 08 Oct 2021 11:40:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72bd06d0-087a-46db-9d08-5239dc2f065e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
[quote user=""]When sending messages, I need to know how much data I&amp;#39;m writing to the characteristics and how fast. Can you please tell me how can I know that?[/quote]
&lt;p&gt;I assume you mean you want to know how much data you are writing over time?&lt;/p&gt;
&lt;p&gt;One way to do this is to just update a counter value each time you call the&amp;nbsp;ble_nus_data_send(..) function, and then read and clear the counter value at a fixed rate (using an app_timer callback for instance).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you check the counter value every second you can directly convert it to a KB/s reading.&amp;nbsp;&lt;/p&gt;
[quote user=""]In addition - how can I know if I am using Notifications and Indications?[/quote]
&lt;p&gt;The NUS service supports Notifications only, and will never use Indications.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you check the implementation of the ble_nus_data_send() function in ble_nus.c you can see how this is configured when sending data:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

hvx_params.handle = p_nus-&amp;gt;tx_handles.value_handle;
hvx_params.p_data = p_data;
hvx_params.p_len  = p_length;
hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;

return sd_ble_gatts_hvx(conn_handle, &amp;amp;hvx_params);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The reason Indications is not supported is that the NUS TX characteristic is configured with the notify property only, as shown in the ble_nus_init() function in ble_nus.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Add the TX Characteristic.
/**@snippet [Adding proprietary characteristic to the SoftDevice] */
memset(&amp;amp;add_char_params, 0, sizeof(add_char_params));
add_char_params.uuid              = BLE_UUID_NUS_TX_CHARACTERISTIC;
add_char_params.uuid_type         = p_nus-&amp;gt;uuid_type;
add_char_params.max_len           = BLE_NUS_MAX_TX_CHAR_LEN;
add_char_params.init_len          = sizeof(uint8_t);
add_char_params.is_var_len        = true;
add_char_params.char_props.notify = 1;

add_char_params.read_access       = SEC_OPEN;
add_char_params.write_access      = SEC_OPEN;
add_char_params.cccd_write_access = SEC_OPEN;

return characteristic_add(p_nus-&amp;gt;service_handle, &amp;amp;add_char_params, &amp;amp;p_nus-&amp;gt;tx_handles);
/**@snippet [Adding proprietary characteristic to the SoftDevice] */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>