Frequency Settings Tutorial

RFID SDK for Android 2.0.3.162

Applicable Devices : FX7500 and FX9600.

Overview

This Tutorial provides a walk-through of the steps to set frequency settings using RFID3 API

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

This tutorial will describe the apis to set the frequency.

Setting it up

The following are the steps to set the frequency.

  • Create Reader Management Object
  • Create a LoginInfo object and Login to the Reader.
  • Perform set frequency operation.

Creating a ReaderManagement object.


// create and initialize the Reader Management object.
    ReaderManagement readerManagement = new ReaderManagement(); 
                                                                                                      
                                                

Creating a LoginInfo object and perform login operation.


//Creating a LoginInfo object and perform login operation.
    LoginInfo loginInfo = new LoginInfo("hostName", "userName", "password", SECURE_MODE.HTTP, false);
    try {
            readerManagement.login(loginInfo,READER_TYPE.FX);
        } catch (InvalidUsageException e) {
            e.printStackTrace();
        } catch (OperationFailureException e) {
           e.printStackTrace();
        }

Performing operation

Set Frequeny Setting.


// Set Frequeny Setting.
try {
    String[] regionList = readerManagement.getSupportedRegionList();
    int index2 = 0;
    String stand = "";
    regionList = readerManagement.getSupportedRegionList();
    System.out.println("\n Total number of Regions: " + regionList.length);
    for (String regionName1 : regionList) {
        ++index2;
        System.out.println("\n Region " + (index2) + " " + regionName1);

        CommunicationStandardInfo[] standardInfoList1 = readerManagement.getRegionStandardList(regionName1);
        for (CommunicationStandardInfo standard : standardInfoList1) {
            System.out.println("---------------------------------------------------------");
            System.out.println(" Standard name " + standard.getStandardName());
            stand = standard.getStandardName();
            System.out.println("Is Hopping Configurable  " + standard.getIsHoppingConfigurable());

            if (standard.getIsHoppingConfigurable()) {
                int numberOfChannels = standard.getChannelIndexList().length;
                System.out.println(" Number of channels  " + numberOfChannels);
                for (int i = 0; i < numberOfChannels; i++) {
                    System.out.println(" Channel index " + standard.getChannelIndexList()[i] + " value "
                            + standard.getChannelFrequencyValueList()[i]);

                }
            }
        }
        String finalStand = stand;
        CommunicationStandardInfo CommSTDconfig = Arrays.stream(standardInfoList1)
                .filter(e -> e.getStandardName().equals(finalStand)).findFirst().orElse(null);
        if (CommSTDconfig != null) {
            if (CommSTDconfig.getIsHoppingConfigurable()) {

                System.out.println("Index Channel");
                for (int i = 0; i < CommSTDconfig.getChannelFrequencyValueList().length; i++) {
                    System.out
                            .println((i + 1) + "          " + CommSTDconfig.getChannelFrequencyValueList()[i]);

                }
                for (int m = 0; m < 2; m++) {

                    Random rand = new Random(); // instance of random class
                    int upperbound = CommSTDconfig.getChannelFrequencyValueList().length;
                    // int[] channelIndexArray = new int[0];
                    int[] channelIndexArray;
                    if (!stand.contains("Plus")) {

                        int[] channelIndexArray1 = { 3, 2, 1 };
                        int[] channelIndexArray2 = { 1, 2, 3 };

                        if (m == 0) {
                            channelIndexArray = channelIndexArray1;
                        }

                        else {
                            channelIndexArray = channelIndexArray2;
                        }
                    } else {
                        // US Plus EU
                        int[] channelIndexArray1 = { 6, 4, 2, 1 };
                        int[] channelIndexArray2 = { 1, 2, 3, 4, 5, 6 };
                        if (m == 0) {
                            channelIndexArray = channelIndexArray1;
                        } else {
                            channelIndexArray = channelIndexArray2;
                        }
                    }


                    int[] chIndex = channelIndexArray;
                    if (chIndex.length > 0) {
                        int j = 0;
                        System.out.println("Selected Channel index(s) ");
                        for (int cindex : chIndex) {
                            if (j == 0) {

                                System.out.print(" " + cindex);
                            } else {
                                System.out.print("," + cindex);

                            }
//
                        }

                        System.out.println("Region activated successful.Setting Channel(s).");
                        boolean hoppingOn = chIndex.length > 1 ? true : false;
                        try {
                            readerManagement.setFrequencySetting(hoppingOn, chIndex);
                        } catch (InvalidUsageException e) {
                            e.printStackTrace();
                        } catch (OperationFailureException e) {
                            if (!e.getVendorMessage()
                                    .equals("Error Code: 65535, Error Description: No changes to commit"))
                                e.printStackTrace();

                        }
                        System.out.println("Region Channel(s) Setting successful.");

//                                    AssertJUnit.assertTrue(true);
                    }
                } // m loop
                // }
            }

//                        AssertJUnit.assertTrue(true);
        }


    }

} catch (OperationFailureException e) {

    System.out.println("Exception: " + e.getVendorMessage());
}

Closer look

  • hostName i.e. IP of the reader.
  • userName i.e. user name of the reader.
  • password i.e. password of the reader.