<?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 large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76363/ble-large-write-turns-to-gibberish</link><description>Greetings! 
 
 I have a central that&amp;#39;s writing BLE messages to a peripheral. The characteristic on the peripheral is a 32-byte array, and my experiment is to write 32 bytes from the Central to the Peripheral without extending the Data Length, but only</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Jun 2021 15:00:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76363/ble-large-write-turns-to-gibberish" /><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/317057?ContentTypeID=1</link><pubDate>Thu, 24 Jun 2021 15:00:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f3f8743-44d0-4f15-8f26-a9be3ac5d051</guid><dc:creator>Jonas Lien</dc:creator><description>&lt;p&gt;Thanks for your reply Susheel.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I get what you&amp;#39;re saying about the offset, but I don&amp;#39;t see you using it in your loop function, same as me. What i call buffer[i] you call ptr[i], and there is no relation to the offset other than the first print?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since you manage to get it running, I&amp;#39;ll see tomorrow if I&amp;#39;ve done something else to not make mine run correctly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jonas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/316969?ContentTypeID=1</link><pubDate>Thu, 24 Jun 2021 11:54:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:318ec7f9-7b01-4f25-b00d-d6e4b53384e2</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It works as it should. Offset is normally seen as a hint on the receiver side to note that if offset != 0 then this transaction is the continuation of the previous data sent (long/reliable writes)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/316968?ContentTypeID=1</link><pubDate>Thu, 24 Jun 2021 11:54:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07abd59b-2757-4b15-a7ac-1b1ee6c72aa8</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I did a quick test on UART_Peripheral and UART_Central examples on NCS v 1.5.1.which your config changes set into proj.conf on both devices&lt;/p&gt;
&lt;p&gt;I see that the following output&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:07.010,070] &#x1B;[0m&amp;lt;inf&amp;gt; peripheral_uart: Bluetooth initialized&#x1B;[0m
Starting Nordic UART service example
[00:00:07.443,695] &#x1B;[0m&amp;lt;inf&amp;gt; peripheral_uart: Connected E9:A8:9F:95:91:83 (random)&#x1B;[0m
[00:00:07.745,269] &#x1B;[0m&amp;lt;inf&amp;gt; peripheral_uart: Security changed: E9:A8:9F:95:91:83 (random) level 2&#x1B;[0m
[00:00:09.044,982] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: Received data, Offet = 0X0 : BLE Msg:&#x1B;[0m
[00:00:09.045,013] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 01  &#x1B;[0m
[00:00:09.045,013] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 02  &#x1B;[0m
[00:00:09.045,013] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 03  &#x1B;[0m
[00:00:09.045,043] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 04  &#x1B;[0m
[00:00:09.045,043] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 05  &#x1B;[0m
[00:00:09.045,043] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 06  &#x1B;[0m
[00:00:09.045,043] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 07  &#x1B;[0m
[00:00:09.045,043] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 08  &#x1B;[0m
[00:00:09.045,074] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 09  &#x1B;[0m
[00:00:09.045,104] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 0a  &#x1B;[0m
[00:00:09.045,104] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 0b  &#x1B;[0m
[00:00:09.045,104] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 0c  &#x1B;[0m
[00:00:09.045,104] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 0d  &#x1B;[0m
[00:00:09.045,135] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 0e  &#x1B;[0m
[00:00:09.045,135] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 0f  &#x1B;[0m
[00:00:09.045,135] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 10  &#x1B;[0m
[00:00:09.045,135] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 11  &#x1B;[0m
[00:00:09.045,135] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 12  &#x1B;[0m
[00:00:09.045,166] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 
&#x1B;[0m
[00:00:09.045,288] &#x1B;[0m&amp;lt;inf&amp;gt; peripheral_uart: Received data from: E9:A8:9F:95:91:83 (random)&#x1B;[0m
[00:00:09.045,349] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: Received data, Offet = 0X12 : BLE Msg:&#x1B;[0m
[00:00:09.045,379] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 13  &#x1B;[0m
[00:00:09.045,379] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 14  &#x1B;[0m
[00:00:09.045,379] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 15  &#x1B;[0m
[00:00:09.045,379] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 16  &#x1B;[0m
[00:00:09.045,410] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 17  &#x1B;[0m
[00:00:09.045,410] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 18  &#x1B;[0m
[00:00:09.045,410] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 19  &#x1B;[0m
[00:00:09.045,410] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 1a  &#x1B;[0m
[00:00:09.045,440] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 1b  &#x1B;[0m
[00:00:09.045,440] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 1c  &#x1B;[0m
[00:00:09.045,440] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 1d  &#x1B;[0m
[00:00:09.045,440] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 1e  &#x1B;[0m
[00:00:09.045,440] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 1f  &#x1B;[0m
[00:00:09.045,471] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 20  &#x1B;[0m
[00:00:09.045,471] &#x1B;[0m&amp;lt;inf&amp;gt; bt_nus: 
&#x1B;[0m&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Changes on the peripheral side nus.c-&amp;gt;on_receive&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ssize_t on_receive(struct bt_conn *conn,
			  const struct bt_gatt_attr *attr,
			  const void *buf,
			  uint16_t len,
			  uint16_t offset,
			  uint8_t flags)
{
	uint8_t *ptr = (uint8_t *)buf;
        LOG_INF(&amp;quot;Received data, Offet = 0X%x : BLE Msg:&amp;quot;, offset);

        for(uint8_t i = 0; i&amp;lt;len; i++)
        {
          LOG_INF(&amp;quot;%02x  &amp;quot;, ptr[i]);
        }
        LOG_INF(&amp;quot;\n&amp;quot;);

	if (nus_cb.received) {
		nus_cb.received(conn, buf, len);
}
	return len;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Changes on the central side, main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint8_t write_test_data[32] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                                0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
                                0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
                                0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
                              };

void main(void)
{
	int err;

	err = bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
	if (err) {
		LOG_ERR(&amp;quot;Failed to register authorization callbacks.&amp;quot;);
		return;
	}

	err = bt_enable(NULL);
	if (err) {
		LOG_ERR(&amp;quot;Bluetooth init failed (err %d)&amp;quot;, err);
		return;
	}
	LOG_INF(&amp;quot;Bluetooth initialized&amp;quot;);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	bt_conn_cb_register(&amp;amp;conn_callbacks);

	int (*module_init[])(void) = {uart_init, scan_init, nus_client_init};
	for (size_t i = 0; i &amp;lt; ARRAY_SIZE(module_init); i++) {
		err = (*module_init[i])();
		if (err) {
			return;
		}
	}

	printk(&amp;quot;Starting Bluetooth Central UART example\n&amp;quot;);


	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
	if (err) {
		LOG_ERR(&amp;quot;Scanning failed to start (err %d)&amp;quot;, err);
		return;
	}

	LOG_INF(&amp;quot;Scanning successfully started&amp;quot;);

	for (;;) {
		/* Wait indefinitely for data to be sent over Bluetooth */
		//struct uart_data_t *buf = k_fifo_get(&amp;amp;fifo_uart_rx_data,
		//				     K_FOREVER);

		err = bt_nus_client_send(&amp;amp;nus_client, write_test_data, sizeof(write_test_data));
		if (err) {
			LOG_WRN(&amp;quot;Failed to send data over BLE connection&amp;quot;
				&amp;quot;(err %d)&amp;quot;, err);
		}

		err = k_sem_take(&amp;amp;nus_write_sem, NUS_WRITE_TIMEOUT);
		if (err) {
			LOG_WRN(&amp;quot;NUS send timeout&amp;quot;);
		}
	}
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/316760?ContentTypeID=1</link><pubDate>Wed, 23 Jun 2021 13:32:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a61e3cbe-20a9-473d-91ac-e3c95a2356ac</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Jonas, I will try to do a quick test of this tomorrow and come back to you. Thanks for your patience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/316499?ContentTypeID=1</link><pubDate>Tue, 22 Jun 2021 13:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64f25c9d-d91d-4e10-9b03-d570c4f3481c</guid><dc:creator>Jonas Lien</dc:creator><description>&lt;p&gt;Hi again Simon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think I&amp;#39;ve basically already given you the relevant code snippets in the top post, but maybe you can use any of your NCS samples that does BLE writes and just increase ATT MTU? I&amp;#39;m fine with any example of writing a bigger object than what the DLE is set for.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I know your throughput sample operates with varying degree of data length, but there it is used bt_gatt_write_without_response, where as I&amp;#39;m interested in bt_gatt_write which also gives a response/ack. The throughput sample also just uses &amp;quot;offset=0&amp;quot; in its params, so I&amp;#39;m not sure what differently I should do.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope to hear from you soon &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jonas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/316486?ContentTypeID=1</link><pubDate>Tue, 22 Jun 2021 12:57:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63598753-e58c-42a6-8814-91cab444bcee</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi again Jonas&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry about the delayed reply, but I&amp;#39;ve discussed this with a colleague, and it seems that, honestly, it doesn&amp;#39;t seem like we&amp;#39;ve tested long prepared writes like this properly. Can you upload your project or the necessary code snippets to do a long write so we can test this on our end, as we&amp;#39;d like to give the correct explanation on how to handle this offset.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/315768?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2021 07:44:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f62608c5-fa33-4073-9dd3-a99a4ddf11a7</guid><dc:creator>Jonas Lien</dc:creator><description>&lt;p&gt;Hi Simon, and thanks for your reply &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;beacon_data.fw is just a struct stored in RAM at runtime.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How do I account for the offset that you are talking about? It seems there is something about the transmit process im not fully getting.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Jonas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/315766?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2021 07:40:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f227546-1fb2-4eb8-9990-729eb7cd99b9</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The send function seems to be done correctly, but the way you receive and interpret the data is what&amp;#39;s causing these garbage values in the second packet.&lt;/p&gt;
&lt;p&gt;It seems like you&amp;#39;re ignoring the offset that tells the receiver what to look for in the second packet, which is why you only see the first packet correctly. You&amp;#39;ll need to take the fact that this is a continuation of data so the data from the second packet is what is printed, and not just random data.&amp;nbsp;Also, where do you store this incoming data&amp;nbsp;&lt;strong&gt;beacon_data.fw&lt;/strong&gt;? Is it stored in RAM or Flash?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE large Write turns to gibberish</title><link>https://devzone.nordicsemi.com/thread/315593?ContentTypeID=1</link><pubDate>Wed, 16 Jun 2021 12:10:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d837c71e-184a-48cb-96c3-a630a72c5357</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Jonas&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry about the poor response, but I have not had sufficient time to take a good look at your issue today, and will do so first thing tomorrow morning. I should be able to provide some better assistance/support by tomorrow. Thank you for your patience!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>