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

Communication speed has been slowed down after modification of INDICATION in NOTIFICATION.

Hi,

I am working on the project as a MultiLink example.
My environment is using nRF52840DK & Softdevice 6 & SDK15.

I am trying to make multiple connections and communicate.
Previously, we only communicated with NOTIFY, but decided to use INDICATE at the same time.

This is the part I modified.
Below is the ble_lbs_c.c revision.

static void on_hvx(ble_lbs_c_t * p_ble_lbs_c, ble_evt_t const * p_ble_evt)
{
    // Check if the event is on the link for this instance
    if (p_ble_lbs_c->conn_handle != p_ble_evt->evt.gattc_evt.conn_handle)
    {
        return;
    }
    // Check if this is a Button notification.
    if (p_ble_evt->evt.gattc_evt.params.hvx.handle == p_ble_lbs_c->peer_lbs_db.button_handle)
    {
        //if (p_ble_evt->evt.gattc_evt.params.hvx.len == 1)		//jwcheon edit
        {
            ble_lbs_c_evt_t ble_lbs_c_evt;

#if bINDICATE
			if( p_ble_evt->evt.gattc_evt.params.hvx.type == BLE_GATT_HVX_INDICATION )
			{
				ble_lbs_c_evt.evt_type = BLE_LBS_C_EVT_BUTTON_INDICATION;		//jwcheon
			}
			else
			{
				ble_lbs_c_evt.evt_type = BLE_LBS_C_EVT_BUTTON_NOTIFICATION;
			}
#else
			ble_lbs_c_evt.evt_type = BLE_LBS_C_EVT_BUTTON_NOTIFICATION;	//org
#endif
            ble_lbs_c_evt.conn_handle                = p_ble_lbs_c->conn_handle;
            ble_lbs_c_evt.params.send.data = (uint8_t *)&p_ble_evt->evt.gattc_evt.params.hvx.data[0];
			ble_lbs_c_evt.params.send.data_len = p_ble_evt->evt.gattc_evt.params.hvx.len;
            p_ble_lbs_c->evt_handler(p_ble_lbs_c, &ble_lbs_c_evt);

#if bINDICATE
			/* Indication ACK ��ȣ �����ִ� �κ� */
			if( p_ble_evt->evt.gattc_evt.params.hvx.type == BLE_GATT_HVX_INDICATION )
			{
				ret_code_t err_code;
				err_code = sd_ble_gattc_hv_confirm(p_ble_lbs_c->conn_handle,
					p_ble_evt->evt.gattc_evt.params.hvx.handle);
	
				if( err_code == NRF_SUCCESS )
				{
					//NRF_LOG_INFO("NRF_SUCCESS");
				}
				else
				{
					//NRF_LOG_INFO("Error: [%x]", err_code);
				}
			}
#endif

static uint32_t cccd_configure(uint16_t conn_handle, uint16_t handle_cccd, bool enable)
{
    NRF_LOG_DEBUG("Configuring CCCD. CCCD Handle = %d, Connection Handle = %d",
        handle_cccd,conn_handle);

    tx_message_t * p_msg;
#if bINDICATE
		uint16_t cccd_val = enable ? (BLE_GATT_HVX_NOTIFICATION | BLE_GATT_HVX_INDICATION) : 0;
#else
		uint16_t cccd_val = enable ? BLE_GATT_HVX_NOTIFICATION : 0;
#endif


    p_msg              = &m_tx_buffer[m_tx_insert_index++];
    m_tx_insert_index &= TX_BUFFER_MASK;

    p_msg->req.write_req.gattc_params.handle   = handle_cccd;
    p_msg->req.write_req.gattc_params.len      = BLE_CCCD_VALUE_LEN;
    p_msg->req.write_req.gattc_params.p_value  = p_msg->req.write_req.gattc_value;
    p_msg->req.write_req.gattc_params.offset   = 0;
    p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ;
    p_msg->req.write_req.gattc_value[0]        = LSB_16(cccd_val);
    p_msg->req.write_req.gattc_value[1]        = MSB_16(cccd_val);
    p_msg->conn_handle                         = conn_handle;
    p_msg->type                                = WRITE_REQ;

    tx_buffer_process();
    return NRF_SUCCESS;
}

The major modification is that when INDICATE comes in, it uses the sd_ble_gattc_hv_confirm () function.

Could it be slowed down by this part?
Or I have modified some things in sdk_config.h as well.

Modified to NRF_SDH_BLE_GAP_EVENT_LENGTH: 6 -> 320
Modified to NRF_SDH_BLE_GATT_MAX_MTU_SIZE: 23 -> 128
NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE: 1408 used as is

Do you think that the communication speed is slowed down as MTU_SIZE increases?
When you communicate with NOTIFY, even these modifications are fast.

However, this is different for INDICATE.
In the case of one, the speed is slightly slow, but it is okay.
However, as the number increases to two or three, the communication speed starts to become much slower.

Also, as the communication speed slows down, the device may be suddenly disconnected at a certain moment.
Predictably, communication packets are getting slower and pushing over, and communication seems to be disconnected.

Can you help me?
Please.

Parents
  • Indications require application level acknowledgement which means it will be slower/ much slower than using notification which only uses Link layer acknowledgements. While you can send one or more notifications per connectio event. Indications will require processing on the peer side, which means server will send the indication in one connection event (event n), the peer will acknowledge this in the next connection event (event n+1) and the server can send another indication in the following connection event (event n+2).

    However I would not expect to see disconnections when using indication compared to notifications. At least not as long as your application makes sure to acknowledge received indications, If I remember correctly the timeout is 30seconds, which means the server will disconnect if it takes more than 30 seconds to get a reply for an indication.

  • Hi, run_ar.

    Your answer became a really great understanding for me.
    The more devices connected to the nRF52840 board, the more I understood why the communication speed is slowed down.

    So, is there any way to improve the speed of using Indication?


    Also, the timeout period is about 30 seconds, and it is confirmed that several devices continuously send packets in a short period of time and lose the response time and forcibly disconnect the connection.

    If so, does this timeout need to be modified on the nRF52840 board?
    If not, do I have to modify it in the connecting device?

    As I guess, the connecting device is likely to send an indication packet and wait for a response timer.

  • Unfortunately the only way to increase the speed of indications is to have a faster connection interval, but this might lead to more problems with maintaining your connection.

    If you have disconnects before the 30 second procedure timeout for indications, you are most likely getting a connection supervision timeout. What connection interval are you using? and how many devices are you testing with? and are this devices centrals or peripherals?

  • The connection interval is as follows.

    I am currently trying to connect up to 4 units.
    When connecting the nrf52840 board and two devices, the connection is broken and data transmission / reception is possible.

    However, the speed of data transmission and reception from three or more units is slow, and communication is interrupted frequently.

    My answer to the last question is central.

    #define MIN_CONNECTION_INTERVAL   MSEC_TO_UNITS(7.5, UNIT_1_25_MS)      /**< Determines minimum connection interval in milliseconds. */
    #define MAX_CONNECTION_INTERVAL   MSEC_TO_UNITS(30, UNIT_1_25_MS)       /**< Determines maximum connection interval in milliseconds. */
    #define SLAVE_LATENCY             0                                     /**< Determines slave latency in terms of connection events. */
    #define SUPERVISION_TIMEOUT       MSEC_TO_UNITS(4000, UNIT_10_MS)       /**< Determines supervision time-out in units of 10 milliseconds. */
    
    

  • Not sure I understand this. But according to Google translate you are trying to connect to 4 units in total (not sure about roles). And that you are not loosing connections due to a supervision timeout within 4 seconds. Instead you are disconnected after 30 seconds because your device has not received application layer acknowledgements for a indication. To solve that you must make sure your application acknowledges these indications.

    Here is the flow chart for a gatt server. And here is the flow chart for the gatt client (usually the central). As you see the gatt client has to reply to the BLE_GATTC_EVT_HVX event for the Softdevice to send an Handle value confirmation to the peer.

Reply Children
Related