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.
This commit is contained in:
Glenn Ruben Bakke 2020-06-25 23:49:12 +02:00 committed by Damien George
parent 5996bf72f1
commit f22f7b285e
1 changed files with 18 additions and 1 deletions

View File

@ -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