add Ctrl+C for REPL over bleuart

This commit is contained in:
hathach 2018-01-16 13:18:19 +07:00 committed by Scott Shawcroft
parent 17ff1b2b46
commit dfa6b6e9c5

View File

@ -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]);
}
}
}
}