WLAN Tutorial

RFID SDK for Android 2.0.3.162

Applicable Devices: Handheld Readers RFD40XX

Overview

This Tutorial provides a walk-through of the steps to perform WIFI operation using RFID3 API.
Wifi is supported only with RFD40XX premium and premium plus devices.

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

New WIFI API in the SDK enables user to use RFD40/RFD90 devices to perform WIFI operations. Following wifi operations can be executed.

  1. WIFI SCAN
  2. WIFI Profile creation
  3. WIFI Profile save
  4. WIFI Profile connect/disconnect.

NOTE: Certificates that needs to be used for WIFI profile needs to be installed on the device using 123RFID Desktop

Wifi Scan

Call API wifiScan() to start scan. Once scan is started notification will be triggered for scan started and scan stopped events, these events are pushed to application via RfidEventsListener.


//wifi Scan
RFIDResults rfidResults = reader.mConnectedReader.Config.wifiScan();


//wifi Events
public class EventHandler implements RfidEventsListener {

   @Override
  public void eventStatusNotify(RfidStatusEvents rfidStatusEvents) {
   if (rfidStatusEvents.StatusEventData.getStatusEventType() 
               == STATUS_EVENT_TYPE.WPA_EVENT) {
   String status = rfidStatusEvents.StatusEventData.WPAEventData.getType();
   String ssid = rfidStatusEvents.StatusEventData.WPAEventData.getssid();
   readWifiScanNotification(status, ssid);
    }
  }
}


public void readWifiScanNotification(String status, String ssid) {
    mActivity.runOnUiThread(() -> {
        switch (status) {
            case "ScanStart":
                //update UI for scan start
                break;
            case "ScanStop":
		//update UI for scan stop
                break;
            case "Operation Failed":
                break;
        }
    });


                                                

Scan data results will be pushed to application via WifiScanDataEventsListener


	//wifi Scan Data
	 @Override
	 public void eventWifiScanNotify(RfidWifiScanEvents rfidwifiscanevents) {
  	 IEvents.WifiScanEventData data = rfidwifiscanevents.getWifiScanEventData();
     Log.d(TAG, "ssid: "+ data.wifiscandata.getssid()
     + " Protocol:" + data.wifiscandata.getProtocol() +"\n");
	 }
     

Make Sure to register listeners using below code

WiFi Add Profile

Please refer the sample code to add WiFi WPA3 Personal profile


WifiProfile wifiProfile = new WifiProfile();
WifiSecureConfig wifiSecureConfig = new WifiSecureConfig();
wifiProfile.setssid("Zebra WiFi");
wifiProfile.setprotocol(ENUM_WIFI_PROTOCOL_TYPE.WPA3_Personal_SAE);
wifiProfile.setpassword("zebra@12345");
wifiProfile.setconfig(wifiSecureConfig);
RFIDResults rfidResults = reader.Config.wifiAddProfile(wifiProfile);

Please refer the sample code to add WiFi WPA2 Enterprise profile


WifiProfile wifiProfile = new WifiProfile();
WifiSecureConfig wifiSecureConfig = new WifiSecureConfig();

wifiProfile.setssid("Zebra WiFi Enterprise");
wifiProfile.setprotocol(ENUM_WIFI_PROTOCOL_TYPE.WPA2_Enterprise_CCMP);

wifiSecureConfig.seteap("TTLS");
wifiSecureConfig.setcacert("ca_cert.pem");
wifiSecureConfig.setidentity("identity");
wifiSecureConfig.setAnonymousIdentity("anonymous_password");
wifiSecureConfig.setPassword("zebra@12345");
wifiProfile.setconfig(wifiSecureConfig);
RFIDResults rfidResults = reader.Config.wifiAddProfile(wifiProfile);
 

WiFi Saved Profile List

This list out the number of profile saved in the Reader. As of now we can save maximum 10 profiles in reader.


List profilelist = new ArrayList<>();
profilelist = reader.Config.wifiListProfile();

WiFi Delete Profile

Please refer the sample code to delete profile from saved profile list.


RFIDResults rfidResults = reader.Config.wifiDeleteProfile("Zebra WiFi")

Get Installed WiFi Certificates

This API will return back the list of installed certificate in string format, by using this we can add enterprise profiles of different EAP


ArrayList wpaCertificates = new ArrayList<>();
wpaCertificates = reader.Config.wifiGetCertificates();
wifiSecureConfig.setcacert("ca_cert.pem");
wifiSecureConfig.setclientcert("client_cert.pem");
wifiSecureConfig.setPrivateKey("key.pem");

WiFi Connect Non Roaming

This API used to connect the Reader WiFi from the saved profile list. Pass the SSID to connect.


RFIDResults rfidResults = reader.Config.wifiConnectNonRoaming("Zebra WiFi");

//wifi Events
@Override
public void eventStatusNotify(RfidStatusEvents rfidStatusEvents) {
  if (rfidStatusEvents.StatusEventData.getStatusEventType() 
               == STATUS_EVENT_TYPE.WPA_EVENT) {
  String status = rfidStatusEvents.StatusEventData.WPAEventData.getType();
  String ssid = rfidStatusEvents.StatusEventData.WPAEventData.getssid();
  readWifiScanNotification(status, ssid);
    }
}



public void readWifiScanNotification(String status, String ssid) {
    mActivity.runOnUiThread(() -> {
        switch (status) {
            case "Connect":
                //Update UI with connected ssid
                break;
            case "Operation Failed":
                break;
        }
    });

WiFi Connect Roaming

This API used to connect the Reader WiFi from the saved profile list. It will be auto connected to available profile


RFIDResults rfidResults = reader.Config.wifiConnectRoaming();


//wifi Events
@Override
public void eventStatusNotify(RfidStatusEvents rfidStatusEvents) {
  if (rfidStatusEvents.StatusEventData.getStatusEventType() 
               == STATUS_EVENT_TYPE.WPA_EVENT) {
  String status = rfidStatusEvents.StatusEventData.WPAEventData.getType();
  String ssid = rfidStatusEvents.StatusEventData.WPAEventData.getssid();
  readWifiScanNotification(status, ssid);
    }
}



public void readWifiScanNotification(String status, String ssid) {
    mActivity.runOnUiThread(() -> {
        switch (status) {
            case "Connect":
                //Update UI with connected ssid
                break;
            case "Operation Failed":
                break;
        }
    });

WiFi Disconnect

Call WiFi disconnect API as shown in code below


RFIDResults rfidResults = reader. Config.wifiDisconnect();


//wifi Events
@Override
public void eventStatusNotify(RfidStatusEvents rfidStatusEvents) {
  if (rfidStatusEvents.StatusEventData.getStatusEventType() 
               == STATUS_EVENT_TYPE.WPA_EVENT) {
  String status = rfidStatusEvents.StatusEventData.WPAEventData.getType();
  String ssid = rfidStatusEvents.StatusEventData.WPAEventData.getssid();
  readWifiScanNotification(status, ssid);
    }
}



public void readWifiScanNotification(String status, String ssid) {
    mActivity.runOnUiThread(() -> {
        switch (status) {
            case " Disconnect":
                //Update UI with disconnected ssid
                break;
            case "Operation Failed":
                break;
        }
    });

WiFi Status

WiFi Status API will return back RSSI, Address, channel, state, band, ssid name, mac, netmask as a key pair values as shown in below code


HashMap status = new HashMap<>();
RFIDResults rfidResults = reader.Config.wifiGetStatus(status);