mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
nrf: Fix NUS console when using boot.py or main.py.
This commit is contained in:
committed by
Damien George
parent
002f7d1ad7
commit
57ca1ecf01
@@ -93,6 +93,9 @@ static ubluepy_advertise_data_t m_adv_data_eddystone_url;
|
||||
#endif // BLUETOOTH_WEBBLUETOOTH_REPL
|
||||
|
||||
int mp_hal_stdin_rx_chr(void) {
|
||||
while (!ble_uart_enabled()) {
|
||||
// wait for connection
|
||||
}
|
||||
while (isBufferEmpty(mp_rx_ring_buffer)) {
|
||||
;
|
||||
}
|
||||
@@ -103,6 +106,9 @@ int mp_hal_stdin_rx_chr(void) {
|
||||
}
|
||||
|
||||
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
||||
// Not connected: drop output
|
||||
if (!ble_uart_enabled()) return;
|
||||
|
||||
uint8_t *buf = (uint8_t *)str;
|
||||
size_t send_len;
|
||||
|
||||
@@ -138,6 +144,7 @@ STATIC void gap_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t conn
|
||||
} else if (event_id == 17) { // disconnect event
|
||||
self->conn_handle = 0xFFFF; // invalid connection handle
|
||||
m_connected = false;
|
||||
m_cccd_enabled = false;
|
||||
ble_uart_advertise();
|
||||
}
|
||||
}
|
||||
@@ -154,6 +161,8 @@ STATIC void gatts_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t at
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
if (data[i] == mp_interrupt_char) {
|
||||
mp_keyboard_interrupt();
|
||||
m_rx_ring_buffer.start = 0;
|
||||
m_rx_ring_buffer.end = 0;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user