hello,
on our bm833 dev board, I scope (using a PIO) the time it takes for the bt_nus_send function to send 146 BYTES. The PIO goes to 0 after the callback nus_sent_cb has been fired to ensure that the data has actually been transmitted.
What we see on the scope are times of around 450us which are not logical based on the bm833 configuration: primary PHY LE 1M, connection interval range between 12,5ms and 15ms.
We expect a few milliseconds in order for the bt833 to send the original data before it accepts new data to send again.
here's what my 'send over ble' function does:
int32_t bt_send_data(const void *data, uint16_t len)
{
nus_sent_cb_done = false;
volatile int32_t ret;
ret = bt_nus_send(current_conn, data, len);
if (ret == -EBUSY) {
LOG_INF("BLETX%d]: File d’attente pleine", bt_nus_tx_send_ix);
set_pin_state_connected(0);
// remove me
nrf_gpio_pin_set((uint32_t)PIO_BT_ERROR);
//error();
return ret;
}
else
if (ret)
{
LOG_INF("[BLETX%d]: ERROR: %d\n", bt_nus_tx_send_ix, ret);
set_pin_state_connected(0);
// remove me
nrf_gpio_pin_set((uint32_t)PIO_BT_ERROR);
//error();
return ret;
} else {
LOG_INF("[BLETX%d]: accepté", bt_nus_tx_send_ix);
}
// wait here to take the semaphore
// to considerate packet as fully sent over ble
ret = k_sem_take(&ble_packet_sent, K_MSEC(1));
k_sem_reset(&ble_packet_sent);
if(ret==0)
LOG_INF("[BLETX%d]: OK", bt_nus_tx_send_ix);
else
LOG_INF("[BLETX%d]: NOK", bt_nus_tx_send_ix);
bt_nus_tx_send_ix++;
return ret;
}
the semaphore ble_packet_sent is set in the nus_sent_cb cb;
static void nus_sent_cb(struct bt_conn *conn)
{
/* Ici, le paquet est considéré comme envoyé au niveau ATT */
nus_sent_cb_done = true;
k_sem_give(&ble_packet_sent);
}
is there a better callback to use to ensure proper availability of the tx characteristic ?
best regards,
Alex