Hi there,
I currently have an nRF51 DK set up transmitting six 20 byte packets per 7.5ms, there about, to an nRF51 Dongle set up as a central. When viewing with Master Emulator i can clearly see that these six 20 byte packets are being transmitted. As can be seen below.
How would i go about logging all of this data onto UART with the central? I have previoulsy had it logging one byte per connection interval but after upping this to six 20 byte packets i am clearly missing data.
Below is relevant code to my application logging recieved data onto UART, any ideas would be great, many thanks!
the client event struct:
typedef struct
{
ble_uart_evt_type_t evt_type ; /**<event type */
union
{
uint8_t rx_value; /**< RX Value.*/
}params;
} ble_uart_evt_t;
the read response:
static void on_read_rsp(ble_uart_t * p_tx, const ble_evt_t * p_ble_evt)
{
const ble_gattc_evt_read_rsp_t * p_response;
p_response = &p_ble_evt->evt.gattc_evt.params.read_rsp;
if (p_response->handle == p_tx->rx_handle)
{
ble_uart_evt_t evt;
evt.evt_type = BLE_UART_EVT_READ_RESP;
evt.params.rx_value = p_response->data[0];
p_tx->evt_handler(p_tx, &evt);
}
// Check if there is any buffered transmissions and send them.
tx_buffer_process();
}
on hvx:
static void on_hvx(ble_uart_t * p_ble_uart, const ble_evt_t * p_ble_evt)
{
// Check if this notification is a tx value notification.
if (p_ble_evt->evt.gattc_evt.params.hvx.handle == p_ble_uart->rx_handle)
{
ble_uart_evt_t ble_uart_evt;
ble_uart_evt.evt_type = BLE_UART_EVT_NOTIFICATION;
ble_uart_evt.params.rx_value = p_ble_evt->evt.gattc_evt.params.hvx.data[0];
p_ble_uart->evt_handler(p_ble_uart, &ble_uart_evt);
}
}
handler in the main.c
static void uart_evt_handler(ble_uart_t * p_uart, ble_uart_evt_t * p_uart_evt)
{
switch (p_uart_evt->evt_type)
{
case BLE_UART_EVT_DISCOVERY_COMPLETE:
// TX service discovered. Enable notification of Tx Level.
ble_uart_rx_read(p_uart);
ble_uart_rx_notif_enable(p_uart);
break;
case BLE_UART_EVT_NOTIFICATION:
{
printf("%d \r\n", p_uart_evt->params.rx_value);
break;
}
case BLE_UART_EVT_READ_RESP:
{
printf("%d \r\n", p_uart_evt->params.rx_value);
break;
}
default:
break;
}
}