Skip to content

Instantly share code, notes, and snippets.

@Xiryl
Created August 12, 2021 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xiryl/ddac5c7d1cc8fd871233115b4dc3e43e to your computer and use it in GitHub Desktop.
Save Xiryl/ddac5c7d1cc8fd871233115b4dc3e43e to your computer and use it in GitHub Desktop.
BluetoothSDK-Service2
/**
* 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