<?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>Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17468/nus-profile-seems-to-cause-system-reset-if-the-data-length-too-long</link><description>iphone5_b.psd m370_android6_b.psd long_write_error.png I using SDK11. I porting nus profile to my system and make a customer&amp;#39;s UUID. I use Lightblue on iPhone 5 to connect my system. I sent a data through my customer&amp;#39;s UUID. My system work fine when the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Nov 2016 12:15:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17468/nus-profile-seems-to-cause-system-reset-if-the-data-length-too-long" /><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67119?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 12:15:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:260dea7b-fc6a-4abf-99cc-f7ae991c2620</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Great! I tried to clean this question up a bit, so it can be useful to others. Could you accept my answer by clicking the grey circle next to it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67140?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 03:14:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eac5e888-6467-4c3f-b3ca-c45e93d0231d</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Hi Petter, Thank you very much. It works fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67141?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 12:45:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61463c14-763d-44a8-8cf5-b0d2945c8eb2</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Thank you. Very helpful. Try the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if(p_ble_evt-&amp;gt;header.evt_id == BLE_EVT_USER_MEM_REQUEST)
{
    err_code = sd_ble_user_mem_reply(m_nus.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
}
if(p_ble_evt-&amp;gt;header.evt_id == BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST)
{
    ble_gatts_rw_authorize_reply_params_t rw_authorize_reply_params;
    
    memset(&amp;amp;rw_authorize_reply_params, 0, sizeof(rw_authorize_reply_params));
    
    rw_authorize_reply_params.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
    
    if(p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL)
    {
        rw_authorize_reply_params.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
    }
    else
    {
        rw_authorize_reply_params.params.write.gatt_status  = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;
    }
    err_code = sd_ble_gatts_rw_authorize_reply(m_nus.conn_handle, &amp;amp;rw_authorize_reply_params);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67137?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 09:43:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86dd0b33-eef4-4978-b0fe-789691e4ed1c</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I  have posted it on top. Please have a look.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67139?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 06:46:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c3e6385-a1ca-43de-9876-fb5a6f189d8f</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Please edit your question and include the sniffer data &lt;strong&gt;and&lt;/strong&gt; the PNG.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67138?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 04:21:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06d6d6cb-58e1-4309-b998-82696a288a9b</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I cannot still make the nordic usb dongle to work properly. But I use TI&amp;#39;s usb dongle I have capture the data. Can you read TI&amp;#39;s sniffer data? If you can&amp;#39;t. Can I extract the error packet to a PNG file to you? How to post it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67136?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 04:25:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1bae6603-dd46-47c4-b176-b902076ad6a5</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I cannot make my usb dongle work properly. I&amp;#39;ll post the sniffer data if I capture the data properly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67130?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2016 13:27:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f767604-c847-49a5-8bb0-b08914798ea5</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. I&amp;#39;m not sure why you get the error. Can you do a sniffer trace with the nRF Sniffer? Also, when you get the error, what are all the parameters in ble_gatts_evt_rw_authorize_request_t struct that comes with the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67135?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2016 06:21:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f8b818d-d74c-4661-88bc-d6f47a23fa93</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Oh, it is very strange. I use your code and then I send 22-byte data. I receive BLE_EVT_USER_MEM_REQUEST event 1 time and call the API of sd_ble_user_mem_reply(m_conn_handle, NULL). Then I get first BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event and call the API of sd_ble_gatts_rw_authorize_reply(m_conn_handle, &amp;amp;rw_authorize_reply_params). I get the error code == 0. (success). Then I get second BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event and call the API of sd_ble_gatts_rw_authorize_reply(m_conn_handle, &amp;amp;rw_authorize_reply_params). I get the error code == 7. (failure. system reset).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67134?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2016 10:04:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f68395f1-35ca-41a2-ae4e-e891166d4457</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Strange, I tested the following code in ble_evt_dispatch(), and I&amp;#39;m not getting any error code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if(p_ble_evt-&amp;gt;header.evt_id == BLE_EVT_USER_MEM_REQUEST)
{
    err_code = sd_ble_user_mem_reply(m_nus.conn_handle, NULL);
    APP_ERROR_CHECK(err_code);
}
if(p_ble_evt-&amp;gt;header.evt_id == BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST)
{
    ble_gatts_rw_authorize_reply_params_t rw_authorize_reply_params;
    
    memset(&amp;amp;rw_authorize_reply_params, 0, sizeof(rw_authorize_reply_params));
    
    rw_authorize_reply_params.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
    
    rw_authorize_reply_params.params.write.gatt_status  = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;

    err_code = sd_ble_gatts_rw_authorize_reply(m_nus.conn_handle, &amp;amp;rw_authorize_reply_params);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67131?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2016 03:15:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3eb52fb5-8736-4f4a-a726-d76611ccbaf5</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I tested all gatt_status from BLE_GATT_STATUS_SUCCESS to BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE. I got an error code = 7 from the reply of the function of sd_ble_gatts_rw_authorize_reply at each gatt_status. Some gatt_status got a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event, and some gatt_status got it twice.
Can I use my code I post yesterday? Does it has any side effect?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67133?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2016 12:26:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:310d48b3-7756-423e-9225-915458d4b7d8</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. What if you use BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED instead?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67132?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2016 08:11:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a05477af-613b-4e49-a0ae-839e96f4196a</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Yes, If I respond with &lt;code&gt;sd_ble_user_mem_reply( p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, NULL)&lt;/code&gt;, I receive a &lt;code&gt;BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST&lt;/code&gt; event. If I respond with &lt;code&gt;auth_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED&lt;/code&gt; and a&lt;code&gt;uth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE&lt;/code&gt;. Then I call the function of  &lt;code&gt;sd_ble_gatts_rw_authorize_reply(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle, &amp;amp;auth_reply)&lt;/code&gt; like I post on 3rd Nov, and it will return error code = 7 (NRF_ERROR_INVALID_PARAM, cause system reset).&lt;/p&gt;
&lt;p&gt;If I change the code as follows, the system won&amp;#39;t cause system reset. I want to know it is correct or not? How may bytes I need to use? Which event I will get at each message segmentation to get data?
LightBlue on BlueiPhone and nRFConnect on Android phone have the same result.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_EVT_USER_MEM_REQUEST:
{
    static ble_user_mem_block_t mem_block;
    static uint8_t buffer[40];
    mem_block.len = 40;
    mem_block.p_mem = &amp;amp;buffer[0];
    err_code = sd_ble_user_mem_reply(m_conn_handle, &amp;amp;mem_block);
    break;
}
case BLE_EVT_USER_MEM_RELEASE:
{
    // call an error respond function.
    break;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67129?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2016 14:25:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e5d4292-db09-41c7-8a5c-aa2edcea639d</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I want to help you, but I don&amp;#39;t have an iOS device here to test with, so I&amp;#39;m not 100% sure what iOS is doing. Providing a sniffer trace would really help, you can use the nRF Sniffer. If you respond with sd_ble_user_mem_reply(), you should receive a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event, as you see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_t_t_s___q_u_e_u_e_d___w_r_i_t_e___n_o_b_u_f___n_o_a_u_t_h___m_s_c.html?cp=3_6_2_1_0_2_4_3_5"&gt;here&lt;/a&gt;. Are you receiving this event? If you do, you can try to call sd_ble_gatts_rw_authorize_reply() with gatt_status set to something else than BLE_GATT_STATUS_SUCCESS, for example BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH or BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED. However, I do not know how iOS will respond to this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67128?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2016 01:35:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fbdc8a9-87e4-4426-9a08-1f1a97faa91e</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I am using ble_uart example. I&amp;#39;ll get the event of BLE_EVT_USER_MEM_REQUEST at the function of on_ble_evt(ble_evt_t * p_ble_evt) if I send 22 characters at iPhone5 using LightBlue. It will cause to system reset after 30 seconds if I don&amp;#39;t process it at the event of BLE_EVT_USER_MEM_REQUEST. It will also cause to system reset after 30 seconds if I call the function of sd_ble_user_mem_reply(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, NULL) at the event of BLE_EVT_USER_MEM_REQUEST. I cannot protect my project against causing to system reset if I send over 20 characters at iPhone5 using LightBlue. Can anyone do me a faver? I don&amp;#39;t need to support long writes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67127?ContentTypeID=1</link><pubDate>Tue, 08 Nov 2016 01:28:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4fe8874-30db-4de4-a4a6-97cabe23f4d5</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I don&amp;#39;t want to support long writes. I just want to protect my project against system reset. Do you have easy way to do it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67124?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 11:08:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b5debb7-0565-4c25-aedb-65184f54543c</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;So you are triggering long write/queued write by trying to write more than 20 bytes, which is not supported by nus, see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_t_t_s___q_u_e_u_e_d___w_r_i_t_e___n_o_b_u_f___n_o_a_u_t_h___m_s_c.html?cp=3_6_2_1_0_2_4_3_5"&gt;this&lt;/a&gt; for more information. You get event 2, which is BLE_EVT_USER_MEM_REQUEST. If you want to support long writes you need to modify the example. You need to handle the events and increase the maximum length of the TX characteristic value. In most cases it is better to split your data into 20 bytes pieces and reassemble the data in the peer application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67121?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 09:58:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:227f899f-e7a3-407d-8efe-2c37dd96c81b</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;I use ble_app_uart example to test. I modified code to print event mesaage. The code is as follows.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
    ***printf(&amp;quot;event=%d\n&amp;quot;, p_ble_evt-&amp;gt;header.evt_id);***
    ble_conn_params_on_ble_evt(p_ble_evt);
    ble_nus_on_ble_evt(&amp;amp;m_nus, p_ble_evt);
    on_ble_evt(p_ble_evt);
    ble_advertising_on_ble_evt(p_ble_evt);
    bsp_btn_ble_on_ble_evt(p_ble_evt);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I got some debug mesages from UART as follows:&lt;/p&gt;
&lt;p&gt;UART Start!&lt;/p&gt;
&lt;p&gt;event=16&lt;/p&gt;
&lt;p&gt;event=80  &amp;lt;-- sent sent 5 characters&lt;/p&gt;
&lt;p&gt;12345&lt;/p&gt;
&lt;p&gt;event=80  &amp;lt;-- sent sent 10 characters&lt;/p&gt;
&lt;p&gt;1234567890&lt;/p&gt;
&lt;p&gt;event=80  &amp;lt;-- sent sent 20 characters&lt;/p&gt;
&lt;p&gt;12345678901234567890&lt;/p&gt;
&lt;p&gt;event=2  &lt;strong&gt;&lt;em&gt;&amp;lt;-- sent 22 characters BLE disconnect from phone&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The project of ble_app_uart seems same issue.&lt;/p&gt;
&lt;p&gt;Our QA team is makeing critical test. They sent unpredictable data to test it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67126?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 08:10:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfc394ac-715b-4569-ac39-9430dd0a1fe6</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Thirdly, I strongly recommend to test the functionality you want with the ble_app_uart example first, then we have common starting point, and it is easier to figure things out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67125?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 08:08:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:830c44db-8c78-4799-bcdf-f65bdc542950</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. So you get into trouble when you are trying to write more than 20 bytes into the TX characteristic. Firstly, as I mentioned above, the maximum ATT MTU with the S130 v2 is 23 bytes, the header is 3 bytes, so up to 20 bytes of data is allowed in one operation. So you are probably triggering long write/queued write by trying to write more than 20 bytes, which is not supported by nus, see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_t_t_s___q_u_e_u_e_d___w_r_i_t_e___n_o_b_u_f___n_o_a_u_t_h___m_s_c.html?cp=3_6_2_1_0_2_4_3_5"&gt;this&lt;/a&gt; for more information. Secondly, the maximum length of the TX characteristic value is 20 bytes, so if you want to actually do a long write you have to change this. But in most cases it is better to split your data into 20 byte pieces and reassemble the data in the peer application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67123?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 04:22:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c072573-9c16-4368-9ec0-97b89e8e1106</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;I am afraid I don&amp;#39;t know enough to help beyond this.&lt;/p&gt;
&lt;p&gt;It also is not clear to me why a Long Write to NUS would result in authorization request, because the write permission for the NUS RX characteristics is set to open...
My only (unhelpful) guess is that because NUS RX characteristic&amp;#39;s maximum length is 20, writing more than 20 create some unknown conflicts...&lt;/p&gt;
&lt;p&gt;Hope someone could help you soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67122?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2016 03:13:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20fc5b94-5d4a-4ecf-97c7-d3482df4dbcc</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;The error return code of sd_ble_gatts_rw_authorize_reply is 7 (NRF_ERROR_INVALID_PARAM). I don&amp;#39;t understand why I haven&amp;#39;t received the event of BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST when the data length is less than or equal 20 bytes. I will receive  the event of BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST when the data length is great than 20 bytes.
My project is modified from the project of ble_app_hrs_rscs_relay_pca10028 of SDK11. (It locations at
examples\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay\pca10028\s130\arm5_no_packs) I also modified ble_nus.c.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67117?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2016 09:18:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dc57a14-6739-40a5-a529-8d81645efe06</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;First off, I gotta admit I am unfamiliar with these authorization events. So I apologize before hand, but I can&amp;#39;t guarantee help.
(Also means anyone who know more should feel free to step in).&lt;/p&gt;
&lt;p&gt;What error code is being returned? You can see the list of possible error at the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v1.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga6de7aea3a870669e1d869b047de95545"&gt;&lt;code&gt;sd_ble_gatts_rw_authorize_reply()&lt;/code&gt; function&amp;#39;s documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Also, where did you get the &lt;code&gt;BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST&lt;/code&gt; handling code from? I believe it is not from the NUS example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67116?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2016 08:28:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dcb479a-fcc8-4465-b580-7258daa9ad5a</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Sorry, I have no good skill with Nordic platform. I follow your instrument to trace the code. I got an event of BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST if the data length is great than 20 bytes. (at APP_ERROR_CHECK)&lt;/p&gt;
&lt;p&gt;But if the data length isn&amp;#39;t great than 20 bytes I don&amp;#39;t receive the event of LE_GATTS_EVT_RW_AUTHORIZE_REQUEST and system work fine.&lt;/p&gt;
&lt;p&gt;Could you guide me how to trace it and fix this wrong I made?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void on_ble_peripheral_evt(ble_evt_t * p_ble_evt)
{
    uint32_t err_code;
    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
...
             break; //BLE_GAP_EVT_CONNECTED
        case BLE_GAP_EVT_DISCONNECTED:
...
            break;//BLE_GAP_EVT_DISCONNECTED
        case BLE_EVT_USER_MEM_REQUEST:
...
            break;//BLE_EVT_USER_MEM_REQUEST
        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
        {
            ble_gatts_rw_authorize_reply_params_t auth_reply;
            if(p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.type
               != BLE_GATTS_AUTHORIZE_TYPE_INVALID)
            {
                if ((p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.request.write.op
                     == BLE_GATTS_OP_PREP_WRITE_REQ)
                    || (p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.request.write.op
                     == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW)
                    || (p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.request.write.op
                     == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL))
                {
                    if (p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.type
                        == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
                    {
                        auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
                    }
                    else
                    {
                        auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
                    }
                    auth_reply.params.write.gatt_status = APP_FEATURE_NOT_SUPPORTED;
                    err_code = ***sd_ble_gatts_rw_authorize_reply(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle,&amp;amp;auth_reply);
                    APP_ERROR_CHECK(err_code);  --&amp;gt;fail at here***
                }
            }
        }break;//BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
        default:
            // No implementation needed.
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nus profile seems to cause system reset if the data length too long.</title><link>https://devzone.nordicsemi.com/thread/67120?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2016 02:09:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3bf17c0-fbd2-4a1b-98d0-c4e4195995b5</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Uh.. you probably don&amp;#39;t want to follow up using an &lt;strong&gt;answer&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Anyway, I have never encountered any system reset due to SoftDevice, whether I use custom BLE services or nRF SDK&amp;#39;s BLE Service.&lt;/p&gt;
&lt;p&gt;Following @petter &amp;#39;s suggestion, you should look at all places &lt;code&gt;APP_ERROR_CHECK&lt;/code&gt; is used.
Or quicker, add the preprocessor &lt;code&gt;DEBUG&lt;/code&gt; in compiling option. This change &lt;code&gt;APP_ERROR_CHECK&lt;/code&gt; to trap the firmware in an infinite loop at errors rather than reset the system. You can then use debug mode and see where the system freeze. Also when it froze, take a look at app_error.c. There are some global variables storing which line in which file trigger the error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>