UART read block with string param unlimited length added

This commit is contained in:
Martin Woolley
2016-06-24 08:46:05 +01:00
parent 0834402b18
commit ecc71a3295
3 changed files with 30 additions and 2 deletions

View File

@ -97,11 +97,20 @@ namespace bluetooth {
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
*/
//% help=bluetooth/uart-write
//% blockId=bluetooth_uart_write block="bluetooth|uart|write %data" blockGap=8
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
void uartWrite(StringData *data) {
uart->send(ManagedString(data));
}
/**
* Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.
*/
//% help=bluetooth/uart-read
//% blockId=bluetooth_uart_read block="bluetooth uart read %del" blockGap=8
StringData* uartRead(StringData *del) {
return uart->readUntil(ManagedString(del)).leakData();
}
/**
* Register code to run when the micro:bit is connected to over Bluetooth
* @param body Code to run when a Bluetooth connection is established