Skip to content

Commit

Permalink
Make callback optional
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ll3 committed Mar 7, 2024
1 parent 27b7303 commit de59482
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class CredentialsViewModel : ViewModel() {
"BLE",
"Central",
_session.value!!.bleIdent.toByteArray(),
::updateRequestData
::updateRequestData,
null
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Transport(private var bluetoothManager: BluetoothManager) {
deviceRetrievalOption: String,
ident: ByteArray,
updateRequestData: (data: ByteArray) -> Unit,
callback: BLESessionStateDelegate
callback: BLESessionStateDelegate?
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TransportBle(private var bluetoothManager: BluetoothManager) {
application: String, serviceUUID: UUID,
deviceRetrievalOption: String, ident: ByteArray,
updateRequestData: (data: ByteArray) -> Unit,
callback: BLESessionStateDelegate
callback: BLESessionStateDelegate?
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TransportBleCentralClientHolder(
private var bluetoothManager: BluetoothManager,
private var serviceUUID: UUID,
private var updateRequestData: (data: ByteArray) -> Unit,
private var callback: BLESessionStateDelegate,
private var callback: BLESessionStateDelegate?,
) : Activity() {

private var context: Context = this
Expand Down Expand Up @@ -96,7 +96,7 @@ class TransportBleCentralClientHolder(
"progress: $progress max: $max"
)

callback.update(mapOf(Pair("progress", mapOf(Pair("curr", progress), Pair("max", max)))))
callback?.update(mapOf(Pair("progress", mapOf(Pair("curr", progress), Pair("max", max)))))
}

override fun onMessageReceived(data: ByteArray) {
Expand Down

0 comments on commit de59482

Please sign in to comment.