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

multi packets per connection interval

HI,I want to send multi packets per connection interval. I have checked some questions and thread. like thislink text and thislink text.

according to the example throughput , i think i can use the data_send function to achieve multi packets per interval.

since i am using ble_uart example, i add data_send() function and put it in while loop to send data continuously. the data_send code is as follow:

static void data_send(){
uint32_t err_code;
  int n=0;
static uint8_t data[500] = {8};

  err_code=ble_lbs_data_send(&m_lbs, data);
if (err_code != NRF_SUCCESS &&
        err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
        err_code != NRF_ERROR_INVALID_STATE &&
        err_code != BLE_ERROR_NO_TX_BUFFERS)
   {
        APP_ERROR_CHECK(err_code);
   }  }

main function is that

int main(void){

  uint32_t err_code_uart,err_code;
  bool erase_bonds;
  uint8_t  start_string[] = START_STRING;

    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS_BLE, APP_TIMER_OP_QUEUE_SIZE_BLE, false);
  uart_init();
  buttons_leds_init(&erase_bonds);
  ble_stack_init();
  gap_params_init();    
  services_init();
  advertising_init();
  conn_params_init();
    err_code_uart = ble_advertising_start(BLE_ADV_MODE_FAST);
  APP_ERROR_CHECK(err_code_uart);


	m_transfer_completed = false;

// Setup bsp module.

	
uint8_t data[500]={0};
	int i=0,count=1;
while(1)
   {
		 
           data_send();
			// ble_nus_string_send(&m_nus, data, 20);

   }}

the question is when i used data_send(); function to send data, there is no data received in MCP while when i use ble_nus_string_send function, it works.

Can anyone help?

Thank You

  • currently, i am using NRF51 dongle to receive data. it can receive up to 6 packets per interval,right. for example, if i want to achieve three data packets per interval, i just copy and past ble_nus_string_send three time,is it correct?

    static void data_send()
    {
    uint32_t err_code;
    static uint8_t data[BLE_LBS_DATA_CHAR_LEN] = {0};
            
    
        err_code = ble_nus_string_send(&m_nus, data, 20);
        if (err_code == BLE_ERROR_NO_TX_BUFFERS ||
            err_code == NRF_ERROR_INVALID_STATE || 
            err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING)
        {
            break;
        }
        err_code = ble_nus_string_send(&m_nus, data, 20);
        if (err_code == BLE_ERROR_NO_TX_BUFFERS ||
            err_code == NRF_ERROR_INVALID_STATE || 
            err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING)
        {
            break;
        }
        err_code = ble_nus_string_send(&m_nus, data, 20);
        if (err_code == BLE_ERROR_NO_TX_BUFFERS ||
            err_code == NRF_ERROR_INVALID_STATE || 
            err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING)
        {
            break;
        }
    

    }

    BTW, how can i view the number of packets per interval in MCP?

    Thank You very much

  • It really depends on how often you call data_send(). If you always have available TX buffers, then yes. If you want to see how many packets you send, you can use a ble sniffer like the nRF sniffer.. You can also use the nRF uart app for your smarthphone, and count the packets manually. This will only be possible if you set a very high connection interval though, like over 2 seconds.

Related