-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 668 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
import {
Platform,
NativeModules
} from 'react-native';
import UsbSerialDevice from './UsbSerialDevice';
const UsbSerialModule = NativeModules.UsbSerial;
export class UsbSerial {
constructor() {
if (Platform.OS != 'android') {
throw 'Unfortunately only android is supported';
}
}
getDeviceListAsync() {
return UsbSerialModule.getDeviceListAsync();
}
openDeviceAsync(deviceObject = {}) {
return UsbSerialModule.openDeviceAsync(deviceObject).then((usbSerialDevNativeObject) => {
return new UsbSerialDevice(UsbSerialModule, usbSerialDevNativeObject);
});
}
}