Greetings Nordic Team,
I am trying to pass data from an application on a dk-nrf52840 to a nrf52840-dongle whose uart is connected to the uart on a microcontroller.
Using the example programs for central_uart and peripheral_uart in nrf connect desktop. everything works fine sending data to and from the respective central and peripheral uarts.
However, I need to send internal data from the application on the dk to the dongles uart (and vice versa). I thought it would be simple enough to just use the
bt_nus_client_send() function, and replace the buf->data and buf->len with my own data. Alas, this only results in an error.
//this is my attempt to use bt_nus_client_send()
char internal_data[UART_BUF_SIZE]={"Jim was here."};
uint16_t length = sizeof(internal_data);
err = bt_nus_client_send(&nus_client, internal_data, length);
if (err) {
LOG_WRN("Fudge! Failed to send data over BLE connection"
"(err %d)", err);
}
//this is the error
<wrn> central_uart: Fudge! Failed to send data over BLE connection(err -128)
//this is the working sample code
for (;;) {
/* Wait indefinitely for data to be sent over Bluetooth */
struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data,
K_FOREVER);
err = bt_nus_client_send(&nus_client, buf->data, buf->len);
if (err) {
LOG_WRN("Failed to send data over BLE connection"
"(err %d)", err);
}
err = k_sem_take(&nus_write_sem, NUS_WRITE_TIMEOUT);
if (err) {
LOG_WRN("NUS send timeout");
}
}
any sugestions?