This commit is contained in:
Milos Kozak 2020-04-24 22:40:11 +02:00
commit 8db0dbd78d
2 changed files with 6 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.events
class EventBTChange constructor(val state: Change, val deviceName: String?) : Event() {
class EventBTChange(val state: Change, val deviceName: String?, val deviceAddress: String? = null) : Event() {
enum class Change {
CONNECT,
DISCONNECT

View file

@ -13,13 +13,13 @@ class BTReceiver : DaggerBroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, intent)
val device : BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
val device: BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
when (intent.action) {
BluetoothDevice.ACTION_ACL_CONNECTED ->
rxBus.send(EventBTChange(EventBTChange.Change.CONNECT, device.name))
BluetoothDevice.ACTION_ACL_CONNECTED ->
rxBus.send(EventBTChange(EventBTChange.Change.CONNECT, deviceName = device.name, deviceAddress = device.address))
BluetoothDevice.ACTION_ACL_DISCONNECTED ->
rxBus.send(EventBTChange(EventBTChange.Change.DISCONNECT, device.name))
rxBus.send(EventBTChange(EventBTChange.Change.DISCONNECT, deviceName = device.name, deviceAddress = device.address))
}
}
}