This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to change the data length of BLE notification

The maximum data length of a characteristic is 9, and I use the follow function to send the notification to a client

uint32_t dxs_send(dr_ble_dxs_t * p_dxs, uint8_t * p_data, uint16_t length)
{
	uint32_t ret_code;
	
	ble_gatts_hvx_params_t hvx_params;
	
	if (p_dxs == NULL)
	{
			return NRF_ERROR_NULL;
	}

	if ((p_dxs->conn_handle == BLE_CONN_HANDLE_INVALID) || (!p_dxs->is_notification_enabled_ctrl))
	{
			return NRF_ERROR_INVALID_STATE;
	}

	memset(&hvx_params, 0, sizeof(hvx_params));

	hvx_params.handle = p_dxs->ctrl_handles.value_handle;
	hvx_params.p_data = p_data;
	hvx_params.p_len  = &length;
	hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
	
	ret_code = sd_ble_gatts_hvx(p_dxs->conn_handle, &hvx_params);
	
	return ret_code;
}

The problem is I always get notification with length of 9 on the client side, even though the input argument "length" is smaller than 9. Is there a way to change the length of notification data?

Parents
  • Hi

    I want to provide basically the same answer as shibshab provided, with little more specifics. This is how the length parameters are presented in the BLE examples in the nRF51 SDK:

    attr.max_len
    
    attr.init_len
    
    attr_md.vlen
    

    which define the maximum length for the characteristic, initial length, and if the characteristic should have variable length or not. Modify these three as needed.

Reply
  • Hi

    I want to provide basically the same answer as shibshab provided, with little more specifics. This is how the length parameters are presented in the BLE examples in the nRF51 SDK:

    attr.max_len
    
    attr.init_len
    
    attr_md.vlen
    

    which define the maximum length for the characteristic, initial length, and if the characteristic should have variable length or not. Modify these three as needed.

Children
No Data
Related