Class BLETransfer
-
- All Implemented Interfaces:
-
com.scytales.mvalid.sdk.engagement.DeviceEngagementDependent
,com.scytales.mvalid.sdk.retrieval.Transfer
,com.scytales.mvalid.sdk.retrieval.TransferProgressListenable
,com.scytales.mvalid.sdk.retrieval.TransferReceiveDependent
,java.io.Closeable
,java.lang.AutoCloseable
public final class BLETransfer implements Transfer<D>, DeviceEngagementDependent, TransferReceiveDependent, TransferProgressListenable, Closeable
Transfer implementation that transfers data using Bluetooth LE.
For android SDK >= 31
- android.Manifest.permission.BLUETOOTH_ADVERTISE
- android.Manifest.permission.BLUETOOTH_SCAN
- android.Manifest.permission.BLUETOOTH_CONNECT
For android SDK <31
- android.Manifest.permission.ACCESS_FINE_LOCATION
- android.Manifest.permission.ACCESS_COARSE_LOCATION
public class SomeActivity extends
implements DeviceEngagementCallback, TransferReceiveCallback, TransferProgressListener { private static final String TAG = "SomeActivity"; private Map<String, Map<String, Map<String, Boolean>>> docRequests = ... private SessionManager sessionManager; @Override public void onEngage(@NonNull Received<EngagementReceived> engagementReceived) { engagementReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { DeviceEngagement deviceEngagement = success.getDeviceEngagement(); Handover handover = success.getHandover(); try { sessionManager = new SessionManager(deviceEngagement, handover); byte[] requestBytes = sessionManager.createRequest(docRequests); BLETransfer bleTransfer = new BLETransfer(getApplicationContext()); bleTransfer.setProgressListener(this); bleTransfer.setTransferReceiveCallback(this); bleTransfer.forDeviceEngagement(deviceEngagement); bleTransfer.send(requestBytes); } catch (SDKException e) { android.util.Log.e(TAG, e.getMessage(), e); } }); } @Override public void onProgressEvent(@NonNull TransferProgressEvent event) { android.util.Log.i(TAG, event.toString()); } @Override public void onReceive(@NonNull Received<TransferReceived> transferReceived) { transferReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { success.runForDevice(receivedBytes -> { try { com.scytales.mvalid.sdk.session.SessionData sessionData = sessionManager.decryptResponse(receivedBytes); // do stuff with decrypted } catch (SDKException e) { // handle decryption error } }); }); } }androidx.appcompat.app.AppCompatActivity
-
-
Constructor Summary
Constructors Constructor Description BLETransfer(Context context)
Instantiates a new Ble transfer.
-
Method Summary
Modifier and Type Method Description BLETransfer
forDeviceEngagement(@NonNull() DeviceEngagement deviceEngagement)
For device engagement device engagement dependent. BLETransfer
unsetTransferProgressListener()
Unset transfer progress listener transfer progress listenable. BLETransfer
setTransferReceiveCallback(@NonNull() TransferReceiveCallback callback)
Sets transfer receive callback. void
send(@NonNull() Request request)
Send. void
stop()
Stop. void
close()
BLETransfer
setTransferProgressListener(@NonNull() TransferProgressListener transferProgressListener)
Sets transfer progress listener. -
-
Constructor Detail
-
BLETransfer
BLETransfer(Context context)
Instantiates a new Ble transfer.- Parameters:
context
- the context
-
-
Method Detail
-
forDeviceEngagement
BLETransfer forDeviceEngagement(@NonNull() DeviceEngagement deviceEngagement)
For device engagement device engagement dependent.
- Parameters:
deviceEngagement
- the device engagement
-
unsetTransferProgressListener
@NonNull() BLETransfer unsetTransferProgressListener()
Unset transfer progress listener transfer progress listenable.
-
setTransferReceiveCallback
@NonNull() BLETransfer setTransferReceiveCallback(@NonNull() TransferReceiveCallback callback)
Sets transfer receive callback.
- Parameters:
callback
- the callback
-
stop
void stop()
Stop.
-
close
void close()
-
setTransferProgressListener
@NonNull() BLETransfer setTransferProgressListener(@NonNull() TransferProgressListener transferProgressListener)
Sets transfer progress listener.
-
-
-
-