package io.trygvis.android.bt; import android.bluetooth.BluetoothDevice; import android.util.Log; public class BtDevice { private final static String TAG = BtDevice.class.getSimpleName(); private final DefaultBtService btService; private final BluetoothDevice bluetoothDevice; private Integer rssi; private BtScanResult scanResult; private A tag; private boolean seenNow; private BtDeviceListener l = null; private BtDeviceListener listener = new BtDeviceListener() { }; public BtDevice(DefaultBtService btService, BluetoothDevice bluetoothDevice, A tag, Integer rssi, BtScanResult scanResult) { this.btService = btService; this.bluetoothDevice = bluetoothDevice; this.tag = tag; this.rssi = rssi; this.scanResult = scanResult; } public void addListener(BtDeviceListener listener) { this.l = listener; } public A getTag() { return tag; } public void setTag(A tag) { this.tag = tag; } public String getAddress() { return bluetoothDevice.getAddress(); } public String getName() { return bluetoothDevice.getName(); } public int getRssi() { return rssi; } public boolean connect(BtActionExecutor executor) { Log.i(TAG, "connect(), address=" + bluetoothDevice.getAddress() + ", queue=" + executor); bluetoothDevice.connectGatt(btService, false, executor.asCallback()); return true; } public BtScanResult getScanResult() { return scanResult; } @Override public String toString() { return "BtDevice{address=" + bluetoothDevice.getAddress() + '}'; } }