Slide 25
Slide 25 text
private val leDeviceListAdapter = LeDeviceListAdapter()
// Device scan callback, including a ScanResult
// which can contain one or more devices
private val leScanCallback: ScanCallback = object : ScanCallback() {
override fun onScanResult(callbackType: Int, result: ScanResult) {
super.onScanResult(callbackType, result)
leDeviceListAdapter.addDevice(result.device)
leDeviceListAdapter.notifyDataSetChanged()
}
}
// With the device, you can have the BluetoothGatt, which has the
// characteristics read/write commands to interact with your device
var bluetoothGatt: BluetoothGatt? = null
bluetoothGatt = device.connectGatt(this, false, gattCallback)
bluetoothGatt.readCharacteristic(characteristic)
bluetoothGatt.writeCharacteristic(characteristic, value, writeType)