<?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>Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59374/correct-best-way-to-implement-a-uart-serial-passthrough</link><description>Hello, the SDK example ble_peripheral\ble_app_uart includes the code below in order to forward data from the UART over the BLE. What it does is wait for a CRLF, or a certain amount of data, and then writes the data to the TX. 
 This isn&amp;#39;t exactly what</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Mar 2020 12:29:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59374/correct-best-way-to-implement-a-uart-serial-passthrough" /><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241121?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 12:29:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bb298d8-d6c1-48f6-a3b7-379679426c00</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sorry, I was missing an &amp;#39;S&amp;#39; in &lt;em&gt;BLE_GATT&lt;strong&gt;S&lt;/strong&gt;_EVT_HVN_TX_COMPLETE. T&lt;/em&gt;he event will be reported to all BLE observers/callbacks along with other BLE events such as&amp;nbsp;&lt;em&gt;BLE_GAP_EVT_CONNECTED&lt;/em&gt;. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241117?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 12:23:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7adc18d3-2b80-4d3a-8ea1-a3a9ad5a83d0</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Actually I don&amp;#39;t see&amp;nbsp;&lt;span&gt;BLE_GATT_EVT_HVN_TX_COMPLETE&amp;nbsp;defined in the SDK...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241116?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 12:20:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8cdbb008-8ae6-4390-a1ad-e6f2987609b9</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Hello, in which handler will the&amp;nbsp;BLE_GATT_EVT_HVN_TX_COMPLETE event occur?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241084?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:45:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02e5fd0d-178a-4023-a51a-0e4d167f294f</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Thanks, I&amp;#39;ll give it a shot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241082?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:44:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45afa243-d3bc-4703-9ad8-8d80b2134ca6</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes that should work as well.&amp;nbsp; I just didn&amp;#39;t think of using the event for that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241081?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:40:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:274967b3-d547-47ca-860d-6ed0c7d68ca7</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Pseudocode:&lt;/p&gt;
&lt;p&gt;bool sending = false;&lt;/p&gt;
&lt;p&gt;[receive data to send]&lt;/p&gt;
&lt;p&gt;* put data in buffer&lt;/p&gt;
&lt;p&gt;* if not sending, then send next BATCH characters and set sending=true&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;[&lt;span&gt;BLE_GATT_EVT_HVN_TX_COMPLETE]&lt;/p&gt;
&lt;p&gt;&lt;span&gt;* if more data in buffer send next BATCH characters&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;* else sending = false&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Doesn&amp;#39;t this take care of everything, variable data, no timers and no termination characters needed?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241080?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:29:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12f04a7f-232a-446c-bbfb-7a190c81de14</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;Oh... well can&amp;#39;t this event be used instead of my aforementioned timer, with minimal latency?&amp;nbsp; Every time that fires, if there is more pending data, then send the next batch?&amp;nbsp; You would never need a termination character.&amp;nbsp; Or would that not work for some reason?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241075?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:26:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70565f21-b1fd-42ba-9bd4-7a1b865d5871</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sorry, I&amp;#39;m not sure I understand the question. Are you referring to the ble_nus_data_send() function used to send data over BLE? You will get a &amp;#39;BLE_GATT_EVT_HVN_TX_COMPLETE event when one or more queued notifications has been sent: &lt;span&gt;&lt;a title="GATTS Handle Value Notification" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.0.1/group___b_l_e___g_a_t_t_s___h_v_n___m_s_c.html"&gt;GATTS Handle Value Notification&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241070?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:14:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f02b23a-29d8-431b-83a2-03fdef9f685d</guid><dc:creator>riceman0</dc:creator><description>&lt;p&gt;I think if there was some sort of event that indicated that a send was *complete* and that the tx is ready to be loaded with new characters would eliminate the need for a timer, and eliminate the latency, wouldn&amp;#39;t it?&amp;nbsp; Is there a reason the SDK doesn&amp;#39;t provide this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct/best way to implement a UART-serial passthrough?</title><link>https://devzone.nordicsemi.com/thread/241068?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 10:11:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1f9a340-3918-4ad6-b7f6-de9f346da153</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The Softdevice can fit 3 notification packets in the output queue by default, so it fills up rather fast if you send small packets instead of buffering the data until it reaches &amp;quot;m_ble_nus_max_data_len&amp;quot;. Without any termination characters and with variable packet length I don&amp;#39;t see any other option than using a timer as you already suggested. There is a tradeoff between latency and throughput.&lt;/p&gt;
&lt;p&gt;1. I made something similar to this a while ago. You may review it here: &lt;a href="https://devzone.nordicsemi.com/support-private/support/231178#permalink=476233"&gt;https://devzone.nordicsemi.com/support-private/support/231178#permalink=476233&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;2. APP_UART_DATA_READY is triggered per byte that is received.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>