Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
8db0dbd78d
2 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue