MPI Extensibility
We have exposed the underlying Java MPI APIs to allow you to interact with Miura devices outside of the SDK should you wish to do so. For example, if you wanted to have a custom tip menu, you could show the menu before calling toro.startTransaction() and add the tip amount in the TransactionMetadata object. See more about gratuities in the Gratuities section.
There is a more comprehensive demo of how this can be achieved in the sample application, see in particular the services.cabcard.torosample.ui.device package and MiuraDeviceUtil object.
Here is a very basic code snippet showing how you could display a message on a Miura device:
Tip: ensure you use the openSession and closeSession methods from the Toro SDK. This allows the SDK to have visibility over the session state, and therefore the session will be "re-used" when calling startTransaction.
import android.util.Log
import com.miurasystems.mpi.api.executor.MiuraManager
import com.miurasystems.mpi.api.utils.DisplayTextUtils
import com.miurasystems.mpi.enums.InterfaceType
import services.cabcard.toro.ToroClient
import services.cabcard.toro.core.listener.ConnectionListener
fun test(toro: ToroClient) {
// Open a session with the selected device over Bluetooth or USB.
toro.openSession(object: ConnectionListener {
override fun onConnected() {
// Now you can use any of the MPI APIs you want.
displayText("Hello, world!")
toro.closeSession()
}
override fun onDisconnected() {
Log.e("Test", "Disconnected from device")
}
override fun onConnectionAttemptFailed() {
Log.e("Test", "Connection attempt failed")
}
})
}
fun displayText(text: String) {
// This is the same MiuraManager instance the Toro SDK is using under the hood.
val miuraManager = MiuraManager.getInstance()
val centeredText = DisplayTextUtils.getCenteredText(text)
val success = miuraManager.mpiClient?.displayText(
InterfaceType.MPI,
centeredText,
true,
true,
false
) ?: false
if (!success) {
Log.e("Test", "Failed to display text on device?!")
}
}The full documentation for the available MPI APIs are available on Miura's website. You may need to request access from them. https://api.miurapartners.com/