nrf/bluetooth/ble_uart: Add mp_hal_stdio_poll function.

This adds support for enabling MICROPY_PY_SYS_STDFILES when running UART
over Bluetooth (NUS).
This commit is contained in:
Glenn Ruben Bakke 2020-06-25 23:32:28 +02:00 committed by Damien George
parent fc1f22a097
commit ab0c14dba0
1 changed files with 15 additions and 0 deletions

View File

@ -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 = {
@ -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);