diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventBTChange.kt b/app/src/main/java/info/nightscout/androidaps/events/EventBTChange.kt index 6956cbb2a5..9285fa5750 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventBTChange.kt +++ b/app/src/main/java/info/nightscout/androidaps/events/EventBTChange.kt @@ -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 diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt index a3b54e924e..37a135b44f 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/BTReceiver.kt @@ -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)) } } } \ No newline at end of file