-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message other than String Type #12
Comments
Hi @kidzen, I believe that is not difficult but at this moment I don't have the environment to make tests. import 'dart:typed_data';
class FlutterBluetoothSerial {
...
Future<dynamic> writeBytes(Uint8List message) =>
_channel.invokeMethod('writeBytes', {'message': message});
...
} public class FlutterBluetoothSerialPlugin ...
...
public void onMethodCall ... {
...
case "writeBytes":
if (arguments.containsKey("message")) {
byte[] message = (byte[]) arguments.get("message");
write(result, message);
} else {
result.error("invalid_argument", "argument 'message' not found", null);
}
break;
...
}
...
private void write(Result result, byte[] message) {
if (THREAD == null) {
result.error("write_error", "not connected", null);
return;
}
try {
THREAD.write(message);
result.success(true);
} catch (Exception ex) {
Log.e(TAG, ex.getMessage(), ex);
result.error("write_error", ex.getMessage(), exceptionToString(ex));
}
}
private void write(Result result, String message) {
write(result, message.getBytes());
}
...
} We can use this example as base code. ;-) Maybe @rafaelterada could help us with tests and PR. Best. |
tq @edufolly for your fast response...i will try it out and post the result back to u...tq so much! |
Hi, I made the changes, however I can not test passing byte []. Can you do the tests and not give a return? |
Hi @rafaelterada, could you provide a PR with these features? |
Hi folks, PR was merged. Thanks. |
Base on this portion of code,
message can only be submitted through String type..
Just to give you a use case, currently i am trying to make use of this plugin to sent byte data to a bluetooth printer. In native android, write method are represent in byte[] type if im not mistaken..
The text was updated successfully, but these errors were encountered: