-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
beckon/src/main/java/com/technocreatives/beckon/internal/BeckonBondingObserver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.technocreatives.beckon.internal | ||
|
||
import android.bluetooth.BluetoothDevice | ||
import com.technocreatives.beckon.BondState | ||
import com.technocreatives.beckon.util.debugInfo | ||
import io.reactivex.subjects.BehaviorSubject | ||
import no.nordicsemi.android.ble.observer.BondingObserver | ||
import timber.log.Timber | ||
|
||
internal class BeckonBondingObserver( | ||
private val bondStateSubject: BehaviorSubject<BondState>, | ||
) : BondingObserver { | ||
override fun onBondingRequired(device: BluetoothDevice) { | ||
// todo do something | ||
Timber.i("onBondingRequired ${device.debugInfo()}") | ||
} | ||
|
||
override fun onBonded(device: BluetoothDevice) { | ||
Timber.i("onBonded ${device.debugInfo()}") | ||
bondStateSubject.onNext(BondState.Bonded) | ||
} | ||
|
||
override fun onBondingFailed(device: BluetoothDevice) { | ||
Timber.i("onBondingFailed ${device.debugInfo()}") | ||
bondStateSubject.onNext(BondState.NotBonded) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
beckon/src/main/java/com/technocreatives/beckon/internal/BeckonConnectionObserver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.technocreatives.beckon.internal | ||
|
||
import android.bluetooth.BluetoothDevice | ||
import com.technocreatives.beckon.BleConnectionState | ||
import com.technocreatives.beckon.util.debugInfo | ||
import no.nordicsemi.android.ble.observer.ConnectionObserver | ||
import timber.log.Timber | ||
|
||
internal class BeckonConnectionObserver( | ||
private val stateCallback: (BleConnectionState) -> Unit | ||
) : ConnectionObserver { | ||
override fun onDeviceConnecting(device: BluetoothDevice) { | ||
Timber.i("onDeviceConnecting ${device.debugInfo()}") | ||
stateCallback(BleConnectionState.Connecting) | ||
} | ||
|
||
override fun onDeviceConnected(device: BluetoothDevice) { | ||
Timber.i("onDeviceConnected $device, debugInfo: ${device.debugInfo()}") | ||
stateCallback(BleConnectionState.Connected) | ||
} | ||
|
||
override fun onDeviceFailedToConnect(device: BluetoothDevice, reason: Int) { | ||
Timber.w("onError Device: ${device.debugInfo()} Reason: $reason") | ||
stateCallback(BleConnectionState.Failed("NO Message", reason)) | ||
} | ||
|
||
override fun onDeviceReady(device: BluetoothDevice) { | ||
Timber.i("onDeviceReady ${device.debugInfo()}") | ||
stateCallback(BleConnectionState.Ready) | ||
} | ||
|
||
override fun onDeviceDisconnecting(device: BluetoothDevice) { | ||
Timber.i("onDeviceDisconnecting $device") | ||
stateCallback(BleConnectionState.Disconnecting) | ||
} | ||
|
||
override fun onDeviceDisconnected(device: BluetoothDevice, reason: Int) { | ||
Timber.i("onDeviceDisconnected $device") | ||
stateCallback(BleConnectionState.Disconnected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters