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

Send large data (>20bytes) over BLE using Zephyr and NRF Connect SDK

Hello everyone!

I want to develop and app the sends some sensors data over BLE.

I am trying the peripheral_uart sample of the NRF Connect SDK but it seems that I cant sent a packet larger than 20 bytes.

Specifically, I want to send an array of  uint32_t [32] or uint8_t [128] data, but when  I try to send data larger than 20 bytes the notification is enabled but no data are sent never to the NRF Connect phone app. Below is the code of the peripheral_uart sample i have modify and try

What configurations should I make to increase the MTU and send larger data?

I will appreciate your help.

Parents
  • void ble_write_thread(void)
    {
    	/* Don't go any further until BLE is initialized */
    	k_sem_take(&ble_init_ok, K_FOREVER);
            uint8_t arr[128];
            for(int i=0; i<128;i++) {
              arr[i]=i;
              }
            uint16_t len = 128;
    
    	for (;;) {
    		/* Wait indefinitely for data to be sent over bluetooth */
    		//struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data,
    			//			     K_FOREVER);
    
    		if (bt_nus_send(NULL, arr, len)) {
    			LOG_WRN("Failed to send data over BLE connection");
    		}
    
                   /// int error = bt_gatt_write_without_response(NULL,char_handle,arr,len, false);
    		//k_free(buf);
    	}
    }
    
    K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL,
    		NULL, PRIORITY, 0, 0);

Reply
  • void ble_write_thread(void)
    {
    	/* Don't go any further until BLE is initialized */
    	k_sem_take(&ble_init_ok, K_FOREVER);
            uint8_t arr[128];
            for(int i=0; i<128;i++) {
              arr[i]=i;
              }
            uint16_t len = 128;
    
    	for (;;) {
    		/* Wait indefinitely for data to be sent over bluetooth */
    		//struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data,
    			//			     K_FOREVER);
    
    		if (bt_nus_send(NULL, arr, len)) {
    			LOG_WRN("Failed to send data over BLE connection");
    		}
    
                   /// int error = bt_gatt_write_without_response(NULL,char_handle,arr,len, false);
    		//k_free(buf);
    	}
    }
    
    K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL,
    		NULL, PRIORITY, 0, 0);

Children
No Data
Related