This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (40 loc) · 1.37 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* An ReactNative wrapper for AndroidBluetoothLibrary <https://github.com/douglasjunior/AndroidBluetoothLibrary>
*
* =======================
* FUNCTIONS
* =======================
*
* config(objectConfig) -> Promise
* startScan() -> Promise<[objectDevice]>
* connect(objectDevice) -> Promise
* getStatus() -> Promise<String>
* write(string) -> Promise
* writeln(string) -> Promise
* stopService() -> Promise
*
* =======================
* EVENTS
* =======================
*
* EVENT_DEVICE_FOUND
* EVENT_DATA_READ
* EVENT_STATUS_CHANGE
* EVENT_DEVICE_NAME
*
*/
import { NativeModules, DeviceEventEmitter } from 'react-native';
const EasyBluetooth = NativeModules.EasyBluetoothLE;
EasyBluetooth.addOnDeviceFoundListener = function (eventCallback) {
return DeviceEventEmitter.addListener(EasyBluetooth.EVENT_DEVICE_FOUND, eventCallback);
}
EasyBluetooth.addOnDataReadListener = function (eventCallback) {
return DeviceEventEmitter.addListener(EasyBluetooth.EVENT_DATA_READ, eventCallback);
}
EasyBluetooth.addOnStatusChangeListener = function (eventCallback) {
return DeviceEventEmitter.addListener(EasyBluetooth.EVENT_STATUS_CHANGE, eventCallback);
}
EasyBluetooth.addOnDeviceNameListener = function (eventCallback) {
return DeviceEventEmitter.addListener(EasyBluetooth.EVENT_DEVICE_NAME, eventCallback);
}
module.exports = EasyBluetooth;