As far as I can see, when sending data via Bluetooth, the data is first stored in the buffer and then sent out together when the buffer is full. Is this the right idea? But now I want to implement real-time data transfer, is it possible to not use this buffer?
Here is how I send the data.
void ble_write_thread(void)
{
int err = 0;
uint8_t dummy[244];
/* Don't go any further until BLE is initialized */
k_sem_take(&ble_init_ok, K_FOREVER);
k_sem_take(&ble_button_start,K_FOREVER);
k_timer_start(&m_throughput_timer, K_SECONDS(1), K_SECONDS(1));
memset(dummy, 0xAA, sizeof(dummy));
for (;;) {
/* Send as many notifications as possible to test the throughput
* of the connection.
*/
dummy[0]++;
err = bt_nus_send(NULL, dummy, m_nus_max_send_len);
k_sleep(K_MSEC(2));
if (!err) {
m_total_num_bytes += m_nus_max_send_len;
}
}
}
K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL, NULL, PRIORITY, 0, 0);