Skip to content

Commit dfa6b6e

Browse files
hathachtannewt
authored andcommitted
add Ctrl+C for REPL over bleuart
1 parent 17ff1b2 commit dfa6b6e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ports/nrf/drivers/bluetooth/ble_uart.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "ble_uart.h"
3131
#include "ringbuffer.h"
3232
#include "hal/hal_time.h"
33+
#include "lib/utils/interrupt_char.h"
3334

3435
#if MICROPY_PY_BLE_NUS
3536

@@ -145,6 +146,7 @@ STATIC void gap_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t conn
145146
} else if (event_id == 17) { // disconnect event
146147
self->conn_handle = 0xFFFF; // invalid connection handle
147148
m_connected = false;
149+
ble_uart_advertise();
148150
}
149151
}
150152

@@ -157,7 +159,14 @@ STATIC void gatts_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t at
157159
m_cccd_enabled = true;
158160
} else if (ble_uart_char_rx.handle == attr_handle) {
159161
for (uint16_t i = 0; i < length; i++) {
160-
bufferWrite(mp_rx_ring_buffer, data[i]);
162+
#if MICROPY_KBD_EXCEPTION
163+
if (data[i] == mp_interrupt_char) {
164+
mp_keyboard_interrupt();
165+
} else
166+
#endif
167+
{
168+
bufferWrite(mp_rx_ring_buffer, data[i]);
169+
}
161170
}
162171
}
163172
}

0 commit comments

Comments
 (0)