aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Ruben Bakke2020-06-25 23:49:12 +0200
committerDamien George2020-07-01 22:51:30 +1000
commitf22f7b285e69aa05ce2dcf1e26de626dd1b1599d (patch)
tree66be40614bc297a751ebb776fbfa99dc1b3b53bd
parent5996bf72f134dd8f1b72ecd20757dcb1c98cfc89 (diff)
nrf/bluetooth/ble_uart: Swap end character on cooked strings.
Changing line ending character of cooked strings makes rshell/pyboard.py work correctly over Bluetooth socat/pts devices.
-rw-r--r--ports/nrf/drivers/bluetooth/ble_uart.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/ports/nrf/drivers/bluetooth/ble_uart.c b/ports/nrf/drivers/bluetooth/ble_uart.c
index b2e79ba44..64e3a05f9 100644
--- a/ports/nrf/drivers/bluetooth/ble_uart.c
+++ b/ports/nrf/drivers/bluetooth/ble_uart.c
@@ -136,8 +136,25 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
}
}
+void ble_uart_tx_char(char c) {
+ // Not connected: drop output
+ if (!ble_uart_enabled()) return;
+
+ ubluepy_characteristic_obj_t * p_char = &ble_uart_char_tx;
+
+ ble_drv_attr_s_notify(p_char->p_service->p_periph->conn_handle,
+ p_char->handle,
+ 1,
+ (uint8_t *)&c);
+}
+
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
- mp_hal_stdout_tx_strn(str, len);
+ for (const char *top = str + len; str < top; str++) {
+ if (*str == '\n') {
+ ble_uart_tx_char('\r');
+ }
+ ble_uart_tx_char(*str);
+ }
}
#if MICROPY_PY_SYS_STDFILES