Skip to content

Commit

Permalink
Add progress callback and remove success callback (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ll3 authored Mar 7, 2024
1 parent 1a5ac5c commit 27b7303
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class BLESessionManager {
"BLE",
"Central",
sessionData.bleIdent.toByteArray(),
::updateRequestData
::updateRequestData,
callback
)
this.callback.update(mapOf(Pair("engagingQRCode", sessionData.qrCodeUri)))
} catch (e: Error) {
Expand Down Expand Up @@ -87,7 +88,6 @@ public class BLESessionManager {
val signatureData = submitSignature(this.sessionManager!!, signature)
this.state = signatureData.state
this.bleManager!!.send(signatureData.response)
this.callback.update(mapOf(Pair("success", "")))
} catch (e: Error) {
Log.e("CredentialsViewModel.submitNamespaces", e.toString())
this.callback.update(mapOf(Pair("error", e.toString())))
Expand Down
5 changes: 0 additions & 5 deletions WalletSdk/src/main/java/com/spruceid/wallet/sdk/GattClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,6 @@ class GattClient(private var callback: GattClientCallback,
val descriptor: BluetoothGattDescriptor =
characteristicServer2Client!!.getDescriptor(clientCharacteristicConfigUuid)

if (descriptor == null) {
callback.onError(Error("Error getting Server2Client clientCharacteristicConfig desc."))
return
}

descriptor.value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE

if (!gatt.writeDescriptor(descriptor)) {
Expand Down
2 changes: 2 additions & 0 deletions WalletSdk/src/main/java/com/spruceid/wallet/sdk/Transport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Transport(private var bluetoothManager: BluetoothManager) {
deviceRetrievalOption: String,
ident: ByteArray,
updateRequestData: (data: ByteArray) -> Unit,
callback: BLESessionStateDelegate
) {

/**
Expand All @@ -41,6 +42,7 @@ class Transport(private var bluetoothManager: BluetoothManager) {
deviceRetrievalOption,
ident,
updateRequestData,
callback
)
}

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

/**
Expand All @@ -43,6 +44,7 @@ class TransportBle(private var bluetoothManager: BluetoothManager) {
bluetoothManager,
serviceUUID,
updateRequestData,
callback,
)
transportBleCentralClientHolder.connect(ident)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TransportBleCentralClientHolder(
private var bluetoothManager: BluetoothManager,
private var serviceUUID: UUID,
private var updateRequestData: (data: ByteArray) -> Unit,
private var callback: BLESessionStateDelegate,
) : Activity() {

private var context: Context = this
Expand Down Expand Up @@ -94,6 +95,8 @@ class TransportBleCentralClientHolder(
"TransportBleCentralClientHolder.gattClientCallback.onMessageSendProgress",
"progress: $progress 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 27b7303

Please sign in to comment.