<?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>Why notification doesn&amp;#39;t work when lenght of data increases greater then 4?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102603/why-notification-doesn-t-work-when-lenght-of-data-increases-greater-then-4</link><description>In the following code: 
 
 Whenever I am increasing uint16_t len value greater then four, the value of nrf connect is not coming or updating after enabling also. 
 so let say if uint16_t len = 4 then value is updating after enabling notification. 
 but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Aug 2023 10:30:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102603/why-notification-doesn-t-work-when-lenght-of-data-increases-greater-then-4" /><item><title>RE: Why notification doesn't work when lenght of data increases greater then 4?</title><link>https://devzone.nordicsemi.com/thread/440275?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 10:30:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7ac8342-120e-43f4-92e2-ece27f27b072</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am not what it is not working for you. If I change max_len and init_len to 10 and change the array size to [10], then I can sent a notification of 10 bytes without any problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why notification doesn't work when lenght of data increases greater then 4?</title><link>https://devzone.nordicsemi.com/thread/440255?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 09:10:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe7dcfc1-f0c6-4f69-bcc3-2c68b40cbb6b</guid><dc:creator>Ayu7</dc:creator><description>&lt;p&gt;If I am increasing this also its not working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why notification doesn't work when lenght of data increases greater then 4?</title><link>https://devzone.nordicsemi.com/thread/440235?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 07:27:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fa6184c-cb69-4df8-a2fe-c965474dcd68</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You have set the maximum size of the attribute to be 4 when you create the characteristic&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    
    // Set characteristic length in number of bytes
		attr_char_value.max_len     = 4;
		attr_char_value.init_len    = 4;
		uint8_t value[4]            = {0x12,0x34,0x56,0x78};
		attr_char_value.p_value     = value;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So writing a value with len 10 will not work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why notification doesn't work when lenght of data increases greater then 4?</title><link>https://devzone.nordicsemi.com/thread/440220?ContentTypeID=1</link><pubDate>Tue, 08 Aug 2023 06:05:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06a80711-98ab-4c86-b5c2-a68fff2d3915</guid><dc:creator>Ayu7</dc:creator><description>&lt;p&gt;Hi ,&lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;&amp;nbsp;and thanks for replying. Yeah, I have updated the data for size 10 but updating also but it is not notifying the app. Also, my hvx is not resulting in any error.&lt;/p&gt;
&lt;p&gt;Here is the code where I am creating data of size 10 and sending it:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void timer_timeout_handler(void * p_context)
{
    // OUR_JOB: Step 3.F, Update temperature and characteristic value.
		int32_t temperature[10];      //Declare a variable holding temperature value
                static int32_t previous_temperature=0;      //Declare a variable to store current temperature until next measurement. 

		//sd_temp_get(&amp;amp;temperature);    //Get temperature
                
                      for(int i=0; i&amp;lt;10;i++) {
                            temperature[i]=i;
                        
                

                // Check if current temperature is different from last temperature
                if(temperature[i] != previous_temperature)
                    {
                      // If new temperature then send notification
                      our_temperature_characteristic_update(&amp;amp;m_our_service, &amp;amp;temperature);
                   }
                        
                // Save current temperature until next measurement
                previous_temperature = temperature[i];
                  //      }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is the code to create characteristics, but I don&amp;#39;t think so that any issue with characteristics creating as notification enabling part is working when size is 4:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint32_t our_char_add(ble_nus_t * p_nus)
{
    // Add a custom characteristic UUID
		uint32_t            err_code;
		ble_uuid_t          char_uuid;
		ble_uuid128_t       base_uuid = NUS_BASE_UUID;
		char_uuid.uuid      = BLE_UUID_OUR_CHARACTERISTC_UUID;
		err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;char_uuid.type);
		APP_ERROR_CHECK(err_code);  
    
    // Add read/write properties to our characteristic
    ble_gatts_char_md_t char_md;
    memset(&amp;amp;char_md, 0, sizeof(char_md));
		char_md.char_props.read = 1;
		char_md.char_props.write = 1;

    
    // Configuring Client Characteristic Configuration Descriptor metadata and add to char_md structure
    ble_gatts_attr_md_t cccd_md;
    memset(&amp;amp;cccd_md, 0, sizeof(cccd_md));
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.read_perm);
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.write_perm);
		cccd_md.vloc                = BLE_GATTS_VLOC_STACK;    
		char_md.p_cccd_md           = &amp;amp;cccd_md;
		char_md.char_props.notify   = 1;

   
    
    // Configure the attribute metadata
    ble_gatts_attr_md_t attr_md;
    memset(&amp;amp;attr_md, 0, sizeof(attr_md));  
		attr_md.vloc        = BLE_GATTS_VLOC_STACK;
    
    
    // OUR_JOB: Step 2.G, Set read/write security levels to our characteristic
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;attr_md.read_perm);
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;attr_md.write_perm);
    
    // Configure the characteristic value attribute
    ble_gatts_attr_t    attr_char_value;
    memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));
		attr_char_value.p_uuid      = &amp;amp;char_uuid;
		attr_char_value.p_attr_md   = &amp;amp;attr_md;
    
    // Set characteristic length in number of bytes
		attr_char_value.max_len     = 4;
		attr_char_value.init_len    = 4;
		uint8_t value[4]            = {0x12,0x34,0x56,0x78};
		attr_char_value.p_value     = value;

    //  Add our new characteristic to the service
		err_code = sd_ble_gatts_characteristic_add(p_nus-&amp;gt;service_handle,
                                   &amp;amp;char_md,
                                   &amp;amp;attr_char_value,
                                   &amp;amp;p_nus-&amp;gt;char_handles);
		APP_ERROR_CHECK(err_code);
    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why notification doesn't work when lenght of data increases greater then 4?</title><link>https://devzone.nordicsemi.com/thread/440094?ContentTypeID=1</link><pubDate>Mon, 07 Aug 2023 11:37:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4164ca7-759c-4451-b5c3-d5b7349f28df</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;If you just increase the len from 4 to 10, then the data pointed by the&amp;nbsp;p_data inside the attribute might not be the of the same size. Have you created an attribute in the characteristic of size 10 to be able to update the value with len = 10?&lt;/p&gt;
&lt;p&gt;In short the attribute value of the characteristic you are trying to update needs to be the right size. And if it is not the right size then doing an hvx might result in an error.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Can you show me the code snippet where you create the characteristic you are trying to send the notification for. That way I can see the details of the attribute and tell you if you can use len = 10 or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>