|
@@ -404,6 +404,19 @@ public class RNSerialportModule extends ReactContextBaseJavaModule {
|
|
serialPort.write(bytes);
|
|
serialPort.write(bytes);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ReactMethod
|
|
|
|
+ public void write(ArrayBuffer bytes) {
|
|
|
|
+ if(!usbServiceStarted){
|
|
|
|
+ eventEmit(onErrorEvent, createError(Definitions.ERROR_USB_SERVICE_NOT_STARTED, Definitions.ERROR_USB_SERVICE_NOT_STARTED_MESSAGE));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if(!serialPortConnected || serialPort == null) {
|
|
|
|
+ eventEmit(onErrorEvent, createError(Definitions.ERROR_THERE_IS_NO_CONNECTION, Definitions.ERROR_THERE_IS_NO_CONNECTION_MESSAGE));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ serialPort.write(bytes);
|
|
|
|
+ }
|
|
|
|
+
|
|
@ReactMethod
|
|
@ReactMethod
|
|
public void writeString(String message) {
|
|
public void writeString(String message) {
|
|
if(!usbServiceStarted){
|
|
if(!usbServiceStarted){
|