Last active
January 4, 2024 23:54
-
-
Save tdcolvin/12ff1be62a7d1394e548f47db1b9b650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var selectedDevice: BluetoothDevice? = null | |
private val scanCallback = object : ScanCallback() { | |
override fun onScanResult(callbackType: Int, result: ScanResult?) { | |
super.onScanResult(callbackType, result) | |
//TODO: Set the criteria for selecting the device. Here we check the device's | |
// name from the advertisement packet, but you could for example check its | |
// manufacturer, address, services, etc. | |
if (result.name == "MyDevice") { | |
//We have found what we're looking for. Save it for later. | |
selectedDevice = result.device | |
} | |
} | |
override fun onScanFailed(errorCode: Int) { | |
super.onScanFailed(errorCode) | |
//TODO: Something went wrong | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment