<?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>Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46688/find-a-way-to-control-notify-flow-to-prevent-stock-notify-between-device-and-phone-app</link><description>Hi 
 We follow the chart to design our notify flow to control the data in notify queue. 
 but we face a problem, the data in the queue always get more than 2 when the 9 or 8 mins, then our flow stop to notify, 
 please reference the code below, s_not_send</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Jul 2019 03:52:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46688/find-a-way-to-control-notify-flow-to-prevent-stock-notify-between-device-and-phone-app" /><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/200633?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 03:52:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f5ded80-7b66-41e4-9bd5-439cd425d1d6</guid><dc:creator>TTN</dc:creator><description>&lt;p&gt;Hi Berg,&lt;/p&gt;
&lt;p&gt;Thanks for your reply, we end up finding that the ble error is due to the VIVO&amp;#39;s(Cell phone) problem, they have working on the issue, thanks!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/186167?ContentTypeID=1</link><pubDate>Thu, 09 May 2019 12:03:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9b4ad83-9d6b-48fe-bc71-cb5b5d8f3ae9</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;This error makes more sense, thanks for confirming. Can you try to handle retries in the main context assuming&amp;nbsp;ble_cus_custom_value_update() is called in an interrupt context that will block Softdevice events? You can monitor&amp;nbsp;&lt;span&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&amp;nbsp;events to determine if packets are being sent.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/185811?ContentTypeID=1</link><pubDate>Wed, 08 May 2019 01:48:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89268cca-2d8a-46bd-8432-4c25c55b329e</guid><dc:creator>TTN</dc:creator><description>&lt;p&gt;Hi, thanks for your reply, the error code is 0x13,&lt;pre class="ui-code" data-mode="text"&gt;        err_code = sd_ble_gatts_hvx(p_cus-&amp;gt;conn_handle, &amp;amp;hvx_params);
		if(err_code!=0){
			SEGGER_RTT_printf( 0, &amp;quot;sd_ble_gatts_hvx result: %x. \r\n&amp;quot;, err_code) ;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;so I used &amp;quot;s_not_send(self count data in queue)&amp;quot; to check whether I should call&amp;nbsp;&amp;nbsp;sd_ble_gatts_hvx again, but the &lt;span&gt;s_not_send&lt;/span&gt;&lt;span&gt;&amp;nbsp;didn&amp;#39;t cut back so the device will keep waiting, user will feel the bluetooth stock.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;	  if ( s_device_mode == e_only_data  ) {              
			if ( s_not_send &amp;lt; 3 ) {          // s_not_send=self count data in queue
	      err_code = ble_cus_custom_value_update( &amp;amp;m_cus, notify_data ) ;                                   
					if(err_code==8){
						SEGGER_RTT_printf(0,&amp;quot;process error err_code=8\n&amp;quot;);
						err_code = sd_ble_gap_disconnect( m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION ) ;
					    s_not_send=0;
						return ; 
					}				
                APP_ERROR_CHECK( err_code ) ;
				s_not_send++ ;
			} // if
		} // if&lt;/pre&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;how can I get the right available queue element number?&lt;br /&gt;can I clear the queue to reset the&amp;nbsp;available queue element?&lt;br /&gt;is there any flow to handle this situation?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/185615?ContentTypeID=1</link><pubDate>Tue, 07 May 2019 07:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:beaf00b2-cbaf-4fab-9a0d-2fe9c5fb363c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Is the error value&amp;nbsp;0x13 or decimal 13?&amp;nbsp; 0x13&amp;nbsp;corresponds to NRF_ERROR_RESOURCES&amp;nbsp;and means that the output buffer is full:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;* @retval ::NRF_ERROR_RESOURCES Too many notifications queued.&lt;br /&gt; * Wait for a @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event and retry.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/185024?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 03:40:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eae339e9-7c88-4236-8504-c5ac9764c6a2</guid><dc:creator>TTN</dc:creator><description>&lt;p&gt;Yes, I check the event in the &amp;quot;on_conn_params_evt_hanlder&amp;quot; of main.c, I can get&amp;nbsp;&lt;span&gt;BLE_CONN_PARAMS_EVT_SUCCEEDED when use nrf connect to the&amp;nbsp;custom&amp;nbsp;device after I type the passkey to create a bonding connection.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;the error is getting from&amp;nbsp;sd_ble_gatts_hvx is 13, after the device start to notify for about 8~9 mins.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t ble_cus_custom_value_update(ble_cus_t * p_cus, uint8_t * custom_value)
{
    NRF_LOG_INFO(&amp;quot;In ble_cus_custom_value_update. \r\n&amp;quot;); 
    if (p_cus == NULL)
    {
        return NRF_ERROR_NULL;
    }

    uint32_t err_code = NRF_SUCCESS;
    ble_gatts_value_t gatts_value;

    // Initialize value struct.
    memset(&amp;amp;gatts_value, 0, sizeof(gatts_value));

    gatts_value.len     = 20 ; 
    gatts_value.offset  = 0;
    gatts_value.p_value = custom_value;

    // Update database.
    err_code = sd_ble_gatts_value_set(p_cus-&amp;gt;conn_handle,
                                      p_cus-&amp;gt;custom_value_handles.value_handle,
                                      &amp;amp;gatts_value);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Send value if connected and notifying.
    if ((p_cus-&amp;gt;conn_handle != BLE_CONN_HANDLE_INVALID)) 
    {
        ble_gatts_hvx_params_t hvx_params;

        memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

        hvx_params.handle = p_cus-&amp;gt;custom_value_handles.value_handle;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
        hvx_params.offset = gatts_value.offset;
        hvx_params.p_len  = &amp;amp;gatts_value.len;
        hvx_params.p_data = gatts_value.p_value;

        err_code = sd_ble_gatts_hvx(p_cus-&amp;gt;conn_handle, &amp;amp;hvx_params);
	    SEGGER_RTT_printf( 0, &amp;quot;sd_ble_gatts_hvx result: %x. \r\n&amp;quot;, err_code) ;
        NRF_LOG_INFO(&amp;quot;sd_ble_gatts_hvx result: %x. \r\n&amp;quot;, err_code); 
    }
    else
    {
        err_code = NRF_ERROR_INVALID_STATE;
        NRF_LOG_INFO(&amp;quot;sd_ble_gatts_hvx result: NRF_ERROR_INVALID_STATE. \r\n&amp;quot;); 
    }


    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: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184923?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 13:39:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9114c902-0d8c-4848-8055-e75c333dd011</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="ttn115"]I thought that there was a start to notify that&amp;nbsp;&lt;span&gt;the connection interval&lt;/span&gt; was accepted&amp;nbsp;&lt;span&gt;by the central.&lt;/span&gt;[/quote]
&lt;p&gt;It depends on your application. The SDK examples will typically terminate the link if the requested parameters are rejected after x attempts. You can check if you receive the&amp;nbsp;BLE_CONN_PARAMS_EVT_SUCCEEDED from the connection parameters negotiation module.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184916?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 13:19:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b17bde53-7b9c-40ac-93a4-049b2467f71e</guid><dc:creator>TTN</dc:creator><description>&lt;p&gt;How can i find the answer?&amp;nbsp;&amp;nbsp;&lt;span lang="en"&gt;I thought that there was a start to notify that&amp;nbsp;&lt;span&gt;the connection interval&lt;/span&gt; was accepted&amp;nbsp;&lt;span&gt;by the central.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184898?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 12:41:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4bc86a3-8dd2-4302-9525-2b64006a0574</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming. We&amp;nbsp;might need a sniffer trace to see which procedure timed out. Do you know if the connection interval is accepted by the central (i.e., interval between 20-40 ms)?&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184800?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 08:59:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:017421dc-6c87-4e9e-89e3-c380fe8e2f71</guid><dc:creator>TTN</dc:creator><description>&lt;p&gt;Yes,&amp;nbsp;&lt;span&gt;ble_cus_custom_value_update() return error 13, but I&amp;#39;m not sure whether the error code is before LMP timeout or not. Is there any way to check?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184785?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 08:27:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fbe221f-1aa9-40e6-b082-8942b2b6801b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I think it&amp;#39;s strange that you get LMP timeout.&amp;nbsp;Does&amp;nbsp;ble_cus_custom_value_update() return an error (not 8) before you get the LMP timeout?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184740?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 02:02:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:330238cc-62c0-4b0d-98ec-87ac1ed4ab6f</guid><dc:creator>TTN</dc:creator><description>&lt;p&gt;The issue is when connecting to the VIVO 1808(cell phone)the notify flow stop when&amp;nbsp;&lt;span&gt;data in the queue is more than the queue can accommodate&lt;/span&gt;&lt;span&gt;&amp;nbsp;in 9 or 8 mins.&lt;br /&gt;&lt;br /&gt;the flow is described in the annex above.&lt;br /&gt;&lt;br /&gt;the situation is we see the nrf connect log and find the error code is LMP response time out, so we try the&amp;nbsp;LINK_COUNT config to 2(PERIPHERAL)+0(CENTRAL)=2(TOTAL) and still get the same error&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;list some config in code&amp;nbsp; and reference link below&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/22353/lmp-response-timeout---experimental_ble_app_multiperipheral_pca10040_s132"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/22353/lmp-response-timeout---experimental_ble_app_multiperipheral_pca10040_s1321&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/22353/lmp-response-timeout---experimental_ble_app_multiperipheral_pca10040_s132"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/22353/lmp-response-timeout---experimental_ble_app_multiperipheral_pca10040_s132"&gt;&lt;pre class="ui-code" data-mode="text"&gt;in SDK config.h
---------------------
// &amp;lt;o&amp;gt; NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. 
#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 2
#endif

// &amp;lt;o&amp;gt; NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. 
#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0
#endif

// &amp;lt;o&amp;gt; NRF_SDH_BLE_TOTAL_LINK_COUNT - Maximum number of total concurrent connections using the default configuration. 
#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT
#define NRF_SDH_BLE_TOTAL_LINK_COUNT 2
#endif

// &amp;lt;o&amp;gt; NRF_SDH_BLE_GAP_EVENT_LENGTH - The time set aside for this connection on every connection interval in 1.25 ms units. 
#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 4
#endif

// &amp;lt;o&amp;gt; NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. 
#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23
#endif

// &amp;lt;o&amp;gt; NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. 
#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE
#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408
#endif
-------------------------
in main

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**&amp;lt; Minimum acceptable connection interval (10 ms). */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(40, UNIT_1_25_MS)             /**&amp;lt; Maximum acceptable connection interval (100 ms) */
#define SLAVE_LATENCY                   0                                           /**&amp;lt; Slave latency. */ // 可否忽略connect event
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**&amp;lt; Connection supervisory timeout (4 seconds). */
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(500)                        /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(100)                        /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAM_UPDATE_COUNT     5                                           /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */
-------------------------&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find a way to control Notify flow to prevent stock notify between device and phone App</title><link>https://devzone.nordicsemi.com/thread/184156?ContentTypeID=1</link><pubDate>Sat, 27 Apr 2019 07:54:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd22fc83-cb05-4000-9192-c9da82e5ffa7</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;What is the issue? I&amp;#39;m afraid I don&amp;#39;t understand your code, and you should indent it properly btw.&lt;/p&gt;
&lt;p&gt;What is that s_not_send variable for? Why less than 3?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>