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

How send multiple notification per connection interval

Hi to all,

i am developing a device with nrf51822 and i want use it as a peripheral device, i want to write 4 packet per connection interval on noti char. i am ok with one packet per interval but when i want to write second packet to this noti char, sd_ble_gatts_hvx return 0x3004 that means BLE_ERROR_NO_TX_PACKETS, i know that in this case i must wait for BLE_EVT_TX_COMPLETE event and then send second packet, but in this manner i am not able to send 4 packet per connection interval. there is any one that know how can i fix this case and send 4 packet per connection interval with sd_ble_gatts_hvx  function?? and also when i call sd_ble_tx_packet_count_get function this function say that p_count is 2, so i do not think that i have memory limitations at least for 2 packet per connection interval.

thanks

Parents
  • Hi,

    I think it is strange that you get BLE_ERROR_NO_TX_PACKETS already after one packet, but waiting for a BLE_EVT_TX_COMPLETE event doesn't necessarily mean that you limit yourself to one packet per interval. The Softdevice should queue your packets and push out as many as it can at each interval. Have you tried waiting for the BLE_EVT_TX_COMPLETE events?

    What kind of central devices do you use?

    How many packets you can fit into a connection interval doesn't just rely on how often you are calling sd_ble_gatts_hvx(). The limiting factor is often the BLE chipsets or BLE stacks on your devices. Here is an informative blog post about how  BLE parameters affects throughput: Maximizing BLE Throughput on iOS and Android.

  • thanks for your response, i had experienced an strange behavior, see below code:

    uint8_t tmparr1[20] = {0};
    uint8_t tmparr2[20] = {0};
    uint8_t   mFlg = 0;
    void SendData(uint8_t ct)
    {
    	ble_gatts_hvx_params_t params;
    	ble_gatts_hvx_params_t params1;
    	uint16_t len1 = 20;
    	uint16_t len2 = 20;
    	static uint16_t err_cd = 0;
    	
    	memset(&params, 0, sizeof(params));
    	params.type = BLE_GATT_HVX_NOTIFICATION;
    	params.handle = m_keyfob.noti_char_handles.value_handle;
    	params.p_data = tmparr1;
    	params.p_len = &len1;
        err_cd = sd_ble_gatts_hvx(m_keyfob.conn_handle, &params);
    	
    	memset(&params1, 0, sizeof(params1));
    	params1.type = BLE_GATT_HVX_NOTIFICATION;
    	params1.handle = m_keyfob.noti_char_handles.value_handle;
    	params1.p_data = tmparr2;
    	params1.p_len = &len2;
    	err_cd = sd_ble_gatts_hvx(m_keyfob.conn_handle, &params1);
    }

    when i execute the above code , the first call of sd_ble_gatts_hvx work ok, but second call of sd_ble_gatts_hvx return 0x3004. but when i put the packet in the buffer in below manner, both of packet queued in buffer without problem.

    uint8_t tmparr1[20] = {0};
    uint8_t tmparr2[20] = {0};
    uint8_t   mFlg = 0;
    
    uint32_t ble_keyfob_send_noti(ble_keyfob_t * p_keyfob, uint8_t * noti_value)
    {
        ble_gatts_hvx_params_t params;
        uint16_t len = 20;
        
        memset(&params, 0, sizeof(params));
        params.type = BLE_GATT_HVX_NOTIFICATION;
        params.handle = p_keyfob->noti_char_handles.value_handle;
        params.p_data = noti_value;
        params.p_len = &len;
        
        return sd_ble_gatts_hvx(p_keyfob->conn_handle, &params);
    }
    
    void SendData(uint8_t ct)
    {
    	static uint8_t flg = 0;
    	if(flg == 0)
    	{
    		tmparr1[0] = 0xa;
    		ble_keyfob_send_noti(&m_keyfob, tmparr1);
    	}
    	else
    	{
    		tmparr1[0] = flg & 0xFF;
    		tmparr1[1] = (flg >> 8) & 0xFF;
    	}
    	
    	tmparr2[0] = 0xc;
    	flg = ble_keyfob_send_noti(&m_keyfob, tmparr2);
    }

    in this manner sd_ble_gatts_hvx function always return 0x00.

    but still i am not able to send two packet per connection interval and the packets was sent with speed of one packet per connection interval. there is any specific configuration that i must to set in order to send two packet per connection interval??

    and the central side is a CC2540 soc that firmware of that side is also was written by me.

    and also i have another question that maybe dose not related to this topic, when sending multiple packet in one connection interval, all of those packets that are transmitted in one connection interval are transmitted in one data channel or they are transmitted in different data channel??

    thanks for your attention

Reply
  • thanks for your response, i had experienced an strange behavior, see below code:

    uint8_t tmparr1[20] = {0};
    uint8_t tmparr2[20] = {0};
    uint8_t   mFlg = 0;
    void SendData(uint8_t ct)
    {
    	ble_gatts_hvx_params_t params;
    	ble_gatts_hvx_params_t params1;
    	uint16_t len1 = 20;
    	uint16_t len2 = 20;
    	static uint16_t err_cd = 0;
    	
    	memset(&params, 0, sizeof(params));
    	params.type = BLE_GATT_HVX_NOTIFICATION;
    	params.handle = m_keyfob.noti_char_handles.value_handle;
    	params.p_data = tmparr1;
    	params.p_len = &len1;
        err_cd = sd_ble_gatts_hvx(m_keyfob.conn_handle, &params);
    	
    	memset(&params1, 0, sizeof(params1));
    	params1.type = BLE_GATT_HVX_NOTIFICATION;
    	params1.handle = m_keyfob.noti_char_handles.value_handle;
    	params1.p_data = tmparr2;
    	params1.p_len = &len2;
    	err_cd = sd_ble_gatts_hvx(m_keyfob.conn_handle, &params1);
    }

    when i execute the above code , the first call of sd_ble_gatts_hvx work ok, but second call of sd_ble_gatts_hvx return 0x3004. but when i put the packet in the buffer in below manner, both of packet queued in buffer without problem.

    uint8_t tmparr1[20] = {0};
    uint8_t tmparr2[20] = {0};
    uint8_t   mFlg = 0;
    
    uint32_t ble_keyfob_send_noti(ble_keyfob_t * p_keyfob, uint8_t * noti_value)
    {
        ble_gatts_hvx_params_t params;
        uint16_t len = 20;
        
        memset(&params, 0, sizeof(params));
        params.type = BLE_GATT_HVX_NOTIFICATION;
        params.handle = p_keyfob->noti_char_handles.value_handle;
        params.p_data = noti_value;
        params.p_len = &len;
        
        return sd_ble_gatts_hvx(p_keyfob->conn_handle, &params);
    }
    
    void SendData(uint8_t ct)
    {
    	static uint8_t flg = 0;
    	if(flg == 0)
    	{
    		tmparr1[0] = 0xa;
    		ble_keyfob_send_noti(&m_keyfob, tmparr1);
    	}
    	else
    	{
    		tmparr1[0] = flg & 0xFF;
    		tmparr1[1] = (flg >> 8) & 0xFF;
    	}
    	
    	tmparr2[0] = 0xc;
    	flg = ble_keyfob_send_noti(&m_keyfob, tmparr2);
    }

    in this manner sd_ble_gatts_hvx function always return 0x00.

    but still i am not able to send two packet per connection interval and the packets was sent with speed of one packet per connection interval. there is any specific configuration that i must to set in order to send two packet per connection interval??

    and the central side is a CC2540 soc that firmware of that side is also was written by me.

    and also i have another question that maybe dose not related to this topic, when sending multiple packet in one connection interval, all of those packets that are transmitted in one connection interval are transmitted in one data channel or they are transmitted in different data channel??

    thanks for your attention

Children
Related