<?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>In &amp;#39;peripheral_uart&amp;#39;, where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107247/in-peripheral_uart-where-does-the-ble-tx-data-go</link><description>I am confused about where the data sen to the output of the &amp;#39;peripheral_uart&amp;#39; (Tx) goes when one uses the Serial Terminal to type in text. Eventually, I want to be able to send advertising data that my device receives to my iPhone and I thought that what</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Jan 2024 07:17:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107247/in-peripheral_uart-where-does-the-ble-tx-data-go" /><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/464298?ContentTypeID=1</link><pubDate>Tue, 16 Jan 2024 07:17:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50e4bd7e-95d0-4c45-8aa7-545f3c6cc3e1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;You need to use the bt_nus_send() function if you wish to send BLE notifications to the phone. The uart_tx() function&amp;nbsp;is&amp;nbsp;from the UART driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/464266?ContentTypeID=1</link><pubDate>Mon, 15 Jan 2024 17:46:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3a14a78-7017-445f-a035-0947c246fb70</guid><dc:creator>Sheldon01</dc:creator><description>&lt;p&gt;I just realized that the code I have been modifying (lesson 4 exercise 3) is supposed to be sending it to the terminal (based on the comment on the code). &amp;nbsp;I am interrupting that data and chaining it to my text. &amp;nbsp;Now I need to figure out how to interrupt the reception of data from the terminal and allow my data to be sent out instead.&lt;pre class="ui-code" data-mode="text"&gt;static void bt_receive_cb(struct bt_conn *conn, const uint8_t *const data, uint16_t len)
{
	int err;
	char addr[BT_ADDR_LE_STR_LEN] = { 0 };

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, ARRAY_SIZE(addr));

	LOG_INF(&amp;quot;Received data from: %s&amp;quot;, addr);

	for (uint16_t pos = 0; pos != len;) {
		struct uart_data_t *tx = k_malloc(sizeof(*tx));

		if (!tx) {
			LOG_WRN(&amp;quot;Not able to allocate UART send data buffer&amp;quot;);
			return;
		}

		/* Keep the last byte of TX buffer for potential LF char. */
		size_t tx_data_size = sizeof(tx-&amp;gt;data) - 1;

		if ((len - pos) &amp;gt; tx_data_size) {
			tx-&amp;gt;len = tx_data_size;
		} else {
			tx-&amp;gt;len = (len - pos);
		}

		memcpy(tx-&amp;gt;data, &amp;amp;data[pos], tx-&amp;gt;len);

		pos += tx-&amp;gt;len;

		/* Append the LF character when the CR character triggered
		 * transmission from the peer.
		 */
		if ((pos == len) &amp;amp;&amp;amp; (data[len - 1] == &amp;#39;\r&amp;#39;)) {
			tx-&amp;gt;data[tx-&amp;gt;len] = &amp;#39;\n&amp;#39;;
			tx-&amp;gt;len++;
		}
		/* STEP 8.3 - Forward the data received over Bluetooth LE to the UART peripheral */
		err = uart_tx(uart, tx-&amp;gt;data, tx-&amp;gt;len, SYS_FOREVER_MS);
		if (err) {
			k_fifo_put(&amp;amp;fifo_uart_tx_data, tx);
		}
	}
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/464263?ContentTypeID=1</link><pubDate>Mon, 15 Jan 2024 17:35:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97e8a60f-f7b4-44e0-b513-c003d6287370</guid><dc:creator>Sheldon01</dc:creator><description>&lt;p&gt;I am now triggering of the reception of the matched scan. &amp;nbsp;That is working well. &amp;nbsp;I send my data out but it does not go where I want it to go. &amp;nbsp;It goes to the Terminal on my computer. &amp;nbsp;I do not want it there! &amp;nbsp;I want it to go to the Norid_UART_Service on my iPhone. &amp;nbsp;I don&amp;#39;t understand how it could be possibly going the terminal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/464145?ContentTypeID=1</link><pubDate>Mon, 15 Jan 2024 11:22:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:377cca61-186a-41be-bbe1-7322c9b453ee</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;As mentioned in the other ticket, you can use the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.1/nrf/libraries/bluetooth_services/services/nus.html#c.bt_nus_send"&gt;bt_nus_send()&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;function to send your data.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463843?ContentTypeID=1</link><pubDate>Thu, 11 Jan 2024 16:45:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebff6dce-4681-4e8d-9537-42d714b1147a</guid><dc:creator>Sheldon01</dc:creator><description>&lt;p&gt;Yes, it was a great place to start. &amp;nbsp;I&amp;#39;m almost done. &amp;nbsp;I&amp;nbsp;have just a few things left. &amp;nbsp;The current problem is that I want to send data out on the UART when advertising matches my filter. &amp;nbsp;Currently it only sends out UART data when it receives data as a trigger.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463831?ContentTypeID=1</link><pubDate>Thu, 11 Jan 2024 16:16:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e10934c-9526-4119-b419-c6fb7f11bf89</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I see. Yes, the serial port emulation demonstrated by this sample might not exactly match your use case. However, I still believe the sample could be a good starting point for your requirements&amp;nbsp;as it should be relatively easy to modify. You can modify&amp;nbsp;the application so that it doesn&amp;#39;t just blindly relay data received on the UART interface (or remove the UART&amp;nbsp;com. &lt;span&gt;altogether&lt;/span&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463812?ContentTypeID=1</link><pubDate>Thu, 11 Jan 2024 15:22:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f22d941-24b5-4172-a2c0-35e7b85a6974</guid><dc:creator>Sheldon01</dc:creator><description>&lt;p&gt;Yes, I am seeing the messages from my serial terminal in the iOS toolbox log. &amp;nbsp;But, that is not what I am trying to see (this is the BLE Rx signal). &amp;nbsp;I was expecting to see the Tx output there (but it is what is going into the BLE Rx). &amp;nbsp;The only place I see the BLE Tx output is on the terminal of my computer. &amp;nbsp;I guess that is good enough for me. &amp;nbsp;I was hoping to see on my iPhone screen somewhere.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463575?ContentTypeID=1</link><pubDate>Wed, 10 Jan 2024 14:13:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87783ebf-dcff-4cd8-a4b9-4a370c07e0e6</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for the clarification. But are you not seeing the messages sent from the serial terminal in your iOS toolbox log?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704895991321v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704896024800v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463574?ContentTypeID=1</link><pubDate>Wed, 10 Jan 2024 14:05:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58a564af-7de4-47d3-acb7-63f1813cb980</guid><dc:creator>Sheldon01</dc:creator><description>&lt;p&gt;On my computer (using the Serial Terminal (v1.20)), when I type in something in the &amp;quot;Type and press enter to send&amp;quot; box and then hit return it only prints what I sent (in green on the terminal). &amp;nbsp;I don&amp;#39;t think it ever makes it to my Bluetooth Rx input. &amp;nbsp;The only way I can see anything from the output of the Bluetooth (on the terminal in Windows) is to send a preset on my iPhone (like you described). &amp;nbsp;I would have thought a command I send from the Serial Terminal on my computer would do the same thing that I see when I send a Command (like your &amp;quot;Hello&amp;quot; from the iPhone) but it doesn&amp;#39;t.&lt;/p&gt;
&lt;p&gt;At least have the one part working so and I can continue. &amp;nbsp;Now I just need to figure out how to send my data instead of a scrambled (done on purpose on the nRF chip) test message.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Sheldon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463558?ContentTypeID=1</link><pubDate>Wed, 10 Jan 2024 13:21:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87495a9f-01c5-4a99-97c5-67e92299440f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Sheldon,&lt;/p&gt;
&lt;p&gt;Thank you for the update. Yes, the&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.1/nrf/samples/bluetooth/peripheral_uart/README.html"&gt;&amp;nbsp;Peripheral UART&lt;/a&gt;&amp;nbsp;sample is configured to relay any data it receives on&amp;nbsp;its UART RX input to the connected BLE device (your iPhone in this case). Similarly, it will output any data&amp;nbsp;receives from the connected Bluetooth central to the UART TX output and the terminal.&lt;/p&gt;
[quote user=""]When I type something into the serial terminal I see that it makes it to my iPhone (it is in green text) followed by a &amp;quot;received&amp;quot; message. &amp;nbsp;But this, now I think, is just what is coming in (what the Rx would see). &amp;nbsp;Where is the Bluetooth Tx output?[/quote]
&lt;p&gt;To send the data in the other direction (i..e, from the phone), you can create Create a preset in the nRF Toolbox app for the command you want to send as I have tried to&amp;nbsp;show below.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704892445459v3.png" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704892477982v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When pressing the &amp;#39;1&amp;#39; button in the above example, the text string &amp;quot;Hello&amp;quot; should be sent from the iPhone to the peripheral and then printed out on the serial terminal.&lt;/span&gt;&lt;/p&gt;
[quote user="Sheldon01"]&lt;p&gt;I enter on the terminal don&amp;#39;t go the Bluetooth Rx input (or at least I never see them coming out on the terminal in &amp;#39;non-green&amp;#39; form.&lt;/p&gt;
&lt;p&gt;Sheldon&lt;/p&gt;[/quote]
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Are you referring to the log in the phone app?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In 'peripheral_uart', where does the BLE Tx data go?</title><link>https://devzone.nordicsemi.com/thread/463556?ContentTypeID=1</link><pubDate>Wed, 10 Jan 2024 13:16:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf15f126-9c27-4a63-bd02-c686ab3fd0b1</guid><dc:creator>Sheldon01</dc:creator><description>&lt;p&gt;There&amp;#39;s nothing like answering your own question...&lt;/p&gt;
&lt;p&gt;I think I have it figured out. &amp;nbsp;The output goes to the Terminal (on the computer). &amp;nbsp;If I send text using a &amp;#39;preset&amp;#39; value in the UART (from the nRF Toolbox on my iPhone) and scramble it up (just for a test) I can see the result on the Terminal on my computer. &amp;nbsp;When I type something on the Terminal, however, it doesn&amp;#39;t get to the Bluetooth chip (not that I can tell). &amp;nbsp;It prints the unaltered value in green on the display. &amp;nbsp;I don&amp;#39;t understand why things I enter on the terminal don&amp;#39;t go the Bluetooth Rx input (or at least I never see them coming out on the terminal in &amp;#39;non-green&amp;#39; form.&lt;/p&gt;
&lt;p&gt;Sheldon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>