Created
August 12, 2021 10:40
-
-
Save Xiryl/ddac5c7d1cc8fd871233115b4dc3e43e to your computer and use it in GitHub Desktop.
BluetoothSDK-Service2
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
/** | |
* Class used for the client Binder. | |
*/ | |
inner class LocalBinder : Binder() { | |
/** | |
* Enable the discovery, registering a broadcastreceiver {@link discoveryBroadcastReceiver} | |
* The discovery filter by LABELER_SERVER_TOKEN_NAME | |
*/ | |
public fun startDiscovery(context: Context) { | |
val filter = IntentFilter(BluetoothDevice.ACTION_FOUND) | |
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED) | |
registerReceiver(discoveryBroadcastReceiver, filter) | |
bluetoothAdapter.startDiscovery() | |
pushBroadcastMessage(BluetoothUtils.ACTION_DISCOVERY_STARTED, null, null) | |
} | |
/** | |
* stop discovery | |
*/ | |
public fun stopDiscovery() { | |
bluetoothAdapter.cancelDiscovery() | |
pushBroadcastMessage(BluetoothUtils.ACTION_DISCOVERY_STOPPED, null, null) | |
} | |
// other stuff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment