Hi,
I use the peripheral ble_app_uart with nRF52832 (Murata module). The nRF52832 is connected to another MCU, STM32L476, via UART.
I develop using IAR, with SDK V15.0.0
My problem is that the uart_event_handle is not preempted by ble_nus_on_ble_evt.
I set a flag in ble_nus_on_ble_evt and in uart_event_handle I wait for it to be set. If I wait in uart_event_handle the flag is not set (ble_nus_on_ble_evt never executes), but if I remove the while loop ble_nus_on_ble_evt executes.
the priority for both is the same as in the original ble_app_uart example (ble_nus_on_ble_evt has higher priority).
I even tried not using BLE_NUS_BLE_OBSERVER_PRIO (for ble_nus_on_ble_evt) and APP_IRQ_PRIORITY_LOWEST (for uart_event_handle), and use 2 and 7 respectively.
The code in uart_event_handle:
switch (p_event->evt_type)
{
case APP_UART_DATA_READY:
if (eCONNECTED_CONFIRMED == ox_conn_mode) // In Approved connection mode -> Pass the byte to the BLE
{
if (GetPacketFromWatch(&data_array, &index))
{
do
{
if (index > BLE_NUS_MAX_DATA_LEN)
{
length = BLE_NUS_MAX_DATA_LEN;
index -= BLE_NUS_MAX_DATA_LEN;
f_ble_tx_complete = 0;
err_code = ble_nus_data_send(&m_nus, &data_array.byte_data[out_index], &length, m_conn_handle);
out_index += BLE_NUS_MAX_DATA_LEN;
while(0 == f_ble_tx_complete); //waiting here
The code in ble_nus_on_ble_evt:
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
on_connect(p_nus, p_ble_evt);
break;
case BLE_GATTS_EVT_WRITE:
on_write(p_nus, p_ble_evt);
break;
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
on_hvx_tx_complete(p_nus, p_ble_evt);
f_ble_tx_complete = 1;
break;