Last active
September 14, 2022 18:15
-
-
Save tkubasik-luna/0548731da4a996600aa9042655e541ee to your computer and use it in GitHub Desktop.
scan device
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
val callback = object : ScanCallback() { | |
override fun onScanResult(callbackType: Int, result: ScanResult?) { | |
super.onScanResult(callbackType, result) | |
result?.device?.connectGatt(context, false, gattCallBack) | |
} | |
} | |
adapter = BluetoothAdapter.getDefaultAdapter() | |
val builder = ScanFilter.Builder() | |
builder.setServiceUuid(ParcelUuid(SERVICE_UUID)) | |
val filter = builder.build() | |
val filters = listOf(filter) | |
val settings = ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_POWER).build() | |
adapter.bluetoothLeScanner.startScan(filters, settings, callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment