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

dealing large data packet's through ble

Hi, I need to send(using BLE) large amount of data's, which are collected by the accelerometer sensor for 1 hour. I have an external NOR flash where the accelerometer data's are stored and from there data's are transmitted to the BLE stack when sync occurs. I am using nRF51822 nordic controller. Assume that, data size will be 50KB.

Regards, Balaji

  • You can get the initial number of buffers available by calling sd_ble_tx_buffer_count_get().

    Using more than one characteristic will not give any higher data throughput, as explained here: https://devzone.nordicsemi.com/index.php/large-data-transmission-through-multiple-characteristics#reply-2099

    A procedure similar to the one given in my other reply here is what will give you the highest possible throughput.

  • Hi Ole,

    Thanks again for this excellent tutorial and example code. I tried it, and it greatly improved the achievable bandwidth.

    One problem I had was using this code was that I was missing every 7th packet. It seems that the while(1) above allows you an attempt to send 7 packets each connection interval, and the last one always fails. I got around this problem by checking to make sure I only attempt to send 6 packets (also using BLE_ERROR_NO_TX_BUFFERS to break me out of the loop), and my missing every 7th packet disappears.

    However, I still do miss the occasional packet, which I don't believe should happen given that notifications are still acked on the lower BLE layers (perhaps link layer?).

    What could I be doing wrong to be losing packets here?

    Thanks! Jamie

  • You should not be missing packets, but I can't think of anything obvious that could cause it. Can you please post this problem as a separate question, including all your code so that I can have a look? If you need confidentiality for the code, you can instead post a support case.

  • Sounds like you are "preparing" or "lifting off" the packet, and then try to send it. This will always fail on the 7th package as the buffer is only 6 packets deep. But you are either not putting the package back, or setting your counter back when this happens.

  • Hi Ole and KPE,

    Thanks for the replies. Ole, I might submit a ticket on this today if I can't figure it out by the end of it. KPE, I've tried putting back the packet if I get returned to me, without success. Please see the code below.

    Thanks! Jamie

    static void heart_rate_meas_timeout_handler(void * p_context) //static void heart_rate_meas_send(void) { uint32_t err_code; uint32_t packets = 0; static uint16_t heart_rate=0x0018;

    //UNUSED_PARAMETER(p_context);
    
    static uint16_t x=0,y=0,z=0;
    
    //while(TxBuffersAvailable)
    while(TxBuffersAvailable && packets < 6)
    {		
    	if(ble_hrs_rr_interval_buffer_is_empty(&m_hrs))
    	{
    		for(int i=0;i<3;++i)
    		{			
    			/*
    			if(x<=50)
    			{
    				x++;y++;z++;
    			}
    			else
    			{
    				x=0;y=0;z=0;
    			}*/
    			ble_hrs_rr_interval_add(&m_hrs, x++);
    			ble_hrs_rr_interval_add(&m_hrs, y++);
    			ble_hrs_rr_interval_add(&m_hrs, z++);
    		}
    		
    		packets++;
    		
    		err_code = ble_hrs_heart_rate_measurement_send(&m_hrs, heart_rate, 0);
    		if (err_code == NRF_ERROR_INVALID_STATE ||
    				err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING)
    		{								
    			break;
    		}
    		else if (err_code == BLE_ERROR_NO_TX_BUFFERS)
    		{			
    			//x--;y--;z--;
    			nrf_gpio_pin_toggle(LED_PIN);
    			TxBuffersAvailable=false;				
    			break;				
    		}
    		else if (err_code != NRF_SUCCESS) 
    		{
    			APP_ERROR_HANDLER(err_code);
    		}
    	}
    	else break;
    }
    
Related