Skip to content

Commit

Permalink
nrf/bluetooth/ble_uart: Add mp_hal_stdio_poll function.
Browse files Browse the repository at this point in the history
This adds support for enabling MICROPY_PY_SYS_STDFILES when running UART
over Bluetooth (NUS).
  • Loading branch information
glennrub authored and dpgeorge committed Jul 1, 2020
1 parent fc1f22a commit ab0c14d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ports/nrf/drivers/bluetooth/ble_uart.c
Expand Up @@ -33,6 +33,10 @@
#include "lib/utils/interrupt_char.h"
#include "py/runtime.h"

#if MICROPY_PY_SYS_STDFILES
#include "py/stream.h"
#endif

#if MICROPY_PY_BLE_NUS

static ubluepy_uuid_obj_t uuid_obj_service = {
Expand Down Expand Up @@ -136,6 +140,17 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
mp_hal_stdout_tx_strn(str, len);
}

#if MICROPY_PY_SYS_STDFILES
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
uintptr_t ret = 0;
if ((poll_flags & MP_STREAM_POLL_RD) && ble_uart_enabled()
&& !isBufferEmpty(mp_rx_ring_buffer)) {
ret |= MP_STREAM_POLL_RD;
}
return ret;
}
#endif

STATIC void gap_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data) {
ubluepy_peripheral_obj_t * self = MP_OBJ_TO_PTR(self_in);

Expand Down

0 comments on commit ab0c14d

Please sign in to comment.