FXR90-Firmware Update

RFID SDK for Android 2.0.2.124

Applicable Devices : FXR90

Overview

This Tutorial provides a walk-through of the steps to update firmware

Create The Project

  • Start by creating a new project in Android Studio. For help, see the Android Studio tutorial.
  • Refer Hello RFID to prepare basic setup to work with RFID Reader and then follow this guide

Details

SDK can update the FXR90 firmware using the following API..


  updateFirmware(String path, String ip)                                                                 
                                                

User needs to make sure that path is obtained using the Android Storage Access Framework. IP address of the interface from where reader reach your android device hosting the firmware files

Performing operations

Simple Login HTTP


// simple login with HTTPS
    try {
		mReader.setPassword(password);
		mReader.secureConnection(false);  ( true if you want perform secure connection)
      	mReader.connect();

	// Firmware update
 
   } catch (InvalidUsageException e) {
            e.printStackTrace();
        } catch (OperationFailureException e) {
           e.printStackTrace();
        }
                                                                                                   
                                                

Calling the Firmware update API call


try {
    mReader.Config.updateFirmware(Path, ip);
} catch (InvalidUsageException | OperationFailureException e) {
    if (e.getStackTrace().length > 0) {
        Log.e(TAG, e.getStackTrace()[0].toString());
    }
}

Getting firmware update status under event status notification

                                                   
 public void eventStatusNotify(RfidStatusEvents rfidStatusEvents) {
        if(rfidStatusEvents.StatusEventData.getStatusEventType() == STATUS_EVENT_TYPE.FIRMWARE_UPDATE_EVENT){
            String status = rfidStatusEvents.StatusEventData.FWEventData.getStatus();
            int imageDownloadProgress = rfidStatusEvents.StatusEventData.FWEventData.getImageDownloadProgress();
            int overallUpdateProgress = rfidStatusEvents.StatusEventData.FWEventData.getOverallUpdateProgress();
            Log.d(TAG,"FW status: "+status+", idp: "+imageDownloadProgress+", ovp: "+overallUpdateProgress );
        }
    }
}

 

Closer look

Support function to launch file storage.


  private void openFileStorage(){
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*");
    Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary:Download");
    intent.putExtra("DocumentsContract.EXTRA_INITIAL_URI", uri);
    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    activityResultLauncher.launch(intent);
}
Note: Don’t select file from the shortcut path.

private final ActivityResultLauncher activityResultLauncher = registerForActivityResult(
        new ActivityResultContracts.StartActivityForResult(),
        new ActivityResultCallback() {
            @Override
            public void onActivityResult(ActivityResult result) {
                if (result.getResultCode() == Activity.RESULT_OK) {
                    Intent data = result.getData();
                    if (data != null) {
                        if (data.getData().toString().contains("content://com.android.providers")) {
                            ShowPlugInPathChangeDialog();
                        } else {
                            selectedFilePath = data.getData().getPath();
                            binding.selectedFw.setText(selectedFilePath);
                        }
                    }
                }
            }

            private void ShowPlugInPathChangeDialog() {
                AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
                builder.setMessage("Don't select file from shortcut path")
                        .setCancelable(false)
                        .setPositiveButton("OK", (dialog, id) -> {
                            dialog.dismiss();
                        });
                AlertDialog alert = builder.create();
                alert.show();
            }
        }
);