summaryrefslogtreecommitdiff
path: root/ports/nrf/drivers/bluetooth/ble_uart.c
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2018-01-16 13:18:19 +0700
committerScott Shawcroft <scott@tannewt.org>2018-01-18 11:32:47 -0800
commitdfa6b6e9c5ec8d7b2a085eb9ddcf565c3433d1c1 (patch)
treef7786f0899c5f8622b1652ab91b088c823cd995f /ports/nrf/drivers/bluetooth/ble_uart.c
parent17ff1b2b46a51c2d9264208f3c8c39443353fe47 (diff)
add Ctrl+C for REPL over bleuart
Diffstat (limited to 'ports/nrf/drivers/bluetooth/ble_uart.c')
-rw-r--r--ports/nrf/drivers/bluetooth/ble_uart.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ports/nrf/drivers/bluetooth/ble_uart.c b/ports/nrf/drivers/bluetooth/ble_uart.c
index c66e7afd4..069d71589 100644
--- a/ports/nrf/drivers/bluetooth/ble_uart.c
+++ b/ports/nrf/drivers/bluetooth/ble_uart.c
@@ -30,6 +30,7 @@
#include "ble_uart.h"
#include "ringbuffer.h"
#include "hal/hal_time.h"
+#include "lib/utils/interrupt_char.h"
#if MICROPY_PY_BLE_NUS
@@ -145,6 +146,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;
+ ble_uart_advertise();
}
}
@@ -157,7 +159,14 @@ STATIC void gatts_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t at
m_cccd_enabled = true;
} else if (ble_uart_char_rx.handle == attr_handle) {
for (uint16_t i = 0; i < length; i++) {
- bufferWrite(mp_rx_ring_buffer, data[i]);
+ #if MICROPY_KBD_EXCEPTION
+ if (data[i] == mp_interrupt_char) {
+ mp_keyboard_interrupt();
+ } else
+ #endif
+ {
+ bufferWrite(mp_rx_ring_buffer, data[i]);
+ }
}
}
}