stop method
Stops recording on the connected bluetooth device.
Returns true
if the acquisition was stopped successfully, false
otherwise.
Throws BITalinoException(BITalinoErrorType.TIMEOUT) if the timeout limit is reached. Throws BITalinoException(BITalinoErrorType.BT_DEVICE_NOT_CONNECTED) if a device is not connected. Throws BITalinoException(BITalinoErrorType.CUSTOM) if a native exception was raised. Throws BITalinoException(BITalinoErrorType.BT_DEVICE_NOT_RECORDING) if the connected bluetooth device is not recording.
Implementation
Future<bool> stop() async {
if (!connected)
throw BITalinoException(BITalinoErrorType.BT_DEVICE_NOT_CONNECTED);
if (!recording)
throw BITalinoException(BITalinoErrorType.BT_DEVICE_NOT_RECORDING);
try {
bool stopped = await _channel.invokeMethod("stop").timeout(timeout);
recording = !stopped;
if (stopped) _onBITalinoDataAvailable = null;
return stopped;
} on TimeoutException {
throw BITalinoException(BITalinoErrorType.TIMEOUT);
} catch (e) {
throw BITalinoException(BITalinoErrorType.CUSTOM, e.toString());
}
}