repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
implementation 'com.github.trifork:AndroidBluetooth:1.0.0' // check the releases/tags page to find the latest version
}
Create an instance of the BluetoothManager
for injection.
BluetoothManager(
applicationContext,
BluetoothManager.Configuration(
connectionMtuSize = 200, // optional
logger = object : BluetoothManager.Logger { // optional
override fun v(message: String) {
Timber.tag(TAG).v(message) // or, your logging framework of choice
}
override fun d(message: String) {
Timber.tag(TAG).d(message)
}
override fun i(message: String) {
Timber.tag(TAG).i(message)
}
override fun w(message: String) {
Timber.tag(TAG).w(message)
}
override fun e(message: String) {
Timber.tag(TAG).e(message)
}
},
hexFormatter = { bytes -> bytes.joinToString("-") { "%02x".format(it) } } // optional
)
)
With this instance you can:
- start scan
- stop scan
- connect
- read the rssi of a connection
- set the priority of a connection
- add and remove individual listeners to connections
- enable notification for a characteristic on a connection
- read a characteristic on a connection
- write bytes to a characteristic on a connection
This library is distributed with using JitPack.io.
Go to the releases page.
Select "Draft a new release"
Set a tag version. For example v1.0.1
Select @target to be the main
branch.
Provide a release title, if it should not be the tag version provided.
Press "Publish release"
This will create a release and a corresponding tag.
๐ Hurray! It is now available to users to start using in their Android projects.