This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Find a way to control Notify flow to prevent stock notify between device and phone App

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 is the data in the queue.

We what to know how to deal with this issue to make to notify stable.

device information
SDK:14.2

SD:5.1.0 GATTS Handle Value Notification flow chart
Nordic Semiconductor Infocenter.pdf

	  if ( s_device_mode == e_only_data  ) {              
			if ( s_not_send < 3 ) {                          // if notify queue have 2 data, stop notify until under 2 data
	      err_code = ble_cus_custom_value_update( &m_cus, notify_data ) ;                                   
					if(err_code==8){
						SEGGER_RTT_printf(0,"process error err_code=8\n");
						  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

Parents Reply
  • Hi, thanks for your reply, the error code is 0x13,

            err_code = sd_ble_gatts_hvx(p_cus->conn_handle, &hvx_params);
    		if(err_code!=0){
    			SEGGER_RTT_printf( 0, "sd_ble_gatts_hvx result: %x. \r\n", err_code) ;

    so I used "s_not_send(self count data in queue)" to check whether I should call  sd_ble_gatts_hvx again, but the s_not_send didn't cut back so the device will keep waiting, user will feel the bluetooth stock.

    	  if ( s_device_mode == e_only_data  ) {              
    			if ( s_not_send < 3 ) {          // s_not_send=self count data in queue
    	      err_code = ble_cus_custom_value_update( &m_cus, notify_data ) ;                                   
    					if(err_code==8){
    						SEGGER_RTT_printf(0,"process error err_code=8\n");
    						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
     

    how can I get the right available queue element number?
    can I clear the queue to reset the available queue element?
    is there any flow to handle this situation?

Children
Related