<?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>When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94778/when-notification-with-big-data-only-maximum-4-notification-is-sent</link><description>Dear Nordic support team, I meet a situation: I have big data array need to transfer(&amp;quot;arrayTransfer&amp;quot; with 3072 bytes) to smart phone by notification method. Using timer 10s to send 3072 byte to smart phone. 
 I want to send 128 bytes data for one notification</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Dec 2022 10:19:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94778/when-notification-with-big-data-only-maximum-4-notification-is-sent" /><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400796?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 10:19:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cfbc140-0eb8-46a7-aa38-fa8461b62b78</guid><dc:creator>Quangca</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;I understand, thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400767?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 09:19:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e529f10-5b59-4fbd-b7ac-3e2e0de6f1a8</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Somewhere after you call&amp;nbsp;ble_stack_init()&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400760?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 08:44:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:004c6325-07b4-4926-966a-1dc3d54a51df</guid><dc:creator>Quangca</dc:creator><description>&lt;p&gt;hi Sigurd,&lt;/p&gt;
&lt;p&gt;where to add this code below?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    ret_code_t err_code;
    ble_opt_t  opt;

    memset(&amp;amp;opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = 1;

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &amp;amp;opt);
    APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400629?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2022 13:14:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2249b4e-2db4-4a01-a12f-10e0116e0fe4</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;&lt;span&gt;Try to set the hvn_tx_queue_size directly as well, and see if it improves anything, snippet:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Function for the SoftDevice initialization.
 *
 * @details This function initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    ble_cfg_t ble_cfg;
    memset(&amp;amp;ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.conn_cfg.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 10;

    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &amp;amp;ble_cfg, ram_start);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATTS.&amp;quot;,
                      nrf_strerror_get(err_code));
    }



    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And also try to enable&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.2.0%2Fstructble__common__opt__conn__evt__ext__t.html"&gt;Connection Event Length Extension&lt;/a&gt;, snippet:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;    ret_code_t err_code;
    ble_opt_t  opt;

    memset(&amp;amp;opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = 1;

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &amp;amp;opt);
    APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400557?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2022 09:58:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:296cae59-48f4-46e7-aaf4-8dc0c88a22bf</guid><dc:creator>Quangca</dc:creator><description>&lt;p&gt;yes, i tried but the same.&lt;/p&gt;
