sendData method
Implementation
Future<void> sendData(List<int> data) async {
try {
_log.finer(() => "Sending ${data.length} bytes of plain data");
_log.finest(data);
if (state != BrilliantConnectionState.connected) {
throw ("Device is not connected");
}
if (data.length > maxDataLength!) {
throw ("Payload exceeds allowed length of $maxDataLength");
}
var finalData = data.toList()..insert(0, 0x01);
await _txChannel!.write(finalData, withoutResponse: true);
} catch (error) {
_log.warning("Couldn't send data. $error");
return Future.error(BrilliantBluetoothException(error.toString()));
}
}