Uartevent (#393)

* support for uart data event

* updated shims
This commit is contained in:
Peli de Halleux
2017-04-28 01:05:04 -07:00
committed by GitHub
parent f820c20af8
commit 9af989c13c
7 changed files with 49 additions and 0 deletions

View File

@ -98,6 +98,18 @@ namespace bluetooth {
return uart->readUntil(ManagedString(del)).leakData();
}
/**
* Registers an event to be fired when one of the delimiter is matched.
* @param delimiters the characters to match received characters against.
*/
//% help=bluetooth/on-uart-data-received
//% weight=18 blockId=bluetooth_on_data_received block="bluetooth|on data received %delimiters=serial_delimiter_conv"
void onUartDataReceived(StringData* delimiters, Action body) {
startUartService();
uart->eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_BLE_UART, MICROBIT_UART_S_EVT_DELIM_MATCH, body);
}
/**
* Register code to run when the micro:bit is connected to over Bluetooth
* @param body Code to run when a Bluetooth connection is established