&lt;p&gt;Do i need change more parameter?&lt;/p&gt;
&lt;p&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/pastedimage1671012078818v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400553?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2022 09:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f09aa9a4-becb-4a12-a895-23fc9eb0bc1b</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="lta2"] Do you have sugestion for me?[/quote]
&lt;p&gt;Yes, as mentioned:&lt;/p&gt;
[quote user="sigurdon"]You could try to set&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH in sdk_config.h to a higher value, e.g. 320.&lt;/span&gt;[/quote]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400550?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2022 09:41:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:deb23a4a-3c52-498f-91d6-50a30b9c48e2</guid><dc:creator>Quangca</dc:creator><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I get log error code return in&amp;nbsp;dataTransferHandler() function, and see that it return&amp;nbsp; 0(NRF_SUCCESS) total 4 times, and&amp;nbsp;&lt;/span&gt;&lt;span&gt;20 times remain return 19(NRF_ERROR_RESOURCES), NRF_ERROR_RESOURCES mean&amp;nbsp;Not enough resources&amp;nbsp;like that below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#define NRF_SUCCESS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (NRF_ERROR_BASE_NUM + 0)&amp;nbsp; ///&amp;lt; Successful command&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#define NRF_ERROR_RESOURCES&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (NRF_ERROR_BASE_NUM + 19) ///&amp;lt; Not enough resources for operation&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So i think this is the main reason it only send 4 notifications to smart phone app..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;=&amp;gt; Do you have sugestion for me?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;Below is my RAM and Flash configure:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:inherit;"&gt;&lt;span style="color:#00ff00;"&gt; linker_section_placement_macros&lt;/span&gt;=&lt;span style="color:#ff6600;"&gt;&amp;quot;FLASH_PH_START=0x0;FLASH_PH_SIZE=0x30000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x6000;FLASH_START=0x19000;FLASH_SIZE=0x17000;RAM_START=0x20002000;RAM_SIZE=0x6000&amp;quot;&lt;/span&gt;&lt;br /&gt; l&lt;span style="color:#00ff00;"&gt;inker_section_placements_segments&lt;/span&gt;=&lt;span style="color:#ff0000;"&gt;&amp;quot;FLASH RX 0x0 0x30000;RAM1 RWX 0x20000000 0x6000&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1671010172514v1.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;dataTransferHandler() function:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void dataTransferHandler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    
    uint8_t dataLengthTransfer = 128;
    ret_code_t err_code;
    uint16_t i = 0, j;

    for(i = 0; i&amp;lt; 24; i++)
     {
        for(j = 0; j&amp;lt;128; j++)

        {
            dataTransfer[j] = arrayTransfer[i*128+j+i];
        }
        err_code = ble_TWIs_temperature_update(&amp;amp;m_TWIs, dataTransfer, BLE_CONN_HANDLE_ALL, dataLengthTransfer);
        NRF_LOG_INFO(&amp;quot;err_code: %d.&amp;quot;, err_code); //get erro code to check
        
        if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
            (err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY) &amp;amp;&amp;amp;
            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING))
        {
            APP_ERROR_HANDLER(err_code);
        }
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400337?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 10:09:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb88ade8-1139-4216-bbcb-da63e7a7b25e</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;You might&amp;nbsp;be filling up the SoftDevice buffer to fast. After 4 notifications queued/buffered, you are likely getting&amp;nbsp;NRF_ERROR_RESOURCES returned. You could try to set&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH in sdk_config.h to a higher value, e.g. 320. After this change, you likely need to allocate more RAM to the SoftDevice.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400273?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 02:46:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ecea985-3e6f-4f7b-8bc8-246dd0f9e9ee</guid><dc:creator>Quangca</dc:creator><description>&lt;p&gt;hello Sigurd,&lt;/p&gt;
&lt;p&gt;Bellow is the&amp;nbsp;&lt;span&gt;ble_TWIs_temperature_update()&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t ble_TWIs_temperature_update(ble_TWIs_t * p_TWIs, uint8_t     *pData, uint16_t    conn_handle, uint16_t datalength)
{
    if (p_TWIs == NULL)
    {
        return NRF_ERROR_NULL;
    }

    ret_code_t         err_code = NRF_SUCCESS;
    ble_gatts_value_t  gatts_value;

    //if (currentVal != lastVal)
    {
        // Initialize value struct.
        memset(&amp;amp;gatts_value, 0, sizeof(gatts_value));

        gatts_value.len     = datalength * sizeof(uint8_t);
        gatts_value.offset  = 0;
        gatts_value.p_value = pData;

        // Send value if connected and notifying.
        if (p_TWIs-&amp;gt;is_notification_supported)
        {
            ble_gatts_hvx_params_t hvx_params;

            memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

            hvx_params.handle = p_TWIs-&amp;gt;TWI2C_level_handles.value_handle;
            hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
            hvx_params.offset = gatts_value.offset;
            hvx_params.p_len  = &amp;amp;datalength;
            hvx_params.p_data = gatts_value.p_value;

            if (conn_handle == BLE_CONN_HANDLE_ALL)
            {
                NRF_LOG_DEBUG(&amp;quot;conn_handle == BLE_CONN_HANDLE_ALL&amp;quot;)
                ble_conn_state_conn_handle_list_t conn_handles = ble_conn_state_conn_handles();
                // Try sending notifications to all valid connection handles.
                for (uint32_t i = 0; i &amp;lt; conn_handles.len; i++)
                {
                    if (ble_conn_state_status(conn_handles.conn_handles[i]) == BLE_CONN_STATUS_CONNECTED)
                    {
                        if (err_code == NRF_SUCCESS)
                        {
                            err_code = temperature_notification_send(&amp;amp;hvx_params,
                                                                 conn_handles.conn_handles[i]);
                             NRF_LOG_DEBUG(&amp;quot;Try sending notifications to all valid connection handles&amp;quot;)
                        }
                        else
                        {
                            // Preserve the first non-zero error code
                            UNUSED_RETURN_VALUE(temperature_notification_send(&amp;amp;hvx_params, conn_handles.conn_handles[i]));
                        }
                    }
                }
            }
            else
            {
                NRF_LOG_DEBUG(&amp;quot;conn_handle != BLE_CONN_HANDLE_ALL&amp;quot;)
                err_code = temperature_notification_send(&amp;amp;hvx_params, conn_handle);
            }
        }
        else
        {
            err_code = NRF_ERROR_INVALID_STATE;
        }
    }
    return err_code;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When notification with big data, only maximum 4 notification is sent.</title><link>https://devzone.nordicsemi.com/thread/400151?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2022 13:25:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdcdfb34-16ea-4591-8d2e-c92635d0f21c</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;How does the function&amp;nbsp;&lt;span&gt;ble_TWIs_temperature_update() look like?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you print what the function is returning?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>