Time Settings Tutorial

RFID SDK for Android 2.0.2.94

Applicable Devices : FX7500 and FX9600.

Overview

This Tutorial provides a walk-through of the steps to perform get and set time zone operations 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 for setting and getting the time zone info, local time and ntp server time.

Setting it up

The following are the steps to get and set time zone info, local time and ntp server time to the reader

  • Create Reader Management Object
  • Create a LoginInfo object and Login to the Reader.
  • Create TimeZoneInfo object for setting the time zone.
  • Create SYSTEMTIME object for setting the local time.
  • Perform get and set time zone info, local time and ntp server time operations.

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

Get Time Zone.


// Get the time zone.
    try {
        TimeZoneInfo timeZoneInfo = readerManagement.TimeZone.getList();
    } catch (InvalidUsageException e) {
         e.printStackTrace();
    }    catch (OperationFailureException e) {
         e.printStackTrace();
    }

Set Time Zone.


// Setting time zone.
    try {
        //System.out.println(" before gettimezonelist function");
        TimeZoneInfo timezoneInfo = readerManagement.TimeZone.getList();

        for (int i = 0; i < timezoneInfo.getTimeZones().length; i++) {
        //System.out.println(" Setting the Time Zone to the next index");
        readerManagement.TimeZone.setActive((short) i);
        }
    } catch (Exception e) {

    }

Get Ntp Server.


// Get Ntp Server.
    try {
    String[] ntpList = readerManagement.getNtpServer();
    } catch (InvalidUsageException e) {
    e.printStackTrace();
    } catch (OperationFailureException e) {
    e.printStackTrace();
    }

Set Ntp Server.


// Setting Ntp Server.
    try {
    String[] ntpList = readerManagement.getNtpServer();
    for(int i=0; i< ntpList.length ; i++){
    readerManagement.setNtpServer(ntpList[i]);
    }
    } catch (InvalidUsageException e) {
    e.printStackTrace();
    } catch (OperationFailureException e) {
    e.printStackTrace();
    }

Get Local Time.


// Get the local time.
    try {
    String localTime = readerManagement.getLocalTime();
    } catch (InvalidUsageException e) {
    e.printStackTrace();
    } catch (OperationFailureException e) {
    e.printStackTrace();
    }

Set Local Time.


// Setting local time.
    SYSTEMTIME time = new SYSTEMTIME();
    try {
    time.Year = 2021;
    time.Day = 5;
    time.DayOfWeek = 05;
    time.Hour = 1;
    time.Milliseconds = 5;
    time.Minute = 5;
    time.Month = 2;
    time.Second = 3;
    readerManagement.setLocalTime(time);
    } catch (Exception e) {

    }

Closer look

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