Skip to content

Commit

Permalink
Improve callback calls (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ll3 authored Mar 12, 2024
1 parent 49995bb commit 59e1dac
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ class TransportBleCentralClientHolder(
"TransportBleCentralClientHolder.gattClientCallback.onPeerConnected",
"Peer Connected"
)
callback?.update(mapOf(Pair("connected", "")))
}

override fun onPeerDisconnected() {
Log.d(
"TransportBleCentralClientHolder.gattClientCallback.onPeerDisconnected",
"Peer Disconnected"
)
callback?.update(mapOf(Pair("disconnected", "")))
gattClient.disconnect()
}

Expand All @@ -96,7 +98,11 @@ class TransportBleCentralClientHolder(
"progress: $progress max: $max"
)

callback?.update(mapOf(Pair("progress", mapOf(Pair("curr", progress), Pair("max", max)))))
if(progress == max) {
callback?.update(mapOf(Pair("success", "")))
} else {
callback?.update(mapOf(Pair("uploadProgress", mapOf(Pair("curr", progress), Pair("max", max)))))
}
}

override fun onMessageReceived(data: ByteArray) {
Expand All @@ -110,6 +116,7 @@ class TransportBleCentralClientHolder(
updateRequestData(data)
} catch (e: Error) {
Log.e("MDoc", e.toString())
callback?.update(mapOf(Pair("error", e)))
}
}

Expand Down

0 comments on commit 59e1dac

Please sign in to comment.