forked from dariuszseweryn/RxAndroidBle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRxBleAdapterWrapper.java
40 lines (29 loc) · 1.14 KB
/
RxBleAdapterWrapper.java
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
package com.polidea.rxandroidble.internal.util;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.support.annotation.Nullable;
import java.util.Set;
public class RxBleAdapterWrapper {
private final BluetoothAdapter bluetoothAdapter;
public RxBleAdapterWrapper(@Nullable BluetoothAdapter bluetoothAdapter) {
this.bluetoothAdapter = bluetoothAdapter;
}
public BluetoothDevice getRemoteDevice(String macAddress) {
return bluetoothAdapter.getRemoteDevice(macAddress);
}
public boolean hasBluetoothAdapter() {
return bluetoothAdapter != null;
}
public boolean isBluetoothEnabled() {
return bluetoothAdapter != null && bluetoothAdapter.isEnabled();
}
public boolean startLeScan(BluetoothAdapter.LeScanCallback leScanCallback) {
return bluetoothAdapter.startLeScan(leScanCallback);
}
public void stopLeScan(BluetoothAdapter.LeScanCallback leScanCallback) {
bluetoothAdapter.stopLeScan(leScanCallback);
}
public Set<BluetoothDevice> getBondedDevices() {
return bluetoothAdapter.getBondedDevices();
}
}