@ -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
|
||||
|
Reference in New Issue
Block a user